All pastes #676020 Raw Edit

Untitled

public text v1 · immutable
#676020 ·published 2007-08-30 18:25 UTC
rendered paste body
#!/bin/sh
# rc.M		
# This file is executed by init(8) when the system is being initialized 
# for one of the "multi user" run levels (i.e. levels 2 through 5).
#
# Origin: this script is a mix of rc.S, rc.M and rc.inet2 from Slackware 10.0
#
# GNU GPL (c) Eko M. Budi, 2004
#         (c) Vector Linux, 2004, Uel Archuletta(bootsplash-text)-2006
#

# load functions
. /etc/rc.d/functions-display

PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PATH"

# Tell the viewers what's going to happen.
/etc/rc.d/rc.text 12 'Going multiuser...'
echocl "rc.M ==> Going multiuser..." yellow

## Turn ON system logger first
if [ -x /etc/rc.d/rc.syslog ]; then
 /etc/rc.d/rc.text 13 'Starting system logger'
  echonl "Starting system logger ..."
  /etc/rc.d/rc.syslog start > /dev/null 2>&1
  evaluate_retvall
fi

## Hardware initialisation
echocl "Initializing hardware" cyan
for RC in modules pnp serial parallel alsa cdrom samba messagebus; do
   if [ -x /etc/rc.d/rc.$RC ]; then
      /etc/rc.d/rc.text 14 "Setting up $RC..."  
      echonl "Setting up $RC ..."
      /etc/rc.d/rc.$RC start > /dev/null 2>&1
      evaluate_retvall
      sleep .2
   fi
done

for RC in apm; do
   if [ -x /etc/rc.d/rc.$RC ]; then
      /etc/rc.d/rc.text 15 "Setting up $RC ..." 
      echonl "Setting up $RC ..."
      /etc/rc.d/rc.$RC start > /dev/null 2>&1
      evaluate_retvall
   fi
done

## Setup basic networking
## Note for slackers: this replaces rc.inet1
## On Vector rc.inet? = individual network device
/etc/rc.d/rc.text 16 ' Initializing Network' 
echocl "Initializing network" cyan

## Start Paranoid firewall 
if [ -x /etc/rc.d/rc.paranoid ]; then
  /etc/rc.d/rc.text 16 'Closing up the holes ...'   
  echonl "Closing up the holes ..."
  /etc/rc.d/rc.paranoid start > /dev/null 2>&1
  evaluate_retvall
fi

## Set hostname & name server
    
if grep -qe " *(hostname|dns)=" /proc/cmdline; then
  if [ -x /etc/rc.d/rc.boot-name ]; then
    /etc/rc.d/rc.text 17 'Setting name from boot parameters ...'
    echonl "Setting name from boot parameters ..."
    /etc/rc.d/rc.boot-name start > /dev/null 2>&1
    evaluate_retvall
  fi
fi

## Local host is always ON for multiuser mode
## So I hardcoded it here
 /etc/rc.d/rc.text 17 'Setting up localhost ...'  
echonl "Setting up localhost ..."
ifconfig lo 127.0.0.1 netmask 255.0.0.0 && \
  route add -net 127.0.0.0 netmask 255.0.0.0 lo > /dev/null 2>&1
evaluate_retvall

## set other networks
  ## Start network using boot parameter or the default inet script
  ## Boot parameter is useful for UML, e.g. you may boot linux with
  ## linux inet1=eth0,dhcp
  ## linux inet1=eth0,{IP},{NETMASK},{GATEWAY}
  for i in 0 1 2 3 4; do
  if [ -x /etc/rc.d/rc.inet$i ]; then
    /etc/rc.d/rc.text 17 'Setting up basic network ...'
    echonl "Setting up basic network ..."
    /etc/rc.d/rc.inet$i start
    evaluate_retvall
  fi
  if [ -x /etc/rc.d/rc.eth$i ]; then
    /etc/rc.d/rc.text 17 "Starting eth$i"
    echonl "Setting up basic network ..."
    /etc/rc.d/rc.eth$i start
    evaluate_retvall
  fi
#done

