Files
Arch-R/packages/sysutils/busybox/scripts/init.system

72 lines
1.6 KiB
Plaintext
Raw Normal View History

2009-03-18 13:02:53 +01:00
#!/bin/sh
/bin/busybox test ! -e /proc/cpuinfo && \
/bin/busybox mount -t proc none /proc
/bin/busybox test ! -e /sys/kernel && \
/bin/busybox mount -t sysfs none /sys
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount -t ramfs none /dev
2009-03-31 00:33:05 +02:00
# mount -t ramfs none /etc
2009-03-18 13:02:53 +01:00
mount -t ramfs none /var
mknod /dev/null c 1 3
mknod /dev/fb0 c 29 0
2009-03-18 21:16:49 +01:00
# parse command line arguments
2009-03-18 13:02:53 +01:00
BOOT=`cat /proc/cmdline | sed 's/.*boot=// ; s/ .*//'`
DISK=`cat /proc/cmdline | sed 's/.*disk=// ; s/ .*//'`
#VERSION=`cat /proc/version | cut -f3 -d" "`
2009-03-18 21:16:49 +01:00
for arg in $(cat /proc/cmdline); do
case $arg in
textmode)
TEXTMODE=yes
;;
2009-03-18 21:16:49 +01:00
configure)
CONFIGURE=yes
;;
esac
done
2009-03-18 13:02:53 +01:00
# make variable directory structure
mkdir -p /var/run
mkdir -p /var/log
mkdir -p /var/lock
mkdir -p /var/tmp
mkdir -p /var/mnt
# setting hostname
echo openelec > /proc/sys/kernel/hostname
# copying config into ram
[ -f "/usr/config/etc.tar.lzma" ] && \
2009-03-31 00:33:05 +02:00
tar xaf "/usr/config/etc.tar.lzma" -C /var
2009-03-18 13:02:53 +01:00
2009-03-18 21:16:49 +01:00
RUNLEVEL="openelec"
if test "$TEXTMODE" = yes; then
RUNLEVEL="text"
2009-03-18 21:16:49 +01:00
elif test "$CONFIGURE" = yes; then
RUNLEVEL="configure"
fi
2009-03-18 13:02:53 +01:00
count=0
for script in /etc/init.d/*; do
2009-03-18 21:16:49 +01:00
grep -q -e "^# runlevels:.*$RUNLEVEL" $script && count=$(($count+1));
2009-03-18 13:02:53 +01:00
done
RET=0
for script in /etc/init.d/*; do
2009-03-18 21:16:49 +01:00
if grep -q -e "^# runlevels:.*$RUNLEVEL" $script; then
2009-03-18 13:02:53 +01:00
/bin/sh $script
S_RET=$?
test $S_RET -ge $RET && RET=$S_RET
fi
done
exit $RET
echo "starting emergency shell"
2009-03-23 22:29:55 +01:00
exec /bin/busybox sh </dev/tty3 >/dev/tty3 2>&1