home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- #
- # /etc/rc.iso - run once at boot time
- #
- # Taken in part from Miquel van Smoorenburg's bcheckrc.
- #
-
-
- echo "************************"
- echo "Started /etc/rc.d/rc.iso"
- echo "************************"
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "Directory of /dev"
- ls -ld /dev
- #ls -l /dev |more
- echo "4050: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- #if [ "x$WATCHBOOT" = "xy" ]; then
- #echo "Enter a Command"
- #echo -n ">"
- #read A
- #while [ "x$A" != "x" ]; do
- #$A
- #echo "Enter a Command"
- #echo -n ">"
- #read A
- #done
- #fi
-
- #These 3 lines are not needed since the RAM disk support
- #is built into the kernel
- #rmmod rd
- #insmod rd rd_size=60000
- #lsmod
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4100: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
-
- ###
- ### This is the start of the section to mount /etc
- ###
-
- #Create the /etc partition (16MB)
- echo "Creating /etc"
- mke2fs -F -i 1024 -q /dev/rd/2 `grep -E -v "^#|^ *$" /etc/sysconfig/rd |grep "/etc" |cut -f2`
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4150: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- echo "Mounting /mnt/etc"
- mount -n /dev/rd/2 /mnt/etc -o defaults,rw
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4200: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- cd /archive/etc
- cp -R * /mnt/etc
- echo "Unmounting /mnt/etc, Mounting /etc"
- umount /mnt/etc
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4250: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- mount -n /dev/rd/2 /etc -o defaults,rw
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4300: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- rm /etc/mtab
- ln -s /proc/mounts /etc/mtab
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "Directory of /etc"
- ls -l /etc
- echo "4350: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- ###
- ### This is the end of the section to mount /etc
- ###
-
-
-
-
- ###
- ### This is the start of the section to mount /var
- ###
-
- #Create the /var partition (32MB)
- echo "Creating /var"
- mke2fs -F -i 1024 -q /dev/rd/1 `grep -E -v "^#|^ *$" /etc/sysconfig/rd |grep "/var" |cut -f2`
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4400: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "Directory listing of /var"
- ls -l /var
- echo "4450: Press Enter to Continue"
- read A
- fi
-
- echo "Mount RAM disk onto /var"
- mount -n -o defaults,rw /dev/rd/1 /var
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4500: Press Enter to Continue"
- read A
- fi
-
- if [ "x$WATCHBOOT" = "xy" ]; then
- #sleep 5
- echo "Directory of /var"
- ls -l /var
- echo "4550: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- cd /var
- mkdir -p lock/subsys spool/anacron spool/cron spool/at spool/mqueue spool/mail
- mkdir -p run/netreport
- mkdir -p log/httpd ntop nessus/logs nessus/CA nessus/jobs nessus/users
- mkdir mysql john
- mkdir empty webmin
- mkdir tmp
- mkdir lib
- ln -s spool/mail
- #Change all the ownerships
- chown -R root:root lock run log mysql spool tmp lib
- chown daemon:daemon spool/at
- chown ntop:nobody ntop
- chown mysql:mysql mysql
- chgrp uucp lock
- chgrp mail spool/mqueue spool/mail
- #Change all the permissions
- chmod 755 run log mysql spool lib
- chmod -R 775 lock
- chmod 777 spool/mail
- chmod 700 spool/cron spool/at
- chmod 775 run/netreport
- chmod 1777 tmp
- touch log/wtmp log/lastlog run/utmp
- chmod 664 log/wtmp run/utmp
- chown root:utmp /var/log/wtmp /var/run/utmp
- chmod 644 log/lastlog
-
-
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "Directory of /var"
- ls -l /var
- echo "4600: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- ###
- ### This is the end of the section to mount /var
- ###
-
-
-
- echo "Creating entries in /etc/mtab"
- mount -f /dev/rd/2 /etc -o defaults,rw
- mount -f /dev/rd/1 /var -o defaults,rw
- #mount -f /dev/rd/3 /dev -o defaults,rw
- mount -f /dev/rd/3 /dev -o defaults,rw
-
-
- ###
- ### This is the start of the section to mount /mnt/floppy
- ### and to copy configuration data from the floppy
- ###
- if [ "x$CONFIGFLOPPY" = "xy" ]; then
- echo "Trying to mount floppy disk"
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4650: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- insmod fat
- insmod vfat
-
- #Try mounting floppy for soft config files
- mount -t auto -o ro /dev/floppy/0 /mnt/floppy
-
- if [ $? -eq 0 ] ; then
- cd /mnt/floppy
-
- AP=`ls profile[0-9].tgz |grep -c profile`
- if [ $AP -ne 0 ] ; then
- echo "The following configuration profiles are available:"
- echo ""
- ls profile[0-9].tgz |cut -d. -f1
- echo ""
- if [ -e /mnt/floppy/profile0.tgz ] ; then
- echo "Select a profile or wait 10 seconds to use profile 0"
- else
- echo "Select a profile or wait 10 seconds to use a blank profile"
- fi
-
- cd /
- while [ "x" = "x" ]; do
- PROFILE=""
- read -t 10 -s -n 1 PROFILE
- if [ "x$PROFILE" != "x" ] ; then
- if [ -e /mnt/floppy/profile$PROFILE.tgz ] ; then
- echo "Using profile $PROFILE"
- tar -zxvf /mnt/floppy/profile$PROFILE.tgz
- chown 0:0 /etc/shadow
- chmod 400 /etc/shadow
- chown 0:0 /etc/samba/smb.conf
- chmod 644 /etc/samba/smb.conf
- chown 0:0 /etc/samba/private/secrets.tdb
- chmod 600 /etc/samba/private/secrets.tdb
- chown -R 0:0 /etc/sysconfig
- chmod 755 /etc/sysconfig/*
- chmod -R 644 /etc/sysconfig/*
- chown -R 0:0 /etc/ppp
- chmod -R 700 /etc/ppp/*
- chown 0:0 /etc/ipsec.conf
- chmod 755 /etc/ipsec.conf
- chown -R 0:0 /etc/ipsec.d
- chmod -R 755 /etc/ipsec.d
- chown -R 0:0 /etc/minicom
- chmod 755 /etc/minicom
- chmod -R 644 /etc/minicom/*
- break
- else
- echo "That profile does not exist"
- fi
- else
- if [ -e /mnt/floppy/profile0.tgz ] ; then
- echo "Continuing with profile 0"
- tar -zxvf /mnt/floppy/profile0.tgz
- chown 0:0 /etc/shadow
- chmod 400 /etc/shadow
- chown 0:0 /etc/samba/smb.conf
- chmod 644 /etc/samba/smb.conf
- chown 0:0 /etc/samba/private/secrets.tdb
- chmod 600 /etc/samba/private/secrets.tdb
- chown -R 0:0 /etc/sysconfig
- chmod 755 /etc/sysconfig/*
- chmod -R 644 /etc/sysconfig/*
- chown -R 0:0 /etc/ppp
- chmod -R 700 /etc/ppp/*
- chown 0:0 /etc/ipsec.conf
- chmod 755 /etc/ipsec.conf
- chown -R 0:0 /etc/ipsec.d
- chmod -R 755 /etc/ipsec.d
- chown -R 0:0 /etc/minicom
- chmod 755 /etc/minicom
- chmod -R 644 /etc/minicom/*
- else
- echo "Continuing with a blank profile"
- fi
- break
- fi
- done
- fi
- fi
- ###
- ### This is the end of the section to mount /mnt/floppy
- ### and to copy configuration data from the floppy
- ###
-
-
- ###
- ### This is the start of the section to unmount /mnt/floppy
- ### if it is currently mounted
- ###
-
- remaining=`cat /proc/mounts | awk '/( \/mnt\/floppy )/ { print $2 }'`
- for i in "$remaining"; do
- umount $i
- done
- fi
-
- ###
- ### This is the end of the section to unmount /mnt/floppy
- ### if it is currently mounted
- ###
-
-
- ###
- ### This is the start of the section to mount /root
- ###
-
- #Create the /root partition for the root user
- echo "Creating /root"
- mke2fs -F -i 1024 -q /dev/rd/3 `grep -E -v "^#|^ *$" /etc/sysconfig/rd |grep "/root" |cut -f2`
- echo "Mounting /mnt/etc"
- mount /dev/rd/3 /root -o defaults,rw
-
- ###
- ### This is the end of the section to mount /root
- ###
-
-
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "4700: Press Enter to Continue"
- read A
- #sleep 5
- fi
-
- #Debug
- if [ "x$WATCHBOOT" = "xy" ]; then
- echo "Current file systems mounted"
- mount
- df -k
- echo "4750: Press Enter to Continue"
- read A
- #sleep 10
- fi
-
-
- echo "*****************************"
- echo "Finished /etc/rc.d/rc.iso"
- echo "*****************************"
-
-
-