## routing, gateway and firewall
## rc.route = custom routing 
## rc.firewall = custom firewall
## ip_forward = enable forwarding, if not in the firewall
for RC in route firewall; do
   if [ -x /etc/rc.d/rc.$RC ]; then
      /etc/rc.d/rc.text 18 "Setting up $RC ..."        
      echonl "Setting up $RC ..."
      /etc/rc.d/rc.$RC start > /dev/null 2>&1
      evaluate_retvall
   fi
done

## at this point, we are ready to talk to The World...
## Here comes the Network file system
## Note for slackers: this is taken from rc.inet2

NFSTAB=`grep -E "^[^#].*[[:space:]].*[[:space:]](nfs|smbfs|ncpfs)[[:space:]]" /etc/fstab`
if [ "$NFSTAB" ]; then
  echocl "Mounting network file system ..." cyan
  if echo $NFSTAB | grep -qw nfs; then
    # Start the RPC portmapper if we find NFS volumes defined in /etc/fstab.
    if ! /usr/sbin/rpcinfo -p 1> /dev/null 2> /dev/null ; then
      if [ -x /sbin/rpc.portmap ]; then
        /etc/rc.d/rc.text 19 'Starting RPC portmapper ...'
        echonl "Starting RPC portmapper ..."
        /sbin/rpc.portmap > /dev/null 2&>1
	evaluate_retvall
      fi
    fi
    /etc/rc.d/rc.text 19 'Mounting remote (NFS) file systems...'
    echonl "Mounting remote (NFS) file systems ..."
    /sbin/mount -a -t nfs  > /dev/null 2&>1
    evaluate_retvall
  fi

  if echo $NFSTAB | grep -qE "[[:space:]](smbfs|ncpfs)[[:space:]]"; then
    /etc/rc.d/rc.text 19 'Mounting remote (SMB/NCP) file systems'
    echonl "Mounting remote (SMB/NCP) file systems ..."
    /sbin/mount -a -t smbfs,ncpfs > /dev/null 2&>1
    evaluate_retvall
  fi

  ## If the new mounted FS is /tmp or /var, reset the file system again
  mount | while read LINE; do
     fsystem=`echo $LINE | cut -f5 -d ' '`
     case $fsystem in nfs|smbfs|ncpfs)
       mpoint=`echo $LINE | cut -f3 -d ' '`
       case $mpoint in
         /tmp|/tmp/*) 
	    rm -f /tmp/.X*lock /tmp/core /tmp/menu* /tmp/reply* /tmp/vasm.log /tmp/kde* /tmp/ksocket*
	    [ -r /tmp/hunt -o -r /tmp/hunt.stats ] && rm -f /tmp/hunt*
	    mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
	    chmod 1777 /tmp /tmp/.ICE-unix /tmp/.X11-unix
	    ;;
	 /var|/var/*)
	    rm -f /var/run/utmp /var/run/*pid /var/run/lpd* /var/run/ppp* /var/run/usb/* \
    		/var/lock/* /var/lock/usb/* /var/spool/uucp/LCK..*
	    touch /var/run/utmp
	    chown root.utmp /var/run/utmp
	    chmod 664 /var/run/utmp
	    /etc/rc.d/rc.syslog restart
	    ;;
	 /usr|/usr/*|/opt|/opt/*)
	    ## Updating libraries
	    ldconfig
           ;;	 
       esac
     esac
  done 
fi

# Set console and X fonts
# setfont &> /dev/null
if [ -x /usr/bin/fc-cache ]; then
    /etc/rc.d/rc.text 19 'Caching fonts ...'
    echonl "Caching fonts ..."
    /usr/bin/fc-cache -r &> /dev/null
    evaluate_retvall
fi

#load vcpufreq if it is set in its config
/sbin/vcpufreq-load

#mount all filesystems in fstab
mount -a 2>/dev/null

###uncomment next 3 lines for nice console background
#for i in 1 2 3 4 5 6 ; do
# splash -s -u $i /etc/bootsplash/themes/current/config/verbose-`fbresolution 2>/dev/null`.cfg 2>/dev/null
#done

/etc/rc.d/rc.text 19 'Starting the System'