Advertisement
Guest User

Untitled

a guest
Aug 15th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.31 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # rc.M      This file is executed by init(8) when the system is being
  4. #       initialized for one of the "multi user" run levels (i.e.
  5. #       levels 1 through 6).  It usually does mounting of file
  6. #       systems et al.
  7. #
  8. # Version:  @(#)/etc/rc.d/rc.M  2.23    Wed Feb 26 19:20:58 PST 2003
  9. #
  10. # Author:   Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
  11. #       Heavily modified by Patrick Volkerding <volkerdi@slackware.com>
  12. #
  13. # Modified for Salix by: George Vlahavas <vlahavas~at~gmail~dot~com>
  14.  
  15. # modified for colorized screen messages and local needs
  16. . /etc/shell-colors
  17.  
  18. # Tell the viewers what's going to happen.
  19. echo
  20. echo -e "${BOLDYELLOW}Going to multi user mode.${COLOR_RESET}"
  21.  
  22. # Screen blanks after 15 minutes idle time, and powers down in one hour
  23. # if the kernel supports APM or ACPI power management:
  24. /bin/setterm -blank 15 -powersave powerdown -powerdown 60
  25.  
  26. # Set the hostname.
  27. if [ -r /etc/HOSTNAME ]; then
  28.   /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
  29. else
  30.   # fall back on this old default:
  31.   echo "darkstar.example.net" > /etc/HOSTNAME
  32.   /bin/hostname darkstar
  33. fi
  34.  
  35. # Set the permissions on /var/log/dmesg according to whether the kernel
  36. # permits non-root users to access kernel dmesg information:
  37. if [ -r /proc/sys/kernel/dmesg_restrict ]; then
  38.   if [ $(cat /proc/sys/kernel/dmesg_restrict) = 1 ]; then
  39.     touch /var/log/dmesg
  40.     chmod 640 /var/log/dmesg
  41.   fi
  42. else
  43.   touch /var/log/dmesg
  44.   chmod 644 /var/log/dmesg
  45. fi
  46. # Save the contents of 'dmesg':
  47. /bin/dmesg -s 65536 > /var/log/dmesg
  48.  
  49. # Initialize PCMCIA devices:
  50. #
  51. # NOTE: This used to be started near the top of rc.S so that PCMCIA devices
  52. # could be fsck'ed along with the other drives.  This had some unfortunate
  53. # side effects, however, since root isn't yet read-write, and /var might not
  54. # even be mounted the .pid files can't be correctly written in /var/run and
  55. # the pcmcia system can't be correctly shut down.  If you want some PCMCIA
  56. # partition to be mounted at boot (or when the card is inserted) then add
  57. # the appropriate lines to /etc/pcmcia/scsi.opts.
  58. #
  59. # Note that the stuff in /etc/pcmcia/ is only for 2.4.x kernels using
  60. # 16-bit PCMCIA cards (not 32-bit Cardbus cards!).  For example, with a
  61. # wireless card you might need to set options in /etc/pcmcia OR in
  62. # /etc/rc.d/rc.wireless.conf, or even in /etc/rc.d/rc.inet1.conf (with
  63. # extra options if needed for the encryption key, ESSID, etc.)
  64. #
  65. # Hopefully this situation will be unified in the future, but for now
  66. # that's how it is...
  67. #
  68. if [ -x /etc/rc.d/rc.pcmcia ]; then
  69.   . /etc/rc.d/rc.pcmcia start
  70.   # The cards might need a little extra time here to initialize.
  71.   sleep 5
  72. fi
  73.  
  74. # Start the system logger.
  75. if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then
  76.   . /etc/rc.d/rc.syslog start
  77. fi
  78.  
  79. # If we are returning from single-user mode we will need to restart
  80. # udevd on systems that use udev:
  81. if grep -wq sysfs /proc/mounts && grep -q tmpfs /proc/filesystems ; then
  82.   if ! grep -wq nohotplug /proc/cmdline ; then
  83.     if [ -x /etc/rc.d/rc.udev ]; then
  84.       /bin/sh /etc/rc.d/rc.udev start
  85.     fi
  86.   fi
  87. fi
  88.  
  89. # Initialize the networking hardware.
  90. if [ -x /etc/rc.d/rc.inet1 ]; then
  91.   . /etc/rc.d/rc.inet1
  92. fi
  93.  
  94. # Look for additional USB/SCSI/IEEE1394/etc devices on multiple LUNs:
  95. if [ -x /etc/rc.d/rc.scanluns ]; then
  96.   . /etc/rc.d/rc.scanluns
  97. fi
  98.  
  99. # Start networking daemons:
  100. if [ -x /etc/rc.d/rc.inet2 ]; then
  101.   . /etc/rc.d/rc.inet2
  102. fi
  103.  
  104. # Mount any additional filesystem types that haven't already been mounted:
  105. mount -a -v 2> /dev/null | grep -v "already mounted"
  106.  
  107. # Start the Control Script for automounter:
  108. if [ -x /etc/rc.d/rc.autofs ]; then
  109.   sh /etc/rc.d/rc.autofs start
  110. fi
  111.  
  112. # Remove stale locks and junk files (must be done after mount -a!)
  113. /bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/core /core 2> /dev/null
  114.  
  115. # Remove stale hunt sockets so the game can start.
  116. if [ -r /tmp/hunt -o -r /tmp/hunt.stats ]; then
  117.   echo -e "${BOLDWHITE}Removing stale hunt sockets from /tmp.${COLOR_RESET}"
  118.   /bin/rm -f /tmp/hunt*
  119. fi
  120.  
  121. # Ensure basic filesystem permissions sanity.
  122. chmod 755 / 2> /dev/null
  123. chmod 1777 /tmp /var/tmp
  124.  
  125. # Start APM or ACPI daemon.
  126. # If APM is enabled in the kernel, start apmd:
  127. if [ -e /proc/apm ]; then
  128.   if [ -x /usr/sbin/apmd ]; then
  129.     echo -e "${BOLDWHITE}Starting APM daemon:${COLOR_RESET}  /usr/sbin/apmd"
  130.     /usr/sbin/apmd
  131.   fi
  132. elif [ -x /etc/rc.d/rc.acpid ]; then # otherwise, start acpid:
  133.   . /etc/rc.d/rc.acpid start
  134. fi
  135.  
  136. # Start D-Bus:
  137. if [ -x /etc/rc.d/rc.messagebus ]; then
  138.   /bin/sh /etc/rc.d/rc.messagebus start
  139. fi
  140.  
  141. # Start console-kit-daemon:
  142. if [ -x /etc/rc.d/rc.consolekit ]; then
  143.   /bin/sh /etc/rc.d/rc.consolekit start
  144. fi
  145.  
  146. # Start HAL:
  147. if [ -x /etc/rc.d/rc.hald ]; then
  148.   /bin/sh /etc/rc.d/rc.hald start
  149. fi
  150.  
  151. # Start Bluetooth:
  152. if [ -x /etc/rc.d/rc.bluetooth ]; then
  153.   /bin/sh /etc/rc.d/rc.bluetooth start
  154. fi
  155.  
  156. # Start wicd:
  157. if [ -x /etc/rc.d/rc.wicd ]; then
  158.   . /etc/rc.d/rc.wicd start
  159. fi
  160.  
  161. # Start dnsmasq, a simple DHCP/DNS server:
  162. if [ -x /etc/rc.d/rc.dnsmasq ]; then
  163.   /etc/rc.d/rc.dnsmasq start
  164. fi
  165.  
  166. # Start snmpd:
  167. if [ -x /etc/rc.d/rc.snmpd ]; then
  168.   /etc/rc.d/rc.snmpd start
  169. fi
  170.  
  171. # Start the Network Time Protocol daemon:
  172. if [ -x /etc/rc.d/rc.ntpd ]; then
  173.   /bin/sh /etc/rc.d/rc.ntpd start
  174. fi
  175.  
  176. # Start the print spooling system.  This will usually be LPRng (lpd) or CUPS.
  177. if [ -x /etc/rc.d/rc.cups ]; then
  178.   # Start CUPS:
  179.   echo -e "${BOLDWHITE}Starting the print spooling system:${COLOR_RESET}"
  180.   /etc/rc.d/rc.cups start
  181. elif [ -x /etc/rc.d/rc.lprng ]; then
  182.   # Start LPRng (lpd):
  183.   echo -e "${BOLDWHITE}Starting the print spooling system:${COLOR_RESET}"
  184.   . /etc/rc.d/rc.lprng start
  185. fi
  186.  
  187. # Start netatalk. (a file/print server for Macs using Appletalk)
  188. if [ -x /etc/rc.d/rc.atalk ]; then
  189.   /etc/rc.d/rc.atalk
  190. fi
  191.  
  192. # Start smartd, which monitors the status of S.M.A.R.T. compatible
  193. # hard drives and reports any problems.  Note some devices (which aren't
  194. # smart, I guess ;) will hang if probed by smartd, so it's commented out
  195. # by default.
  196. #if [ -x /usr/sbin/smartd ]; then
  197. #  /usr/sbin/smartd
  198. #fi
  199.  
  200. # If we're using udev, make /dev/cdrom and any other optical drive symlinks
  201. # if some udev rule hasn't made them already:
  202. if grep -wq sysfs /proc/mounts && grep -q tmpfs /proc/filesystems; then
  203.   if ! grep -wq nohotplug /proc/cmdline ; then
  204.     if [ -x /lib/udev/rc.optical-symlinks -a -x /etc/rc.d/rc.udev ]; then
  205.       /bin/sh /lib/udev/rc.optical-symlinks
  206.     fi
  207.   fi
  208. fi
  209.  
  210. # Monitor the UPS with genpowerd.
  211. # To use this, uncomment this section and edit your settings in
  212. # /etc/genpowerd.conf (serial device, UPS type, etc).  For more information,
  213. # see "man genpowerd" or the extensive documentation in the
  214. # /usr/doc/genpower-*/ directory.
  215. # You'll also need to configure a similar block in /etc/rc.d/rc.6 if you want
  216. # support for stopping the UPS's inverter after the machine halts.
  217. #if [ -x /sbin/genpowerd ]; then
  218. #  echo -e "${BOLDWHITE}Starting genpowerd daemon.${COLOR_RESET}"
  219. #  /sbin/genpowerd
  220. #fi
  221.  
  222. # Turn on process accounting.  To enable process accounting, make sure the
  223. # option for BSD process accounting is enabled in your kernel, and then
  224. # create the file /var/log/pacct (touch /var/log/pacct).  By default, process
  225. # accounting is not enabled (since /var/log/pacct does not exist).  This is
  226. # because the log file can get VERY large.
  227. if [ -x /sbin/accton -a -r /var/log/pacct ]; then
  228.   chmod 640 /var/log/pacct
  229.   /sbin/accton /var/log/pacct
  230. fi
  231.  
  232. # Start crond (Dillon's crond):
  233. # If you want cron to actually log activity to /var/log/cron, then change
  234. # -l notice to -l info to increase the logging level.
  235. if [ -x /usr/sbin/crond ]; then
  236.   echo -e "${BOLDWHITE}Starting the cron scheduling daemon:${COLOR_RESET}"
  237.   /usr/sbin/crond -l notice
  238. fi
  239.  
  240. # Start atd (manages jobs scheduled with 'at'):
  241. if [ -x /usr/sbin/atd ]; then
  242.   echo -e "${BOLDWHITE}Starting the at scheduling daemon:${COLOR_RESET}"
  243.   /usr/sbin/atd -b 15 -l 1
  244. fi
  245.  
  246. # Slackware-Mini-Quota-HOWTO:
  247. # To really activate quotas, you'll need to add 'usrquota' and/or 'grpquota' to
  248. # the appropriate partitions as listed in /etc/fstab.  Here's an example:
  249. #
  250. # /dev/hda2      /home      ext3     defaults,usrquota      1   1
  251. #
  252. # You'll then need to setup initial quota files at the top of the partitions
  253. # to support quota, like this:
  254. # touch /home/aquota.user /home/aquota.group
  255. # chmod 600 /home/aquota.user /home/aquota.group
  256. #
  257. # Then, reboot to activate the system.
  258. # To edit user quotas, use 'edquota'.  See 'man edquota'.  Also, the
  259. # official Quota Mini-HOWTO has lots of useful information.  That can be found
  260. # here:  /usr/doc/Linux-HOWTOs/Quota
  261.  
  262. # Check quotas and then turn quota system on:
  263. if grep -q quota /etc/fstab ; then
  264.   for quotafs in $(awk '/quota/ {print $2}' /etc/fstab) ; do
  265.     /bin/rm -f $quotafs/{a,}quota.{group,user}.new
  266.   done
  267.   if [ -x /sbin/quotacheck ]; then
  268.     echo -e "${BOLDCYAN}Checking filesystem quotas:${COLOR_RESET}  /sbin/quotacheck -avugm"
  269.     /sbin/quotacheck -avugm
  270.   fi
  271.   if [ -x /sbin/quotaon ]; then
  272.     echo -e "${BOLDCYAN}Activating filesystem quotas:${COLOR_RESET}  /sbin/quotaon -avug"
  273.     /sbin/quotaon -avug
  274.   fi
  275. fi
  276.  
  277. # Start the SASL authentication server.  This provides SASL
  278. # authentication services for sendmail:
  279. if [ -x /etc/rc.d/rc.saslauthd ]; then
  280.   . /etc/rc.d/rc.saslauthd start
  281. fi
  282.  
  283. # Start the sendmail daemon:
  284. if [ -x /etc/rc.d/rc.sendmail ]; then
  285.   . /etc/rc.d/rc.sendmail start
  286. fi
  287.  
  288. # Load ALSA (sound) defaults:
  289. if [ -x /etc/rc.d/rc.alsa ]; then
  290.   echo -e "${BOLDWHITE}Configuring ALSA:${COLOR_RESET}"
  291.   . /etc/rc.d/rc.alsa
  292. fi
  293.  
  294. # Load a custom keymap if the user has an rc.keymap script.
  295. if [ -x /etc/rc.d/rc.keymap ]; then
  296.   echo -e "${BOLDWHITE}Loading default keyboard map:${COLOR_RESET}"
  297.   . /etc/rc.d/rc.keymap
  298. fi
  299.  
  300. # Start the MySQL database:
  301. if [ -x /etc/rc.d/rc.mysqld ]; then
  302.   . /etc/rc.d/rc.mysqld start
  303. fi
  304.  
  305. # Start Apache web server:
  306. if [ -x /etc/rc.d/rc.httpd ]; then
  307.   . /etc/rc.d/rc.httpd start
  308. fi
  309.  
  310. # Start OpenLDAP:
  311. if [ -x /etc/rc.d/rc.openldap ]; then
  312.   . /etc/rc.d/rc.openldap start
  313. fi
  314.  
  315. # Start Samba (a file/print server for Win95/NT machines).
  316. # Samba can be started in /etc/inetd.conf instead.
  317. if [ -x /etc/rc.d/rc.samba ]; then
  318.   . /etc/rc.d/rc.samba start
  319. fi
  320.  
  321. # Start the GPM mouse server:
  322. if [ -x /etc/rc.d/rc.gpm ]; then
  323.   . /etc/rc.d/rc.gpm start
  324. fi
  325.  
  326. # If there are SystemV init scripts for this runlevel, run them.
  327. if [ -x /etc/rc.d/rc.sysvinit ]; then
  328.   . /etc/rc.d/rc.sysvinit
  329. fi
  330.  
  331. # Start all other rc files not listed in here
  332. if [ -x /etc/rc.d/rc.services ]; then
  333.     python /etc/rc.d/rc.services
  334. fi
  335.  
  336. # Start numlockx if it's activated.
  337. if [ -x /etc/rc.d/rc.numlock ]; then
  338.   . /etc/rc.d/rc.numlock start
  339. fi
  340.  
  341. # Load a custom screen font if the user has an rc.font script.
  342. if [ -x /etc/rc.d/rc.font ]; then
  343.   . /etc/rc.d/rc.font
  344. fi
  345.  
  346. # We need to wait 25 secs and try to mount everything not mounted
  347. # already for networks shares, as network connections might not have
  348. # established properly yet.
  349. sleep 25 && {
  350.     mount -a -v 2> /dev/null | grep -v "already mounted"
  351.     /bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/core /core 2> /dev/null
  352. } &
  353.  
  354. # Start the local setup procedure.
  355. if [ -x /etc/rc.d/rc.local ]; then
  356.   echo -e "${BOLDBLUE}Running local startup commands.${COLOR_RESET}"
  357.   . /etc/rc.d/rc.local
  358. fi
  359.  
  360. # All done.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement