home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #(c) copyright Barry Kauler 2006, www.puppylinux.com
-
-
- PATH=/bin:/sbin:/usr/bin:/usr/sbin
-
- check_status()
- {
- /bin/echo -en "\\033[65G"
- if [ $1 -eq 0 ]
- then
- /bin/echo -en "\\033[1;32mdone"
- /bin/echo -e "\\033[0;39m"
- else
- /bin/echo -en "\\033[1;31mfailed"
- /bin/echo -e "\\033[0;39m"
- echo "Pausing for 20 seconds..."
- sleep 20
- fi
- }
-
- COMPRFS="squashfs"
-
- DEBUGFUNC()
- {
- xxcc="$1"
- while [ "$xxcc" ];do
- echo -n "DEBUG: ENTER or type a command: "
- read xxcc
- eval $xxcc
- done
- }
-
- check_status()
- {
- /bin/echo -en "\\033[65G"
- if [ $1 -eq 0 ]
- then
- /bin/echo -en "\\033[1;32mdone"
- /bin/echo -e "\\033[0;39m"
- else
- /bin/echo -en "\\033[1;31mfailed"
- /bin/echo -e "\\033[0;39m"
- echo "Pausing for 60 seconds..."
- sleep 60
- fi
- }
-
- echo "Now executing /etc/rc.d/rc.sysinit..."
-
- echo -n "Mounting /proc: ";mount /proc;check_status $?
- if [ "`df | grep "initrd"`" = "" ];then
- echo -n "Remounting root rw: ";mount -o remount,rw /;check_status $?
- fi
- echo -n "Mounting devpts: ";mount /dev/pts;check_status $?
- mkdir /sys 2>/dev/null
- echo -n "Mounting /sys: ";mount /sys;check_status $?
- mount > /etc/mtab
-
- #load modules
- . /etc/rc.d/rc.modules
-
- #this does not work for the 2.6.16.7 kernel...
- #cat /proc/pci | grep -i "usb" > /dev/null #old PCs may not have usb.
- if [ ! "`lsmod | grep "^usbcore"`" = "" ];then
- #need to mount this, but not here if it is in /etc/fstab...
- echo -n "Mounting usbfs:"
- mount -t usbfs none /proc/bus/usb;check_status $?
- #...RH doesn't have this one in fstab, so I won't.
- #Here is what could be put into fstab:
- # none /proc/bus/usb usbfs defaults 0 0
- fi
-
- #v1.0.7 busybox 1.01 syslogd does not have -L option...
- #echo -n "Starting syslogd: ";syslogd -m 0 -L;check_status $?
- echo -n "Starting syslogd: ";syslogd -m 0;check_status $?
- echo -n "Starting klogd: ";klogd;check_status $?
-
-
- #PUPMODE only created if init script in initrd was executed...
- [ ! -f /etc/rc.d/PUPMODE ] && echo -n "2" > /etc/rc.d/PUPMODE
- PUPMODE="`cat /etc/rc.d/PUPMODE`"
-
- ##only need to clean system for full no-ramdisk hd installation...
- #if [ "$PUPMODE" = "2" ];then
- # echo "Cleaning up system... "
- # rm -rf /tmp/*
- # #rm -rf /var/*
- # #sync
- # #mkdir /var/local
- # #mkdir /var/lock
- # #mkdir /var/locks
- # #mkdir /var/log
- # #mkdir /var/run
- # #mkdir /var/spool
- # #mkdir /var/local/lib
- # #mkdir /var/local/lib/games
- # #rm -f /var/log/messages ...need to wipe this at shutdown.
- # #rm -f /var/log/sh-httpd.log
- # #rm -f /var/log/wtmp
- # #> /var/run/utmp
- # #NO, maybe just need to wipe these...
- # rm -f /var/lock/LCK*
- # rm -f /var/run/*.pid
- # rm -rf /root/tmp 2> /dev/null #v1.0.7
- #fi
-
- echo -e "Puppy Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
-
-
- #echo "An experiment, to get dialup dyn ip assignment"
- #echo "working with a firewall..."
- echo "1" > /proc/sys/net/ipv4/ip_dynaddr
-
- #mount > /etc/mtab #as busybox doesn't have proper mtab (mkfs needs it).
-
-
- #force update when new version of Puppy...
- /etc/rc.d/rc.update $PUPMODE
-
- sync
-
- if [ "$PUPMODE" = "2" ];then #full h.d. installation, no initrd.
- #load a swap partition...
- SWAPPART="`fdisk -l | grep "Linux swap" | head -n 1 | cut -f 1 -d " "`"
- [ ! "$SWAPPART" = "" ] && swapon $SWAPPART
-
- #attach squashfs modules for full hd installation (no initrd or init script)...
- #TODO currently only mounts the older format .sfs files onto /usr...
- USRDEVX=""
- rm -rf /.usr_devx 2> /dev/null
- if [ ! "`ls /usr_devx.sfs 2> /dev/null`" = "" ];then
- mkdir /.usr_devx 2> /dev/null
- echo "Mounting /usr_devx.sfs file on /.usr_devx..."
- losetup-FULL /dev/loop3 /usr_devx.sfs
- mount -r -t squashfs -o noatime /dev/loop3 /.usr_devx;check_status $?
- [ $? -eq 0 ] && USRDEVX=':/.usr_devx=ro'
- fi
- USRMORE=""
- rm -rf /.usr_more 2> /dev/null
- if [ ! "`ls /usr_more.sfs 2> /dev/null`" = "" ];then
- mkdir /.usr_more
- echo "Mounting /usr_more.sfs file on /.usr_more..."
- losetup-FULL /dev/loop4 /usr_more.sfs
- mount -r -t squashfs -o noatime /dev/loop4 /.usr_more
- [ $? -eq 0 ] && USRMORE=':/.usr_more=ro'
- fi
- if [ ! "$USRDEVX$USRMORE" = "" ];then
- mount -t unionfs -o dirs=/usr=rw$USRDEVX$USRMORE none /usr;check_status $?
- fi
- fi
-
- #v2.01 case of 128M PCs with pup_save.3fs, need more ram space...
- #NOTE future, do not assume /initrd/mnt/dev_save/ is mntpt for pup_save.3fs,
- # get device out of PUPSAVE and use 'mount' to find mntpt.
- #do this for PUPMODE=12 only, pup_save.3fs direct on pup_rw layer (fast storage)...
- if [ "$PUPMODE" = "12" ];then
- if [ -f /initrd/mnt/dev_save/pupswap.swp ];then
- echo "Activating swap file /initrd/mnt/dev_save/pupswap.swp..."
- swapon /initrd/mnt/dev_save/pupswap.swp
- else
- #only create a swap file if no swap partition...
- if [ "`free | grep 'Swap:' | tr -s " " | cut -f 3 -d " "`" = "0" ];then
- if [ ! "`cat /etc/rc.d/PUPSAVE | cut -f 1 -d ',' | grep --extended-regexp 'msdos|vfat|ext2|ext3|reiserfs|minix'`" = "" ];then
- DRVFREE=`df -m | grep '/initrd/mnt/dev_save' | tr -s " " | cut -f 4 -d " "`
- if [ $DRVFREE ];then
- DRVFREE=`expr $DRVFREE \/ 2`
- SWPSIZE=100 #100M
- [ $SWPSIZE -gt $DRVFREE ] && SWPSIZE=$DRVFREE #never use more than half free space.
- if [ $SWPSIZE -gt 20 ];then
- echo "Creating Linux swap file in /initrd/mnt/dev_save/..."
- dd if=/dev/zero of=/initrd/mnt/dev_save/pupswap.swp bs=1048576 count=$SWPSIZE
- if [ $? -eq 0 ];then
- sync
- mkswap /initrd/mnt/dev_save/pupswap.swp
- if [ $? -eq 0 ];then
- sync
- swapon /initrd/mnt/dev_save/pupswap.swp
- fi
- fi
- fi
- fi
- fi
- fi
- fi
- fi
-
- exec /etc/rc.d/rc.local0
- # ...must be last entry in this file
-