fs

morpheus filesystem files
git clone git://git.2f30.org/fs.git
Log | Files | Refs

commit 4465767a5a1622824b4f231f5cbd0de27d5ecacc
parent a14a4a5b19836f2c0a7d9df7dfe28a5d227b2ddc
Author: sin <sin@2f30.org>
Date:   Mon Oct 27 13:59:27 +0000

Update fs

Diffstat:
bin/enter-emul | 34++++++++++++++++++++++++++++++++++
bin/mktcb | 22++++++++++++++++++++++
bin/rc.init | 80+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
bin/rc.shutdown | 29+++++++++++++----------------
bin/rc.svc | 9++-------
bin/respawn | 26--------------------------
bin/svc | 3+++
bin/svc.d/avail/sdhcp | 21---------------------
bin/svc.d/bare.sh | 37-------------------------------------
bin/svc.d/default/sdhcp | 1-
etc/group | 22+++++++++++-----------
etc/issue | 1-
etc/motd | 0
etc/passwd | 6+++---
etc/skel/.mkshrc | 4----
etc/skel/.profile | 14--------------
etc/skel/.xinitrc | 3---
root/.mkshrc | 4----
root/.profile | 14--------------
root/.xinitrc | 3---
skel/.mkshrc | 8++++++++
skel/.profile | 14++++++++++++++
skel/.xinitrc | 1+
svc.d/bare.sh | 37+++++++++++++++++++++++++++++++++++++
24 files changed, 196 insertions(+), 197 deletions(-)
diff --git a/bin/enter-emul b/bin/enter-emul @@ -0,0 +1,34 @@ +#!/bin/sh + +if test -z "$1"; then + root="/emul" +else + root="$1" +fi + +echo -n "Mounting $root/dev... " +mount -o bind /dev $root/dev +echo "done." +echo -n "Mounting $root/dev/pts... " +mount -o bind /dev/pts $root/dev/pts +echo "done." +echo -n "Mounting $root/proc... " +mount -t proc proc $root/proc +echo "done." +echo -n "Mounting $root/sys... " +mount -o bind /sys $root/sys +echo "done." +echo "Chrooting $root..." +chroot $root /bin/sh +echo -n "Unmounting $root/dev/pts... " +umount $root/dev/pts +echo "done." +echo -n "Unmounting $root/dev... " +umount $root/dev +echo "done." +echo -n "Unmounting $root/sys... " +umount $root/sys +echo "done." +echo -n "Unmounting $root/proc... " +umount $root/proc +echo "done." diff --git a/bin/mktcb b/bin/mktcb @@ -0,0 +1,22 @@ +#!/bin/sh +# make tcb file structure from a /etc/shadow file. +# Usage: cat /etc/shadow | mktcb +# TODO: need to set group "auth" and permissions. +# http://docs.altlinux.org/manpages/tcb.5.html + +umask 0077 +mkdir -p /etc/tcb +chmod 755 /etc/tcb +while read -r line; do + name=$(printf '%s' "$line" | cut -f 1 -s -d ':') + if test -z x"$name"; then + continue + fi + hash=$(printf '%s' "$line" | cut -f 2 -d ':') + mkdir -p "/etc/tcb/$name" + chown "$name:root" "/etc/tcb/$name" + chmod 700 "/etc/tcb/$name" + printf '%s\n' "$line" > "/etc/tcb/$name/shadow" + chown "$name:root" "/etc/tcb/$name/shadow" + chmod 600 "/etc/tcb/$name/shadow" +done diff --git a/bin/rc.init b/bin/rc.init @@ -1,8 +1,5 @@ #!/bin/sh -PATH=/bin -export PATH - umask 022 . /etc/rc.conf @@ -14,46 +11,55 @@ echo echo # Soft reboot on ctrl-alt-del -ctrlaltdel -s +/bin/ctrlaltdel -s -mkdir -p /proc -mkdir -p /sys -mount -n -t proc -o nosuid,noexec,nodev proc /proc -mount -n -t sysfs -o nosuid,noexec,nodev sysfs /sys +/bin/mount -n -t proc -o nosuid,noexec,nodev proc /proc +/bin/mount -n -t sysfs -o nosuid,noexec,nodev sysfs /sys -mount -n -t tmpfs -o nosuid,mode=0755 dev /dev -mkdir -p /dev/pts -mount -n -t devpts -o gid=5,mode=0620 devpts /dev/pts +/bin/mount -n -t tmpfs -o nosuid,mode=0755 dev /dev +/bin/mkdir -p /dev/pts +/bin/mount -n -t devpts -o gid=5,mode=0620 devpts /dev/pts -grep -q " verbose" /proc/cmdline && dmesg -n 8 || dmesg -n 3 +/bin/grep -q " verbose" /proc/cmdline && dmesg -n 8 || dmesg -n 3 -mount -o remount,ro / +/bin/mount -o remount,ro / echo Running smdev -smdev -s +/bin/smdev -s echo Setting smdev as the kernel hotplug echo /bin/smdev > /proc/sys/kernel/hotplug +# HACK! +cd /dev +/bin/ln -sf /proc/self/fd/0 stdin +/bin/ln -sf /proc/self/fd/1 stdout +/bin/ln -sf /proc/self/fd/2 stderr +/bin/ln -sf /proc/self/fd fd +cd - 1>/dev/null + echo Checking filesystems -fsck -ATa +/bin/fsck -ATa if [ $? -eq 1 ]; then echo Filesystem errors exist, fix manually. - sh - halt -r + /bin/sh + /bin/halt -r fi echo Remounting root as read-write -mount -o remount,rw / +/bin/mount -o remount,rw / echo Mounting filesystems -mount -a +/bin/mount -a + +ln -sf /proc/mounts /etc/mtab echo "Setting hostname to $HOSTNAME" -hostname $HOSTNAME +/bin/hostname $HOSTNAME echo Bringing up the lo interface -ifconfig lo up +/bin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host +/bin/ip link set lo up HWCLOCK_PARAMS="-s" case $HARDWARECLOCK in @@ -73,23 +79,26 @@ esac if [ -n "$HWCLOCK_PARAMS" ]; then echo Setting hwclock [ -n "$TIMEZONE" ] && export TZ="$TIMEZONE" - hwclock $HWCLOCK_PARAMS + /bin/hwclock $HWCLOCK_PARAMS /dev/rtc0 unset TZ fi echo Setting random seed -[ -f /etc/random-seed ] && cat /etc/random-seed >/dev/urandom -dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null +[ -f /etc/random-seed ] && /bin/cat /etc/random-seed >/dev/urandom +/bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null echo Storing dmesg output to /var/log/dmesg.log -dmesg > /var/log/dmesg.log -if [ -e /proc/sys/kernel/dmesg_restrict ] && [ $(cat /proc/sys/kernel/dmesg_restrict) = "1" ]; +/bin/dmesg > /var/log/dmesg.log +if [ -e /proc/sys/kernel/dmesg_restrict ] && [ $(/bin/cat /proc/sys/kernel/dmesg_restrict) = "1" ]; then - chmod 0600 /var/log/dmesg.log + /bin/chmod 0600 /var/log/dmesg.log else - chmod 0644 /var/log/dmesg.log + /bin/chmod 0644 /var/log/dmesg.log fi +echo Enabling core dumps +ulimit -c unlimited + if [ -x /bin/rc.modules ]; then echo Running rc.modules /bin/rc.modules @@ -100,8 +109,15 @@ if [ -x /bin/rc.svc ]; then /bin/rc.svc fi +if [ -x /bin/rc.local ]; then + echo Running rc.local + /bin/rc.local +fi + +: > /var/run/utmp + echo -sh -c 'respawn getty /dev/tty1 linux' &>/dev/null & -sh -c 'respawn getty /dev/tty2 linux' &>/dev/null & -sh -c 'respawn getty /dev/tty3 linux' &>/dev/null & -sh -c 'respawn getty /dev/tty4 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty1 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty2 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty3 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty4 linux' &>/dev/null & diff --git a/bin/rc.shutdown b/bin/rc.shutdown @@ -1,8 +1,5 @@ #!/bin/sh -PATH=/bin -export PATH - umask 022 . /etc/rc.conf @@ -17,7 +14,7 @@ reboot|poweroff) esac # Set linefeed mode to avoid staircase effect -echo; stty onlcr +echo; /bin/stty onlcr echo Shutting down @@ -39,36 +36,36 @@ esac if [ -n "$HWCLOCK_PARAMS" ]; then echo Saving system clock [ -n "$TIMEZONE" ] && export TZ="$TIMEZONE" - hwclock $HWCLOCK_PARAMS + /bin/hwclock $HWCLOCK_PARAMS /dev/rtc0 unset TZ fi echo Storing random seed -dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null +/bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null -svc -k +/bin/svc -k -killall5 -s TERM -sleep 3 -killall5 -s KILL +/bin/killall5 -s TERM +/bin/sleep 3 +/bin/killall5 -s KILL echo Remounting root as read-only -mount -o remount,ro / +/bin/mount -o remount,ro / echo Unmounting filesystems -umount -a +/bin/umount -a -sync -sleep 3 +/bin/sync +/bin/sleep 3 wait echo bye case "$1" in reboot) - halt -r + /bin/halt -r ;; poweroff) - halt -p + /bin/halt -p ;; esac diff --git a/bin/rc.svc b/bin/rc.svc @@ -2,10 +2,5 @@ . /etc/rc.conf -svc -c -svc -s - -if [ -x /bin/rc.local ]; then - echo Running rc.local - /bin/rc.local -fi +/bin/svc -c +/bin/svc -s diff --git a/bin/respawn b/bin/respawn @@ -1,26 +0,0 @@ -#!/bin/sh - -usage() { - echo "usage $(basename $0) [-d delay] cmd arg..." 1>&2 - exit 1 -} - -delay="0" -case "$1" in - -d) - delay="$2" - shift 2 - ;; - -h) - usage - ;; -esac - -if test -z $1; then - usage -fi - -while :; do - $* - sleep $delay -done diff --git a/bin/svc b/bin/svc @@ -33,6 +33,9 @@ # % svc -l # list all services in /bin/svc.d/avail # % svc -r ser # restart service +PATH=/bin +export PATH + BASEDIR="/bin/svc.d" BASENAME="$(basename $0)" diff --git a/bin/svc.d/avail/sdhcp b/bin/svc.d/avail/sdhcp @@ -1,21 +0,0 @@ -#!/bin/sh - -SERVICE="sdhcp" - -[ -e "/bin/svc.d/default/$SERVICE" ] && . "/bin/svc.d/default/$SERVICE" - -BIN="/bin/$SERVICE" - -PID=$(pidof -o %PPID $SERVICE) - -case $1 in - -s) - [ -z "$PID" ] && ifconfig $PARAMS up && $BIN $PARAMS; - ;; - -k) - [ -n "$PID" ] && kill -9 $PID &> /dev/null && ifconfig $PARAMS down - ;; - *) - echo "usage: $0 -s|-k" - exit 1 -esac diff --git a/bin/svc.d/bare.sh b/bin/svc.d/bare.sh @@ -1,37 +0,0 @@ -#!/bin/sh - -[ $# -eq 0 ] && SERVICE="$0" - -if [ $# -gt 0 ]; -then - SERVICE="$1" - shift 1 -fi - -[ -e "/bin/svc.d/default/$SERVICE" ] && . "/bin/svc.d/default/$SERVICE" - -BIN="" -for p in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin; -do - if [ -x "$p/$SERVICE" ]; - then - BIN="$p/$SERVICE" - break - fi -done -[ -z "$BIN" ] && exit 1 - -PID=$(pidof -o %PPID $BIN) - -case $1 in - -s) - [ -z "$PID" ] && $BIN $PARAMS; - ;; - -k) - [ -n "$PID" ] && kill -9 $PID &> /dev/null; - ;; - *) - echo "usage: $0 -s|-k" - exit 1 -esac - diff --git a/bin/svc.d/default/sdhcp b/bin/svc.d/default/sdhcp @@ -1 +0,0 @@ -PARAMS="eth0" diff --git a/etc/group b/etc/group @@ -1,11 +1,11 @@ -root:x:0:root -bin:x:1:root,bin,daemon -daemon:x:2:root,bin,daemon -sys:x:3:root,bin -adm:x:4:root,daemon -tty:x:5: -disk:x:6:root -cdrom:x:7:root -video:x:8:root -audio:x:9:root -nogroup:x:65534: +root:!:0:root +bin:!:1:root,bin,daemon +daemon:!:2:root,bin,daemon +sys:!:3:root,bin +adm:!:4:root,daemon +tty:!:5: +disk:!:6:root +cdrom:!:7:root +video:!:8:root +audio:!:9:root +nogroup:!:65534: diff --git a/etc/issue b/etc/issue @@ -1 +0,0 @@ -Morpheus (\s \m \r) (\l) diff --git a/etc/motd b/etc/motd diff --git a/etc/passwd b/etc/passwd @@ -1,4 +1,4 @@ root::0:0:root:/root:/bin/mksh -bin:x:1:1:bin:/bin:/bin/false -daemon:x:2:2:daemon:/sbin:/bin/false -nobody:x:65534:65534:nobody:/nonexistent:/bin/false +bin:*:1:1:bin:/bin:/bin/false +daemon:*:2:2:daemon:/sbin:/bin/false +nobody:*:65534:65534:nobody:/nonexistent:/bin/false diff --git a/etc/skel/.mkshrc b/etc/skel/.mkshrc @@ -1,4 +0,0 @@ -PS1='# ' - -# C-l should clear the screen -bind -m '^L'='^U'clear'^J''^Y' diff --git a/etc/skel/.profile b/etc/skel/.profile @@ -1,14 +0,0 @@ -PATH=/bin -TERM=linux -HISTFILE=~/.mksh_history -EDITOR=jmacs -PAGER=less -ENV=~/.mkshrc -export PATH TERM HISTFILE EDITOR PAGER ENV - -set -o emacs -set -o bgnice -set -o notify -set -o utf8-mode - -umask 022 diff --git a/etc/skel/.xinitrc b/etc/skel/.xinitrc @@ -1,3 +0,0 @@ -xsetroot -solid black & -uuterm-x11 & -exec dwm diff --git a/root/.mkshrc b/root/.mkshrc @@ -1,4 +0,0 @@ -PS1='# ' - -# C-l should clear the screen -bind -m '^L'='^U'clear'^J''^Y' diff --git a/root/.profile b/root/.profile @@ -1,14 +0,0 @@ -PATH=/bin -TERM=linux -HISTFILE=~/.mksh_history -EDITOR=jmacs -PAGER=less -ENV=~/.mkshrc -export PATH TERM HISTFILE EDITOR PAGER ENV - -set -o emacs -set -o bgnice -set -o notify -set -o utf8-mode - -umask 022 diff --git a/root/.xinitrc b/root/.xinitrc @@ -1,3 +0,0 @@ -xsetroot -solid black & -uuterm-x11 & -exec dwm diff --git a/skel/.mkshrc b/skel/.mkshrc @@ -0,0 +1,8 @@ +if ! test "$(id -u)" -eq 0; then + PS1='$ ' +else + PS1='# ' +fi + +# C-l should clear the screen +bind -m '^L'='^U'clear'^J''^Y' diff --git a/skel/.profile b/skel/.profile @@ -0,0 +1,14 @@ +PATH=/bin +TERM=linux +HISTFILE=~/.mksh_history +EDITOR=jmacs +PAGER=less +ENV=~/.mkshrc +export PATH TERM HISTFILE EDITOR PAGER ENV + +set -o emacs +set -o bgnice +set -o notify +set -o utf8-mode + +umask 022 diff --git a/skel/.xinitrc b/skel/.xinitrc @@ -0,0 +1 @@ +exec dwm diff --git a/svc.d/bare.sh b/svc.d/bare.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +[ $# -eq 0 ] && SERVICE="$0" + +if [ $# -gt 0 ]; +then + SERVICE="$1" + shift 1 +fi + +[ -e "/bin/svc.d/default/$SERVICE" ] && . "/bin/svc.d/default/$SERVICE" + +BIN="" +for p in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin; +do + if [ -x "$p/$SERVICE" ]; + then + BIN="$p/$SERVICE" + break + fi +done +[ -z "$BIN" ] && exit 1 + +PID=$(pidof -o %PPID $BIN) + +case $1 in + -s) + [ -z "$PID" ] && $BIN $PARAMS; + ;; + -k) + [ -n "$PID" ] && kill -9 $PID &> /dev/null; + ;; + *) + echo "usage: $0 -s|-k" + exit 1 +esac +