home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / etc / rc.d / rc.sysinit < prev    next >
Encoding:
Text File  |  2006-06-16  |  5.5 KB  |  190 lines

  1. #!/bin/sh
  2. #(c) copyright Barry Kauler 2006, www.puppylinux.com
  3.  
  4.  
  5. PATH=/bin:/sbin:/usr/bin:/usr/sbin
  6.  
  7. check_status()
  8. {
  9.   /bin/echo -en "\\033[65G"
  10.   if [ $1 -eq 0 ]
  11.   then
  12.     /bin/echo -en "\\033[1;32mdone"
  13.     /bin/echo -e "\\033[0;39m"
  14.   else
  15.     /bin/echo -en "\\033[1;31mfailed"
  16.     /bin/echo -e "\\033[0;39m"
  17.     echo "Pausing for 20 seconds..."
  18.     sleep 20
  19.   fi
  20. }
  21.  
  22. COMPRFS="squashfs"
  23.  
  24. DEBUGFUNC()
  25. xxcc="$1"
  26. while [ "$xxcc" ];do
  27. echo -n "DEBUG: ENTER or type a command: "
  28.  read xxcc
  29.  eval $xxcc
  30. done
  31. }
  32.  
  33. check_status()
  34. {
  35.   /bin/echo -en "\\033[65G"
  36.   if [ $1 -eq 0 ]
  37.   then
  38.     /bin/echo -en "\\033[1;32mdone"
  39.     /bin/echo -e "\\033[0;39m"
  40.   else
  41.     /bin/echo -en "\\033[1;31mfailed"
  42.     /bin/echo -e "\\033[0;39m"
  43.     echo "Pausing for 60 seconds..."
  44.     sleep 60
  45.   fi
  46. }
  47.  
  48. echo "Now executing /etc/rc.d/rc.sysinit..."
  49.  
  50. echo -n "Mounting /proc: ";mount /proc;check_status $?
  51. if [ "`df | grep "initrd"`" = "" ];then
  52.  echo -n "Remounting root rw: ";mount -o remount,rw /;check_status $?
  53. fi
  54. echo -n "Mounting devpts: ";mount /dev/pts;check_status $?
  55. mkdir /sys 2>/dev/null
  56. echo -n "Mounting /sys: ";mount /sys;check_status $?
  57. mount > /etc/mtab
  58.  
  59. #load modules
  60. . /etc/rc.d/rc.modules
  61.  
  62. #this does not work for the 2.6.16.7 kernel...
  63. #cat /proc/pci | grep -i "usb" > /dev/null #old PCs may not have usb.
  64. if [ ! "`lsmod | grep "^usbcore"`" = "" ];then
  65.  #need to mount this, but not here if it is in /etc/fstab...
  66.  echo -n "Mounting usbfs:"
  67.  mount -t usbfs none /proc/bus/usb;check_status $?
  68.  #...RH doesn't have this one in fstab, so I won't. 
  69.  #Here is what could be put into fstab:
  70.  # none  /proc/bus/usb  usbfs  defaults  0  0
  71. fi
  72.  
  73. #v1.0.7  busybox 1.01 syslogd does not have -L option...
  74. #echo -n "Starting syslogd: ";syslogd -m 0 -L;check_status $?
  75. echo -n "Starting syslogd: ";syslogd -m 0;check_status $?
  76. echo -n "Starting klogd: ";klogd;check_status $?
  77.  
  78.  
  79. #PUPMODE only created if init script in initrd was executed...
  80. [ ! -f /etc/rc.d/PUPMODE ] && echo -n "2" > /etc/rc.d/PUPMODE
  81. PUPMODE="`cat /etc/rc.d/PUPMODE`"
  82.  
  83. ##only need to clean system for full no-ramdisk hd installation...
  84. #if [ "$PUPMODE" = "2" ];then
  85. # echo "Cleaning up system... "
  86. # rm -rf /tmp/*
  87. # #rm -rf /var/*
  88. # #sync
  89. # #mkdir /var/local
  90. # #mkdir /var/lock
  91. # #mkdir /var/locks
  92. # #mkdir /var/log
  93. # #mkdir /var/run
  94. # #mkdir /var/spool
  95. # #mkdir /var/local/lib
  96. # #mkdir /var/local/lib/games
  97. # #rm -f /var/log/messages ...need to wipe this at shutdown.
  98. # #rm -f /var/log/sh-httpd.log
  99. # #rm -f /var/log/wtmp
  100. # #> /var/run/utmp
  101. # #NO, maybe just need to wipe these...
  102. # rm -f /var/lock/LCK*
  103. # rm -f /var/run/*.pid
  104. # rm -rf /root/tmp 2> /dev/null #v1.0.7
  105. #fi
  106.  
  107. echo -e "Puppy Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
  108.  
  109.  
  110. #echo "An experiment, to get dialup dyn ip assignment"
  111. #echo "working with a firewall..."
  112. echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  113.  
  114. #mount > /etc/mtab #as busybox doesn't have proper mtab (mkfs needs it).
  115.  
  116.  
  117. #force update when new version of Puppy...
  118. /etc/rc.d/rc.update $PUPMODE
  119.  
  120. sync
  121.  
  122. if [ "$PUPMODE" = "2" ];then #full h.d. installation, no initrd.
  123.  #load a swap partition...
  124.  SWAPPART="`fdisk -l | grep "Linux swap" | head -n 1 | cut -f 1 -d " "`"
  125.  [ ! "$SWAPPART" = "" ] && swapon $SWAPPART
  126.  
  127.  #attach squashfs modules for full hd installation (no initrd or init script)...
  128.  #TODO currently only mounts the older format .sfs files onto /usr...
  129.  USRDEVX=""
  130.  rm -rf /.usr_devx 2> /dev/null
  131.  if [ ! "`ls /usr_devx.sfs 2> /dev/null`" = "" ];then
  132.   mkdir /.usr_devx 2> /dev/null
  133.   echo "Mounting /usr_devx.sfs file on /.usr_devx..."
  134.   losetup-FULL /dev/loop3 /usr_devx.sfs
  135.   mount -r -t squashfs -o noatime /dev/loop3 /.usr_devx;check_status $?
  136.   [ $? -eq 0 ] && USRDEVX=':/.usr_devx=ro'
  137.  fi
  138.  USRMORE=""
  139.  rm -rf /.usr_more 2> /dev/null
  140.  if [ ! "`ls /usr_more.sfs 2> /dev/null`" = "" ];then
  141.   mkdir /.usr_more
  142.   echo "Mounting /usr_more.sfs file on /.usr_more..."
  143.   losetup-FULL /dev/loop4 /usr_more.sfs
  144.   mount -r -t squashfs -o noatime /dev/loop4 /.usr_more
  145.   [ $? -eq 0 ] && USRMORE=':/.usr_more=ro'
  146.  fi
  147.  if [ ! "$USRDEVX$USRMORE" = "" ];then
  148.   mount -t unionfs -o dirs=/usr=rw$USRDEVX$USRMORE none /usr;check_status $?
  149.  fi
  150. fi
  151.  
  152. #v2.01 case of 128M PCs with pup_save.3fs, need more ram space...
  153. #NOTE future, do not assume /initrd/mnt/dev_save/ is mntpt for pup_save.3fs,
  154. #     get device out of PUPSAVE and use 'mount' to find mntpt.
  155. #do this for PUPMODE=12 only, pup_save.3fs direct on pup_rw layer (fast storage)...
  156. if [ "$PUPMODE" = "12" ];then
  157.  if [ -f /initrd/mnt/dev_save/pupswap.swp ];then
  158.   echo "Activating swap file /initrd/mnt/dev_save/pupswap.swp..."
  159.   swapon /initrd/mnt/dev_save/pupswap.swp
  160.  else
  161.   #only create a swap file if no swap partition...
  162.   if [ "`free | grep 'Swap:' | tr -s " " | cut -f 3 -d " "`" = "0" ];then
  163.    if [ ! "`cat /etc/rc.d/PUPSAVE | cut -f 1 -d ',' | grep --extended-regexp 'msdos|vfat|ext2|ext3|reiserfs|minix'`" = "" ];then
  164.     DRVFREE=`df -m | grep '/initrd/mnt/dev_save' | tr -s " " | cut -f 4 -d " "`
  165.     if [ $DRVFREE ];then
  166.      DRVFREE=`expr $DRVFREE \/ 2`
  167.      SWPSIZE=100 #100M
  168.      [ $SWPSIZE -gt $DRVFREE ] && SWPSIZE=$DRVFREE #never use more than half free space.
  169.      if [ $SWPSIZE -gt 20 ];then
  170.       echo "Creating Linux swap file in /initrd/mnt/dev_save/..."
  171.       dd if=/dev/zero of=/initrd/mnt/dev_save/pupswap.swp bs=1048576 count=$SWPSIZE
  172.       if [ $? -eq 0 ];then
  173.        sync
  174.        mkswap /initrd/mnt/dev_save/pupswap.swp
  175.        if [ $? -eq 0 ];then
  176.         sync
  177.         swapon /initrd/mnt/dev_save/pupswap.swp
  178.        fi
  179.       fi
  180.      fi
  181.     fi
  182.    fi
  183.   fi
  184.  fi
  185. fi
  186.  
  187. exec /etc/rc.d/rc.local0
  188. # ...must be last entry in this file
  189.