| 1 | beyerle@PS | 1 | #!/bin/bash
 | 
        
           |  |  | 2 | #
 | 
        
           |  |  | 3 | # Fix things during bootup - run first 
 | 
        
           | 84 | beyerle@PS | 4 | # For example: Enable services, etc ...
 | 
        
           | 1 | beyerle@PS | 5 | # Executed at the very end of /etc/rc.d/rc.sysinit
 | 
        
           |  |  | 6 | #
 | 
        
           |  |  | 7 | # Urs Beyerle, PSI
 | 
        
           |  |  | 8 | #
 | 
        
           |  |  | 9 |   | 
        
           |  |  | 10 | ### -----------------------------------------------------------
 | 
        
           | 84 | beyerle@PS | 11 | ### Definitions
 | 
        
           | 1 | beyerle@PS | 12 | ### -----------------------------------------------------------
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 | # dir of mounted /$MOUNTDIR/live
 | 
        
           |  |  | 15 | MOUNTDIR=livecd
 | 
        
           |  |  | 16 |   | 
        
           |  |  | 17 | # source functions
 | 
        
           |  |  | 18 | . /$MOUNTDIR/live/liblinuxlive
 | 
        
           |  |  | 19 | . /etc/init.d/functions
 | 
        
           |  |  | 20 |   | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 | ### -----------------------------------------------------------
 | 
        
           |  |  | 23 | ### Get boot parameters
 | 
        
           |  |  | 24 | ### -----------------------------------------------------------
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 | # start afs?
 | 
        
           |  |  | 27 | AFS=$( cmdline_parameter afs )
 | 
        
           |  |  | 28 | CELL=$( cmdline_value cell )
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | # or force no afs
 | 
        
           |  |  | 31 | [ $( cmdline_parameter noafs ) ] && AFS=""
 | 
        
           |  |  | 32 |   | 
        
           |  |  | 33 | # start ssh server?
 | 
        
           |  |  | 34 | SSH=$( cmdline_parameter ssh )
 | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 | # root on NFS?
 | 
        
           |  |  | 37 | NFSROOT=$( cmdline_value nfsroot )
 | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 | # PSI setup?
 | 
        
           |  |  | 40 | PSI=$( cmdline_parameter psi )
 | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 | # do not start network
 | 
        
           |  |  | 43 | NONET=$( cmdline_parameter nonet )
 | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 | # Are PXE/TFTP and NFS Server the same host ? not uesed any more
 | 
        
           |  |  | 46 | ONEMASTER=$( cmdline_parameter onemaster )
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 | # fast booting ?
 | 
        
           |  |  | 49 | FASTBOOT=$( cmdline_parameter fastboot )
 | 
        
           |  |  | 50 |   | 
        
           | 131 | beyerle@PS | 51 | # no (auto) kudzu ?
 | 
        
           |  |  | 52 | NOKUDZU=$( cmdline_parameter nokudzu )
 | 
        
           |  |  | 53 |   | 
        
           | 1 | beyerle@PS | 54 | # if run=rdesktop, we do fast boot
 | 
        
           |  |  | 55 | if [ "$( cmdline_value run )" = "rdesktop" ]; then
 | 
        
           |  |  | 56 |     FASTBOOT="fastboot"
 | 
        
           |  |  | 57 | fi
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 | # start ntpd ?
 | 
        
           |  |  | 60 | NTPD=$( cmdline_parameter ntpd )
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 | # services on/off
 | 
        
           |  |  | 63 | SERVICEON=$( cmdline_value serviceon )
 | 
        
           |  |  | 64 | SERVICEOFF=$( cmdline_value serviceoff )
 | 
        
           |  |  | 65 |   | 
        
           | 88 | beyerle@PS | 66 | # Xserver configurations
 | 
        
           |  |  | 67 | SCREEN=$( cmdline_value screen )
 | 
        
           | 1 | beyerle@PS | 68 |   | 
        
           | 88 | beyerle@PS | 69 |   | 
        
           | 1 | beyerle@PS | 70 | ### -----------------------------------------------------------
 | 
        
           | 84 | beyerle@PS | 71 | ### Configure services
 | 
        
           | 1 | beyerle@PS | 72 | ### -----------------------------------------------------------
 | 
        
           |  |  | 73 |   | 
        
           |  |  | 74 | ### disable rpcidmapd, if LiveCD mounted over NFS
 | 
        
           |  |  | 75 | if [ $NFSROOT ]; then
 | 
        
           | 105 | beyerle@PS | 76 |     chkconfig rpcidmapd off >/dev/null 2>&1
 | 
        
           | 1 | beyerle@PS | 77 | fi
 | 
        
           |  |  | 78 |   | 
        
           | 88 | beyerle@PS | 79 | ### disable NetworkManager, if LiveCD mounted over NFS
 | 
        
           |  |  | 80 | if [ $NFSROOT ]; then
 | 
        
           | 105 | beyerle@PS | 81 |     chkconfig NetworkManager off           >/dev/null 2>&1
 | 
        
           |  |  | 82 |     chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
 | 
        
           | 88 | beyerle@PS | 83 | fi
 | 
        
           |  |  | 84 |   | 
        
           | 1 | beyerle@PS | 85 | ### disable shutdown of network and nfs, 
 | 
        
           |  |  | 86 | # if we have the LiveCD mounted over NFS
 | 
        
           |  |  | 87 | if [ $NFSROOT ]; then
 | 
        
           |  |  | 88 |     if [ $ONEMASTER ]; then
 | 
        
           |  |  | 89 |         # "network off" is only necessary, 
 | 
        
           |  |  | 90 |         # if PXE/TFTP and NTS server is on same machine
 | 
        
           |  |  | 91 | 	chkconfig network off
 | 
        
           |  |  | 92 |     fi
 | 
        
           |  |  | 93 |   | 
        
           | 128 | beyerle@PS | 94 |     rm -f /etc/rc.d/rc6.d/K*netfs
 | 
        
           |  |  | 95 |     rm -f /etc/rc.d/rc6.d/K*nfslock
 | 
        
           |  |  | 96 |     rm -f /etc/rc.d/rc6.d/K*portmap
 | 
        
           |  |  | 97 |     rm -f /etc/rc.d/rc6.d/K*network
 | 
        
           | 1 | beyerle@PS | 98 |   | 
        
           | 128 | beyerle@PS | 99 |     rm -f /etc/rc.d/rc0.d/K*netfs
 | 
        
           |  |  | 100 |     rm -f /etc/rc.d/rc0.d/K*nfslock
 | 
        
           |  |  | 101 |     rm -f /etc/rc.d/rc0.d/K*portmap
 | 
        
           |  |  | 102 |     rm -f /etc/rc.d/rc0.d/K*network
 | 
        
           | 1 | beyerle@PS | 103 | fi
 | 
        
           |  |  | 104 |   | 
        
           |  |  | 105 | ### enable AFS during start up, if given by boot parameter
 | 
        
           |  |  | 106 | if [ $AFS ]; then
 | 
        
           |  |  | 107 |     chkconfig afs on
 | 
        
           |  |  | 108 | fi
 | 
        
           |  |  | 109 |   | 
        
           | 131 | beyerle@PS | 110 | ### disable auto-kudzu
 | 
        
           |  |  | 111 | if [ $NOKUDZU ]; then
 | 
        
           |  |  | 112 |     chkconfig kudzu-auto off
 | 
        
           |  |  | 113 | fi
 | 
        
           |  |  | 114 |   | 
        
           | 1 | beyerle@PS | 115 | ### disable some services for fast booting
 | 
        
           |  |  | 116 | if [ $FASTBOOT ]; then    
 | 
        
           |  |  | 117 |     echo "Fast booting enabled"
 | 
        
           | 128 | beyerle@PS | 118 |     chkconfig vpnclient_init off  2>/dev/null
 | 
        
           |  |  | 119 |     chkconfig haldaemon off       2>/dev/null
 | 
        
           |  |  | 120 |     chkconfig pcmcia off          2>/dev/null
 | 
        
           |  |  | 121 |     chkconfig ntpd off            2>/dev/null
 | 
        
           |  |  | 122 |     chkconfig atd off             2>/dev/null
 | 
        
           |  |  | 123 |     chkconfig cpuspeed off        2>/dev/null
 | 
        
           |  |  | 124 |     chkconfig gpm off             2>/dev/null
 | 
        
           |  |  | 125 |     chkconfig messagebus off      2>/dev/null
 | 
        
           | 129 | beyerle@PS | 126 |     chkconfig avahi-daemon off    2>/dev/null
 | 
        
           | 128 | beyerle@PS | 127 |     chkconfig kudzu-auto off      2>/dev/null
 | 
        
           | 1 | beyerle@PS | 128 | fi
 | 
        
           |  |  | 129 |   | 
        
           |  |  | 130 | ### enable ntpd?
 | 
        
           |  |  | 131 | if [ $NTPD ]; then
 | 
        
           |  |  | 132 |     chkconfig ntpd on
 | 
        
           |  |  | 133 | fi
 | 
        
           |  |  | 134 |   | 
        
           |  |  | 135 | ### enable SSH server during start up, if given by boot parameter
 | 
        
           |  |  | 136 | if [ $SSH ]; then
 | 
        
           |  |  | 137 |     chkconfig sshd on
 | 
        
           |  |  | 138 | fi
 | 
        
           |  |  | 139 |   | 
        
           | 84 | beyerle@PS | 140 | ### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
 | 
        
           |  |  | 141 | if [ ! $NONET ]; then
 | 
        
           |  |  | 142 |     lspci | grep -q Intel.*3945ABG
 | 
        
           |  |  | 143 |     if [ "$?" = "0" ]; then
 | 
        
           |  |  | 144 | 	chkconfig ipw3945d on 2>/dev/null
 | 
        
           |  |  | 145 |     fi
 | 
        
           |  |  | 146 | fi
 | 
        
           |  |  | 147 |   | 
        
           |  |  | 148 | ### enable 915resolution on Intel Mobile Display controller
 | 
        
           | 88 | beyerle@PS | 149 | #   and set resolution in /etc/sysconfig/915resolution defined by screen=
 | 
        
           | 84 | beyerle@PS | 150 | lspci | grep -q Display.*Intel.*Mobile
 | 
        
           |  |  | 151 | if [ "$?" = "0" ]; then 
 | 
        
           |  |  | 152 |     chkconfig 915resolution on 2>/dev/null
 | 
        
           | 88 | beyerle@PS | 153 |     if [ -e /etc/sysconfig/915resolution ]; then
 | 
        
           |  |  | 154 | 	X=$( echo $SCREEN | cut -d"x" -f1 )
 | 
        
           |  |  | 155 | 	Y=$( echo $SCREEN | cut -d"x" -f2 )
 | 
        
           |  |  | 156 | 	if [ $X ]; then
 | 
        
           |  |  | 157 | 	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
 | 
        
           |  |  | 158 | 	fi
 | 
        
           |  |  | 159 | 	if [ $Y ]; then
 | 
        
           |  |  | 160 | 	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
 | 
        
           |  |  | 161 | 	fi
 | 
        
           |  |  | 162 |     fi
 | 
        
           | 84 | beyerle@PS | 163 | fi
 | 
        
           |  |  | 164 |   | 
        
           | 1 | beyerle@PS | 165 | ### services on
 | 
        
           |  |  | 166 | if [ -n $SERVICEON ]; then
 | 
        
           |  |  | 167 |     for service in `echo "$SERVICEON" | tr ':' ' '`; do
 | 
        
           |  |  | 168 | 	if [ -f /etc/init.d/$service ]; then
 | 
        
           |  |  | 169 | 	    chkconfig $service on
 | 
        
           |  |  | 170 | 	fi
 | 
        
           |  |  | 171 |     done
 | 
        
           |  |  | 172 | fi
 | 
        
           |  |  | 173 |   | 
        
           |  |  | 174 | ### services off
 | 
        
           |  |  | 175 | if [ -n $SERVICEOFF ]; then
 | 
        
           |  |  | 176 |     for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
 | 
        
           |  |  | 177 | 	if [ -f /etc/init.d/$service ]; then
 | 
        
           |  |  | 178 | 	    chkconfig $service off
 | 
        
           |  |  | 179 | 	fi
 | 
        
           |  |  | 180 |     done
 | 
        
           |  |  | 181 | fi
 | 
        
           |  |  | 182 |   | 
        
           | 84 | beyerle@PS | 183 |   | 
        
           |  |  | 184 | ### -----------------------------------------------------------
 | 
        
           |  |  | 185 | ### Main
 | 
        
           |  |  | 186 | ### -----------------------------------------------------------
 | 
        
           |  |  | 187 |   | 
        
           |  |  | 188 | ### get resolv.conf, if we have the LiveCD mounted over NFS
 | 
        
           |  |  | 189 | if [ $NFSROOT ]; then
 | 
        
           |  |  | 190 |     cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
 | 
        
           |  |  | 191 | fi
 | 
        
           |  |  | 192 |   | 
        
           |  |  | 193 | ### restore blacklist (modified in runveryfirst)
 | 
        
           |  |  | 194 | if [ $NFSROOT ]; then
 | 
        
           |  |  | 195 |     [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
 | 
        
           |  |  | 196 |     [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
 | 
        
           |  |  | 197 |     mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
 | 
        
           |  |  | 198 | fi
 | 
        
           |  |  | 199 |   | 
        
           |  |  | 200 | ### create AFS mount point
 | 
        
           |  |  | 201 | mkdir -p /afs
 | 
        
           |  |  | 202 |   | 
        
           |  |  | 203 | ### set afs cell, if given by boot parameter
 | 
        
           |  |  | 204 | if [ $CELL ]; then
 | 
        
           |  |  | 205 |     echo $CELL > /usr/vice/etc/ThisCell
 | 
        
           |  |  | 206 | fi
 | 
        
           |  |  | 207 |   | 
        
           | 1 | beyerle@PS | 208 | ### fix perm of /tmp
 | 
        
           |  |  | 209 | chmod 1777 /tmp
 | 
        
           |  |  | 210 |   | 
        
           |  |  | 211 | ### create home
 | 
        
           |  |  | 212 | mkdir -p /home
 | 
        
           |  |  | 213 |   | 
        
           |  |  | 214 | ### create /scratch
 | 
        
           |  |  | 215 | mkdir -p /scratch
 | 
        
           |  |  | 216 | chmod 1777 /scratch
 | 
        
           |  |  | 217 |   | 
        
           |  |  | 218 | ### create /data
 | 
        
           |  |  | 219 | if [ $PSI ]; then
 | 
        
           |  |  | 220 |     mkdir -p /data
 | 
        
           |  |  | 221 |     chmod 1777 /data
 | 
        
           |  |  | 222 | fi
 | 
        
           |  |  | 223 |   | 
        
           |  |  | 224 | ### add PSI master
 | 
        
           |  |  | 225 | if [ $PSI ]; then
 | 
        
           |  |  | 226 |     mkdir -p /mnt/master
 | 
        
           | 125 | beyerle@PS | 227 |     echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
 | 
        
           | 1 | beyerle@PS | 228 | fi
 | 
        
           |  |  | 229 |   |