Technically the first one isn't a Diversion script
Needs to go into /initrd/unslung (linuxrc.raid script replaced with updated one 9/2/2009 Bullfrog)
# cat /initrd/unslung/linuxrc.raid
#!/bin/sh
# pwd
# set
# ls -l /usr/sbin
echo "/initrd/initrd/unslung/linuxrc.raid"
# echo -e "running linuxrc.raid \r\n"
# find / -name "hello"
mounted=
/bin/mknod /dev/md4 b 9 4 2>/dev/null
/sbin/insmod /unslung/md.o
/sbin/insmod /unslung/raid1.o
if [ -f /unslung/mdadm.conf ] ; then
/unslung/mdadm --assemble --scan --config=/unslung/mdadm.conf
/bin/echo "Sleeping while root mirror resyncs..."
# cat /proc/mdstat
Set_Led rs_blinking &
cnt=125
while [ $cnt -gt 0 ] ; do
echo -ne "\r$cnt "
sleep 1
# cat /proc/mdstat
# the following 5 lines of code aren't working as needed.
# the following command is supposed to return various errorcodes to
# indicate the state of the mirror md1
# 0 The array is functioning normally.
# 1 The array has at least one failed device.
# 2 The array has multiple failed devices and hence is unus-
# able (raid4 or raid5).
# 4 There was an error while trying to get information about
# the device.
# cmd=`/unslung/mdadm --misc --test --detail /dev/md1 >/dev/null`
# returns error 0 if string present or 1 if not present
/unslung/mdadm --detail /dev/md1 2>&1 |grep "appear to be active"; err2=$
?
/unslung/mdadm --detail /dev/md1 2>&1 |grep "Rebuild Status"; err=$?
/unslung/mdadm --detail /dev/md1 2>&1 |grep "faulty removed"; err3=$?
[ "$err3" = "0" ] && err="0"
# ttt=`/unslung/mdadm --detail /dev/md1 2>&1`
# echo "hello $ttt"
if [ "$err2" = "0" ]
then
echo " "
echo "No disks"
cnt=1
else
if [ "$err" = "1" ]
then
echo " "
echo "Raid 1 up - Root mirror is synchronised"
cnt=1
fi
if [ "$err3" = "0" ]
then
echo " "
echo "Raid 1 up - Root mirror isn't synchronised - give up and boot"
cnt=1
fi
fi
cnt=`expr $cnt - 1`
done
echo "loop finished"
else
echo "user is still configuring raid setup"
sleep 3
/unslung/mdadm -A /dev/md4 -R /dev/sda4
/unslung/mdadm -A /dev/md3 -R /dev/sda3
/unslung/mdadm -A /dev/md2 -R /dev/sda2
/unslung/mdadm -A /dev/md1 -R /dev/sda1
fi
# echo "stop flashing led"
killall Set_Led >/dev/null 2>/dev/null
# Set_Led ready &
echo "attempt mount"
if /bin/mount -rt ext3 /dev/md1 /mnt ; then
# if /bin/mount -rt ext3 /dev/md1 /smnt ; then
echo "mounted /md1 as /mnt ==============" >/dev/console
mounted=/mnt
# indicate to calling linuxrc that /mnt is mounted
# df
return 0
fi
# indicate to calling linuxrc that /mnt isn't mounted
#df
return 1
|
The rest are standard Diversion scripts
# cat /unslung/rc.sysinit
#!/bin/sh
# The raid devices are /dev/md1 /dev/md2 /dev/md3 /dev/md4
# They have already been created in 'linuxrc'
# Create and use swap partition
/sbin/mkswap /dev/md3
/bin/sleep 2
/sbin/swapon /dev/md3
# Mount data and conf partitions
/bin/mount -t ext3 /dev/md2 /share/hdd/conf -o rw,noatime
/bin/mount -t ext3 /dev/md1 /share/hdd/data -o rw,noatime
# Mount the 4th partition
/bin/mount -t ext3 /dev/md4 /share/hdd/data/public -o rw,noatime
/bin/mount /share/hdd/data/public /public -o bind
# Continue with the rest of the /etc/rc.d/rc.sysinit script
return 1
|
# cat /unslung/rc.1
#!/bin/sh
#/sbin/ifconfig ixp0 hw ether 00:C0:02:01:01:04
df
df|grep /dev/md1 >/dev/null 2>/dev/null
if [ ! $? ] ; then
/bin/echo "Starting Set CGI_ds.conf:"; /etc/rc.d/rc.bootbin; check_status
fi
df
# Next section only required to allow Maxtor drives to spin down:
# Script section to create ramdisk for /var
# Some find that they have to repeat the process with /dev
/bin/echo "Creating ramfs for /var: (diversion - /unslung/rc.1):"
/bin/mount -t ramfs ramfs /mnt/tmpmnt -o maxsize=256
/bin/cp -rp /var/* /mnt/tmpmnt/
/bin/mkdir -p /var.state
/bin/mount -o bind /var /var.state
/bin/mount -o bind /mnt/tmpmnt /var
/bin/umount /mnt/tmpmnt
# We have commented out the 'bootbin' line above so we must provide replacements
# The rc.sysinit diversion has already mounted the RAID arrays
# This next line brings the ethernet interface up
/sbin/ifup
# These three lines are optional
# cp /opt/etc/passwd /etc/passwd
# cp /opt/etc/passwd /share/hdd/conf/passwd
# [ -L /root ] || ln -sf /opt/user/root /root
/bin/echo "Restore time and timezone:"; /etc/rc.d/rc.rstimezone; check_status
/bin/echo "Restore usrgrpshares:"; /etc/rc.d/rc.reset_usrgrpshare; check_status
#/bin/echo "Generating telnet password:"; /usr/sbin/TelnetPassword; check_status
#/bin/echo "Restore time and timezone:"; /etc/rc.d/rc.rstimezone; check_status
/bin/echo "Starting WEB Server:"; . /etc/rc.d/rc.thttpd;check_status
/bin/echo "Starting samba:"; . /etc/rc.d/rc.samba
#/bin/echo "Starting download:"; /usr/sbin/download
/bin/echo "Starting INET Server:"; . /etc/rc.d/rc.xinetd; check_status
#/bin/echo "Starting QuickSet Daemon :"; . /etc/rc.d/rc.quickset
/bin/echo "Starting Crond :"; . /etc/rc.d/rc.crond
/bin/echo "Starting Rest Task :"; . /etc/rc.d/rc.local
/bin/echo "Starting Optware Packages:"; ( . /etc/rc.d/rc.optware-start )
/usr/bin/Set_Led ready
/usr/bin/Set_Led beep1
/bin/echo "Checking disk status :"; /usr/sbin/CheckDiskFull 2 >/dev/null
df
/bin/echo -e "\n\n$HOSTNAME: Boot Completed !!!\n\n"
# Do not continue with the /etc/rc.d/rc.1 script
return 0
|
# cat /unslung/rc.reboot
#!/bin/sh
cd /
/bin/cp /etc/passwd /opt/etc/passwd
/bin/echo "Stopping Optware Packages (rc.reboot):"; ( . /etc/rc.d/rc.optware-stop )
/bin/killall -2 upnpd 2>/dev/null
/bin/sleep 4
# Switch off ethernet interface
/sbin/ifdown ixp0
# Stop Samba
/bin/killall nmbd 2>/dev/null
/bin/killall smbd 2>/dev/null
/bin/killall ample 2>/dev/null
/bin/killall mms 2>/dev/null
/bin/killall mt-daapd 2>/dev/null
# Stop webserver
/bin/killall -SIGUSR2 thttpd 2>/dev/null
/bin/sleep 2
# Unmount all drives
/bin/umount /share/flash/conf 2>/dev/null
/bin/umount /share/flash/data 2>/dev/null
/bin/umount /share/hdd/conf 2>/dev/null
/bin/umount /share/hdd/data/public 2>/dev/null
/bin/umount /public 2>/dev/null
/bin/umount /share/hdd/data 2>/dev/null
/sbin/swapoff /dev/sda3 2>/dev/null
/sbin/swapoff /dev/sdb3 2>/dev/null
/sbin/swapoff /dev/md3 2>/dev/null
# Stop RAID arrays
# we will not be able to stop the boot drive
/opt/sbin/mdadm -Ss --config=/opt/etc/mdadm.conf
/bin/sleep 2
# doing reverse of '/etc/rc' script
/bin/mount -o remount,ro /dev/root /
/bin/umount /proc/bus/usb
/bin/umount /proc
/bin/umount_flash 2>/dev/null
echo "Waiting 10 seconds for disk write cache to flush"
/bin/sleep 10
# REboot!
/sbin/reboot
|
# cat /unslung/rc.halt
#!/bin/sh
chdir /
/bin/cp /etc/passwd /opt/etc/passwd
/bin/echo "Stopping Optware Packages (/unslung/rc.halt):"; ( . /etc/rc.d/rc.optware-stop )
/bin/echo "continuing"
/bin/killall sshd 2>/dev/null
/opt/etc/init.d/S80thttpd stop
/bin/killall -2 upnpd 2>/dev/null
# Stop cron job daemon
/bin/killall crond 2>/dev/null
# Switch off ethernet interface
/sbin/ifdown ixp0
# Stop Samba
/bin/killall nmbd 2>/dev/null
/bin/killall smbd 2>/dev/null
/bin/killall ample 2>/dev/null
/bin/killall mms 2>/dev/null
/bin/killall mt-daapd 2>/dev/null
# turn off quotas
/usr/bin/quotaoff -a
# Stop webserver
/bin/killall -SIGUSR2 thttpd 2>/dev/null
/bin/sleep 2
# Unmount all drives
/bin/umount /var.state 2>/dev/null
/bin/umount /var 2>/dev/null
/bin/umount /share/flash/conf 2>/dev/null
/bin/umount /share/hdd/data/public 2>/dev/null
/bin/umount /public 2>/dev/null
/bin/umount /share/flash/data 2>/dev/null
/bin/umount /share/hdd/conf 2>/dev/null
/bin/umount /share/hdd/data 2>/dev/null
/sbin/swapoff /dev/sda3 2>/dev/null
/sbin/swapoff /dev/sdb3 2>/dev/null
/sbin/swapoff /dev/md3 2>/dev/null
# Stop RAID arrays
# We will not be able to stop the root drive
# But thats OK because we resync it at startup
/opt/sbin/mdadm -Ss --config=/opt/etc/mdadm.conf
/bin/sleep 3
# doing reverse of '/etc/rc' script
/bin/mount -o remount,ro /dev/root /
/bin/umount /proc/bus/usb
/bin/umount /proc
echo "waiting 15 seconds"
/bin/sleep 15
/sbin/halt-test &>/dev/null
/bin/sleep 2
/sbin/halt-test &>/dev/null
echo "waiting 15 seconds for disk write cache to flush"
/bin/sleep 15
return 0
|
# cat /unslung/rc.local
#!/bin/sh
HOSTNAME=`hostname`
/usr/sbin/CheckResetButton 2>/dev/null
/usr/sbin/CheckPowerButton 2>/dev/null
/usr/sbin/do_umount 2>/dev/null
/bin/chmod 775 /share 2>/dev/null
/bin/chown admin.everyone /share/hdd/ 2>/dev/null
/bin/chown admin.everyone /share 2>/dev/null
/etc/rc.d/rc.quota 2>/dev/null
/usr/sbin/init_media 2>/dev/null
# /bin/echo "$HOSTNAME: boot complete!"; check_status
#
#
#
# don't continue with the /etc/rc.d/rc.local script.
return 0
|