#!/bin/sh # # System initialesieren { . /etc/init.d/rc.functions mount proc mount sys mount devpts mount tmpfs mount devtmpfs make_dev klogd -c 1 show_splash # search and wait for system device i=0 grep -q "root=" /proc/cmdline && dev="$(sed 's|.*root=\(\S*\).*|\1|' /proc/cmdline)" dev=${dev-LABEL=MLD-${SYSTEM_VERSION%%-*}} while [ $i -lt 10 ]; do dev=$( (blkid | sed 's/"//g' | grep "$dev" || echo "$dev") | head -n1 | sed "s/:.*//") test -e "$dev" && break echo -en "\rWaiting for system device: $(show_step) \r" sleep 1 i=$(($i+1)) done # searching for system device if [ ! -e "$dev" ]; then blkid | cut -d : -f 1 > /tmp/system_devs while read device; do echo -en "\rSearching for system device: $(show_step) \r" mount $device /mnt if [ -e /mnt/boot/MLD-${SYSTEM_VERSION%%-*}_initramfs-* ]; then dev=$device if ! grep -q "root=" /proc/cmdline; then # update the root parameter in the bootmanager sed "s|append |append root=$(blkid | grep "^$device" | sed 's|.*\(\(UUID\|LABEL\)="[^"]*\)".*|\1|;s|"||') |g" -i /mnt/boot/isolinux/isolinux.cfg 2>/dev/null if [ -e /mnt/syslinux.cfg ]; then # replace unetbootin bootmenu echo "include boot/isolinux/isolinux.cfg" > /mnt/syslinux.cfg sed 's|vesamenu.c32|boot/isolinux/vesamenu.c32|;s|back.jpg|boot/isolinux/back.jpg|' /mnt/boot/isolinux/style.cfg > /mnt/style.cfg fi fi fi umount $device test -e "$dev" && break done < /tmp/system_devs rm /tmp/system_devs fi if [ ! -e "$dev" ]; then echo -e "System device '$dev' not found"; check_status 1 sh fi dev=${dev##*/} dir="${BOOT_IMAGE%/boot/*}" dir="${dir#/}" echo "Import system device: /dev/$dev" echo " Turn on DMA: " hdparm -d1 /dev/$(echo $dev | cut -b 1-3) &>/dev/null check_status echo " Checking: " fsck -a -C1 /dev/$dev | while read a b c d; do test -n "${d##/dev/*}" -o -z "$d" || { n=$(($b*20/$c+($a-1)*20)); test "$n" != "$l" && show_step $n; l=$n; }; done check_status echo " Mounting: " mkdir -p /mnt/$dev || failed mount /dev/$dev /mnt/$dev || failed ln -s /mnt/$dev/$dir /mnt/system || failed check_status if mount | grep /dev/$dev | grep -q "(ro,"; then echo "Mounting read-only system directory: " mount / -o remount,add:1:/mnt/system=rr || failed # make /etc/addons writeable mkdir -p /mnt/addons || failed mount addons /mnt/addons -t tmpfs -o loop || failed mount addons /etc/addons -t aufs -o dirs=/mnt/addons:/mnt/system/etc/addons || failed check_status elif mount | grep /dev/$dev | grep -q "vfat"; then echo "Mounting vfat system directory: " mount / -o remount,add:1:/mnt/system=ro || failed if [ -x /mnt/system/boot/rootimg.gz ]; then gunzip /mnt/system/boot/rootimg.gz fi if [ -x /mnt/system/boot/rootimg ]; then # use a writeable image mkdir -p /mnt/rootimg || failed mount /mnt/system/boot/rootimg /mnt/rootimg -o loop || failed mkdir -p /mnt/rootimg/var/spool || failed mount / -o remount,add:0:/mnt/rootimg=rw || failed fi # needed to make addons mountable as aufs on / mount /mnt/system/etc/addons /etc/addons -o loop || failed check_status else echo "Mounting read-write system directory: " mkdir -p /mnt/system/var/spool mount / -o remount,add:0:/mnt/system=rw || failed # needed to make addons mountable as aufs on / mount /mnt/system/etc/addons /etc/addons -o loop || failed check_status fi # Starting loging damons and Destination for extended log messages . /etc/rc.config echo "Setting up logging: level $LOG_LEVEL" reset >/dev/tty5 || failed echo >/dev/tty10 || failed setlogcons 10 || failed syslogd -m 0 || failed if [ "0$LOG_LEVEL" -lt "3" ]; then #klogd -c 1 || failed ln -fs /dev/null /dev/stdlog || failed else killall klogd klogd -c $(($LOG_LEVEL-2)) || failed ln -fs /dev/stdout /dev/stdlog || failed fi if [ "0$LOG_LEVEL" -gt "1" ]; then # move /var/log to hdd (log to tmpfs will activated in rc.poweroff) cp -r /mnt/tmpfs/var/log /var || failed mv /var/log /var/log.mv || failed mv /var/log.mv /var/log || failed fi if [ "0$LOG_LEVEL" -lt "1" ]; then # redirect logfiles to /dev/null for f in /var/run/utmp $(find /var/log -type f); do ln -fs /dev/null $f || failed done fi check_status } 2>&1 | tee -a /var/log/sysinit { . /etc/init.d/rc.functions . /etc/profile export BOOTSTEPS=$STARTSTEPS echo "Setting up netware: " update_config "127.0.0.1.localhost" "127.0.0.1\tlocalhost $HOST_NAME" /etc/hosts || failed echo "$HOST_NAME" > /etc/hostname || failed hostname -F /etc/hostname || failed ifconfig lo up 127.0.0.1 || failed route add -net 127.0.0.0/8 lo || failed check_status echo "$SYSTEM_NAME $SYSTEM_VERSION" >> /etc/issue echo "`uname -s` `uname -r` [`uname -m` arch]\n" >> /etc/issue # import addons > /var/spool/apm.new > /var/spool/apm.pid add_pos=$(mount | grep -q " /mnt/rootimg " && echo 3 || echo 2) for addon in $(cat /etc/addons/active 2>/dev/null || (cd /etc/addons/; ls *.sfs 2>/dev/null)); do test -z "${addon###*}" && continue name=${addon%-*_*} name=${name##*_} basename=${name%.*} test -e /var/spool/apm.mnt/$basename || echo $basename >> /var/spool/apm.new echo "$( ( echo "Importing addon: $basename" mkdir -p /var/spool/apm.mnt/$basename || failed if ! mount /etc/addons/$addon /var/spool/apm.mnt/$basename -t squashfs -o loop; then if [ ! -e /etc/addons/$addon ]; then echo " Unknown Addon: $addon" && failed else sleep 1 mount /etc/addons/$addon /var/spool/apm.mnt/$basename -t squashfs -o loop || failed fi fi mount / -o remount,add:$add_pos:/var/spool/apm.mnt/$basename=rr || failed check_status ) 2>&1 )" & echo $! >> /var/spool/apm.pid done while read pid; do wait $pid; done < /var/spool/apm.pid rm -f /var/spool/apm.pid test -e /lib/modules/$(uname -r) && depmod ldconfig.sh echo "Start load of Kernel modules:" udevd_restart check_status echo "Import all further filesystems: " # Enabling DMA modus if [ "$ide" != "nodma" ]; then echo " Turn on DMA: " for dev in $(ls -d /proc/ide/hd? 2>/dev/null; ls -d /proc/ide/sd? 2>/dev/null); do device="/dev/${dev##*/}" hdparm -d1 $dev >>/dev/null 2>&1 || (echo " $dev"; check_status 1 "no DMA") done fi echo " Checking: " fsck -a -C1 -A | while read a b c d; do test -n "${d##/dev/*}" -o -z "$d" || { n=$(($b*20/$c+($a-1)*20)); test "$n" != "$l" && show_step $n; l=$n; }; done check_status # Mount devpts, devusb and hard disks echo " Mounting: " mkdir -p /dev/pts mkdir -p /mnt/data mount -a -t auto,tmpfs,ext2,ext3,ext4,xfs,vfat || failed mount -t devpts devpts /dev/pts || failed mkdir -p /mnt/data/cache /mnt/data/tv rm -rf /var/cache ln -s /mnt/data/cache /var/cache check_status # run install scripts for new addons export DIALOG_OUT=/dev/console for addon in $(cat /var/spool/apm.new); do if [ -e /var/spool/apm/$addon ]; then echo "Installing addon: $addon"; /var/spool/apm/$addon install; check_status fi done rm /var/spool/apm.new # Startscripte ausführen /etc/init.d/rc.init start # Save number of bootsteps and set progesivebar to 100% update_setting STARTSTEPS $(cat /var/spool/bootstep) echo $BOOTSTEPS >/var/spool/bootstep show_bootstep . /etc/rc.config if [ "$SHOW_PROMPT" = "1" ]; then # disable silentmode echo "verbose" 2>/dev/null > /proc/splash fi # das logging tee muss abgeschossen werden (sofern er nicht von selbst beendet wird) da ansonsten die gestarteten demons ein beenden dieses Skripts verhindern wuerden { sleep 5; killall tee; } >/dev/null 2>&1 &1 | tee -a /var/log/sysinit