From 44817e10492e311950bb9fdda0de6bf75cb9672f Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Fri, 8 Sep 2023 09:19:46 -0700 Subject: [PATCH] fill out complete set of startup (rc) files used by Unraid OS --- etc/rc.d/rc.0 | 1 + etc/rc.d/rc.4 | 60 +++++++++ etc/rc.d/rc.4.local | 9 ++ etc/rc.d/rc.6 | 278 +++++++++++++++++++++++++++++++++++++++++ etc/rc.d/rc.K | 126 +++++++++++++++++++ etc/rc.d/rc.M | 255 +++++++++++++++++++++++++++++++++++++ etc/rc.d/rc.S | 156 +++++++++++++++++++++++ etc/rc.d/rc.S.cont | 243 +++++++++++++++++++++++++++++++++++ etc/rc.d/rc.acpid | 40 ++++++ etc/rc.d/rc.atd | 39 ++++++ etc/rc.d/rc.bind | 136 ++++++++++++++++++++ etc/rc.d/rc.cgconfig | 202 ++++++++++++++++++++++++++++++ etc/rc.d/rc.cgred | 170 +++++++++++++++++++++++++ etc/rc.d/rc.dnsmasq | 43 +++++++ etc/rc.d/rc.font | 6 + etc/rc.d/rc.inetd | 36 ++++++ etc/rc.d/rc.ip_forward | 100 +++++++++++++++ etc/rc.d/rc.kadmind | 40 ++++++ etc/rc.d/rc.kpropd | 41 ++++++ etc/rc.d/rc.krb5kdc | 41 ++++++ etc/rc.d/rc.loop | 11 ++ etc/rc.d/rc.messagebus | 81 ++++++++++++ etc/rc.d/rc.saslauthd | 45 +++++++ etc/rc.d/rc.serial | 132 +++++++++++++++++++ etc/rc.d/rc.smartd | 50 ++++++++ etc/rc.d/rc.sshd | 6 +- etc/rc.d/rc.sysvinit | 56 +++++++++ etc/rc.d/rc.wsdd2 | 58 +++++++++ 28 files changed, 2458 insertions(+), 3 deletions(-) create mode 120000 etc/rc.d/rc.0 create mode 100755 etc/rc.d/rc.4 create mode 100755 etc/rc.d/rc.4.local create mode 100755 etc/rc.d/rc.6 create mode 100755 etc/rc.d/rc.K create mode 100755 etc/rc.d/rc.M create mode 100755 etc/rc.d/rc.S create mode 100755 etc/rc.d/rc.S.cont create mode 100755 etc/rc.d/rc.acpid create mode 100755 etc/rc.d/rc.atd create mode 100644 etc/rc.d/rc.bind create mode 100644 etc/rc.d/rc.cgconfig create mode 100644 etc/rc.d/rc.cgred create mode 100755 etc/rc.d/rc.dnsmasq create mode 100644 etc/rc.d/rc.font create mode 100755 etc/rc.d/rc.inetd create mode 100755 etc/rc.d/rc.ip_forward create mode 100644 etc/rc.d/rc.kadmind create mode 100644 etc/rc.d/rc.kpropd create mode 100644 etc/rc.d/rc.krb5kdc create mode 100755 etc/rc.d/rc.loop create mode 100755 etc/rc.d/rc.messagebus create mode 100644 etc/rc.d/rc.saslauthd create mode 100755 etc/rc.d/rc.serial create mode 100644 etc/rc.d/rc.smartd create mode 100755 etc/rc.d/rc.sysvinit create mode 100755 etc/rc.d/rc.wsdd2 diff --git a/etc/rc.d/rc.0 b/etc/rc.d/rc.0 new file mode 120000 index 000000000..a4b596bfa --- /dev/null +++ b/etc/rc.d/rc.0 @@ -0,0 +1 @@ +rc.6 \ No newline at end of file diff --git a/etc/rc.d/rc.4 b/etc/rc.d/rc.4 new file mode 100755 index 000000000..e7e7aa587 --- /dev/null +++ b/etc/rc.d/rc.4 @@ -0,0 +1,60 @@ +#!/bin/bash +# +# rc.4 This file is executed by init(8) when the system is being +# initialized for run level 4 (XDM) +# +# Version: @(#)/etc/rc.d/rc.4 2.00 02/17/93 +# +# Author: Fred N. van Kempen, +# At least 47% rewritten by: Patrick J. Volkerding +# + +# Tell the viewers what's going to happen... +echo "Starting up X11 session manager..." + +# If you'd like to start something different or in a different order than +# the options below, create your own startup script /etc/rc.d/rc.4.local +# and make it executable and it will be used instead: +if [ -x /etc/rc.d/rc.4.local ]; then + exec /bin/bash /etc/rc.d/rc.4.local +fi + +# Try to use GNOME's gdm session manager. This comes first because if +# gdm is on the machine then the user probably installed it and wants +# to use it by default: +if [ -x /usr/bin/gdm ]; then + exec /usr/bin/gdm +fi + +# Someone thought that gdm looked prettier in /usr/sbin, +# so look there, too: +if [ -x /usr/sbin/gdm ]; then + exec /usr/sbin/gdm +fi + +# Not there? OK, try to use KDE's kdm session manager: +if [ -x /opt/kde/bin/kdm ]; then + exec /opt/kde/bin/kdm -nodaemon +elif [ -x /usr/bin/kdm ]; then + exec /usr/bin/kdm -nodaemon +fi + +# Look for SDDM as well: +if [ -x /usr/bin/sddm ]; then + exec /usr/bin/sddm +fi + +# If all you have is XDM, I guess it will have to do: +if [ -x /usr/bin/xdm ]; then + exec /usr/bin/xdm -nodaemon +elif [ -x /usr/X11R6/bin/xdm ]; then + exec /usr/X11R6/bin/xdm -nodaemon +fi + +# error +echo +echo "Hey, you don't have SDDM, KDM, GDM, or XDM. Can't use runlevel 4 without" +echo "one of those installed." +sleep 30 + +# All done. diff --git a/etc/rc.d/rc.4.local b/etc/rc.d/rc.4.local new file mode 100755 index 000000000..f6d6afc07 --- /dev/null +++ b/etc/rc.d/rc.4.local @@ -0,0 +1,9 @@ +#! /bin/sh +# +# rc.4.local This file is executed by rc.4 +# + +# Try to use SLiM login manager: +if [ -x /usr/bin/slim ]; then + exec /usr/bin/slim +fi diff --git a/etc/rc.d/rc.6 b/etc/rc.d/rc.6 new file mode 100755 index 000000000..abf61f971 --- /dev/null +++ b/etc/rc.d/rc.6 @@ -0,0 +1,278 @@ +#!/bin/bash +# +# rc.6 This file is executed by init when it goes into runlevel +# 0 (halt) or runlevel 6 (reboot). It kills all processes, +# unmounts file systems and then either halts or reboots. +# +# Version: @(#)/etc/rc.d/rc.6 15.0 Wed Nov 10 21:19:42 UTC 2021 +# +# Author: Miquel van Smoorenburg +# Modified by: Patrick J. Volkerding, +# +# limetech - modified for Unraid OS + +# Set the path. +PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + /etc/rc.d/rc.sysvinit +fi + +# Set linefeed mode to avoid staircase effect. +/bin/stty onlcr + +echo "Running shutdown script $0:" + +# Find out how we were called. +case "$0" in + *0) + shutdown_command="halt" + ;; + *6) + shutdown_command=reboot + ;; + *) + echo "$0: call me as \"rc.0\" or \"rc.6\" please!" + exit 1 + ;; +esac + +# Restart init. This prevents init from hanging on to file handles for removed +# glibc shared libraries in the case that those were upgraded or reinstalled. +/sbin/telinit u + +# Save the system time to the hardware clock using hwclock --systohc. +# This will also create or update the timestamps in /etc/adjtime. +if [ -x /sbin/hwclock ]; then + # Check for a broken motherboard RTC clock (where ioports for rtc are + # unknown) to prevent hwclock causing a hang: + if ! grep -q " : rtc" /proc/ioports ; then + CLOCK_OPT="--directisa" + fi + if [ /etc/adjtime -nt /etc/hardwareclock ]; then + if grep -q "^LOCAL" /etc/adjtime ; then + echo "Saving system time to the hardware clock (localtime)." + else + echo "Saving system time to the hardware clock (UTC)." + fi + /sbin/hwclock $CLOCK_OPT --systohc + elif grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then + echo "Saving system time to the hardware clock (UTC)." + if [ ! -r /etc/adjtime ]; then + echo "Creating system time correction file /etc/adjtime." + fi + /sbin/hwclock $CLOCK_OPT --utc --systohc + else + echo "Saving system time to the hardware clock (localtime)." + if [ ! -r /etc/adjtime ]; then + echo "Creating system time correction file /etc/adjtime." + fi + /sbin/hwclock $CLOCK_OPT --localtime --systohc + fi +fi + +# Run any local shutdown scripts: +if [ -x /etc/rc.d/rc.local_shutdown ]; then + /etc/rc.d/rc.local_shutdown stop +fi + +# Stop mcelog +if [ -x /etc/rc.d/rc.mcelog ]; then + /etc/rc.d/rc.mcelog stop +fi + +# Stop the Samba server: +if [ -x /etc/rc.d/rc.samba ]; then + /etc/rc.d/rc.samba stop +fi + +# Stop avahi: +if [ -x /etc/rc.d/rc.avahidaemon ]; then + /etc/rc.d/rc.avahidaemon stop + /etc/rc.d/rc.avahidnsconfd stop +fi + +# Shut down WireGuard +if [ -x /etc/rc.d/rc.wireguard ]; then + /etc/rc.d/rc.wireguard stop +fi + +# Shut down OpenLDAP: +if [ -x /etc/rc.d/rc.openldap ]; then + /etc/rc.d/rc.openldap stop +fi + +# Shut down the SASL authentication daemon: +if [ -x /etc/rc.d/rc.saslauthd ]; then + /etc/rc.d/rc.saslauthd stop +fi + +# Stop the MySQL database: +if [ -x /etc/rc.d/rc.mysqld -a -r /var/run/mysql/mysql.pid ]; then + /etc/rc.d/rc.mysqld stop +fi + +# Shut down the NFS server: +if [ -x /etc/rc.d/rc.nfsd ]; then + /etc/rc.d/rc.nfsd stop +fi + +# Shut down the SSH server: +if [ -x /etc/rc.d/rc.sshd ]; then + /etc/rc.d/rc.sshd stop +fi + +# Stop the Network Time Protocol daemon: +if [ -x /etc/rc.d/rc.ntpd ]; then + /etc/rc.d/rc.ntpd stop +fi + +# Kill any processes (typically gam) that would otherwise prevent +# unmounting NFS volumes: +unset FUSER_DELAY +for dir in $(/bin/mount | grep -e 'type nfs ' -e 'type nfs4 ' | sed -e 's|.* on ||g' | cut -d ' ' -f 1) ; do + echo "Killing processes holding NFS mount $dir open..." + # Background this to prevent fuser from also blocking shutdown: + /usr/bin/fuser -k -M -m "$dir" & + FUSER_DELAY=5 +done +# If fuser was run, let it have some delay: +if [ ! -z "$FUSER_DELAY" ]; then + sleep $FUSER_DELAY +fi + +# Unmount any NFS, SMB, or CIFS filesystems: +echo "Unmounting remote filesystems:" +/bin/umount -v -a -l -f -r -t nfs,nfs4,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" +# Update PATH hashes: +hash -r + +# Stop D-Bus: +if [ -x /etc/rc.d/rc.messagebus ]; then + /etc/rc.d/rc.messagebus stop +fi + +# Bring down the networking system, but first make sure that this +# isn't a diskless client with the / partition mounted via NFS: +if ! /bin/mount | /bin/grep -q -e 'on / type nfs' -e 'on / type nfs4' ; then + if [ -x /etc/rc.d/rc.inet1 ]; then + /etc/rc.d/rc.inet1 stop + fi +fi + +# In case dhcpcd might have been manually started on the command line, +# look for the .pid file, and shut dhcpcd down if it's found: +if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then + /sbin/dhcpcd -k 1> /dev/null 2> /dev/null + # A little time for /etc/resolv.conf and/or other files to + # restore themselves. + sleep 2 +fi + +# Turn off process accounting: +if [ -x /sbin/accton -a -r /var/log/pacct ]; then + /sbin/accton off +fi + +# Terminate acpid before syslog: +if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit + /etc/rc.d/rc.acpid stop +fi + +# Stop udev: +if [ -x /etc/rc.d/rc.udev ]; then + /etc/rc.d/rc.udev force-stop +fi + +# Kill all remaining processes. +OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon +if [ ! "$1" = "fast" ]; then + echo "Sending all processes the SIGTERM signal." + /sbin/killall5 -15 $OMITPIDS + /bin/sleep 5 + echo "Sending all processes the SIGKILL signal." + /sbin/killall5 -9 $OMITPIDS +fi + +# limetech - let's keep this on the USB flash +# Carry a random seed between reboots. +/usr/sbin/seedrng +cp /var/lib/seedrng/seed.credit /boot/config/random-seed 2>/dev/null + +# Before unmounting file systems write a reboot or halt record to wtmp. +$shutdown_command -w + +# Turn off swap: +if [ ! "$(cat /proc/swaps | wc -l)" = "1" ]; then + echo "Turning off swap." + /sbin/swapoff -a + /bin/sync +fi + +# Unmount local file systems: +# limetech - but not /, /lib, /usr or /boot (yet) +echo "Unmounting local file systems:" +EXCLUDE_TYPES=("proc" "sysfs" "tmpfs" "devtmpfs" "devpts" "nfsd") +EXCLUDE_PATHS=("/" "/lib" "/usr" "/boot") +MOUNTS=$(cat /proc/mounts) +while IFS= read -r line; do + mount_type=$(echo "$line" | awk '{print $3}') + mount_path=$(echo "$line" | awk '{print $2}') + [[ " ${EXCLUDE_TYPES[@]} " =~ " ${mount_type} " ]] && continue + [[ " ${EXCLUDE_PATHS[@]} " =~ " ${mount_path} " ]] && continue + /sbin/umount -v "$mount_path" +done <<< "$MOUNTS" + +# limetech - shut down the unraid driver if started +if /bin/grep -qs 'mdState=STARTED' /proc/mdstat ; then + echo "Stopping md/unraid driver:" + echo "stop" > /proc/mdcmd + if /bin/grep -qs 'mdState=STOPPED' /proc/mdstat ; then + echo "Clean shutdown" + /bin/rm -f /boot/config/forcesync + else + echo "Unclean shutdown - Cannot stop md/unraid driver" + fi +fi + +# This never hurts: +/bin/sync + +# now remount /boot read-only +echo "Remounting /boot read-only:" +/sbin/mount -v -o remount,ro /boot + +echo "Remounting root filesystem read-only:" +/bin/mount -v -n -o remount,ro / + +# sleep 3 fixes problems with some hard drives that don't +# otherwise finish syncing before reboot or poweroff +/bin/sleep 3 + +# This is to ensure all processes have completed on SMP machines: +wait + +if [ -x /sbin/genpowerd ]; then + # See if this is a powerfail situation: + if grep -E -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then + # Signal UPS to shut off the inverter: + /sbin/genpowerd -k + if [ ! $? = 0 ]; then + echo + echo "There was an error signaling the UPS." + echo "Perhaps you need to edit /etc/genpowerd.conf to configure" + echo "the serial line and UPS type." + # Wasting 15 seconds of precious power: + /bin/sleep 15 + fi + fi +fi + +# Now halt (poweroff with APM or ACPI enabled kernels) or reboot. +if [ "$shutdown_command" = "reboot" ]; then + echo "Rebooting." + /sbin/reboot +else + /sbin/poweroff +fi diff --git a/etc/rc.d/rc.K b/etc/rc.d/rc.K new file mode 100755 index 000000000..4330eafcd --- /dev/null +++ b/etc/rc.d/rc.K @@ -0,0 +1,126 @@ +#!/bin/bash +# +# rc.K This file is executed by init when it goes into runlevel +# 1, which is the administrative state. It kills all +# daemons and then puts the system into single user mode. +# Note that the file systems are kept mounted. +# +# Version: @(#)/etc/rc.d/rc.K 3.1415 Sat Jan 13 13:37:26 PST 2001 +# +# Author: Miquel van Smoorenburg +# Modified by: Patrick J. Volkerding +# + +# Set the path. +PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin + +# Load a custom screen font if the user has an rc.font script. +if [ -x /etc/rc.d/rc.font ]; then + /etc/rc.d/rc.font +fi + +# Load any needed keyboard mappings: +if [ -x /etc/rc.d/rc.keymap ]; then + /etc/rc.d/rc.keymap +fi + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + /etc/rc.d/rc.sysvinit +fi + +# Try to turn off quota: +if grep -q quota /etc/fstab ; then + if [ -x /sbin/quotaoff ]; then + echo "Turning off filesystem quotas." + /sbin/quotaoff -a + fi +fi + +# Try to turn off accounting: +if [ -x /sbin/accton -a -r /var/log/pacct ]; then + /sbin/accton off +fi + +# Run any local shutdown scripts: +if [ -x /etc/rc.d/rc.local_shutdown ]; then + /etc/rc.d/rc.local_shutdown stop +fi + +# Stop the Apache web server: +if [ -x /etc/rc.d/rc.httpd ]; then + /etc/rc.d/rc.httpd stop +fi + +# Stop the Samba server: +if [ -x /etc/rc.d/rc.samba ]; then + /etc/rc.d/rc.samba stop +fi + +# Shut down the NFS server: +if [ -x /etc/rc.d/rc.nfsd ]; then + /etc/rc.d/rc.nfsd stop +fi + +# Kill any processes (typically gam) that would otherwise prevent +# unmounting NFS volumes: +unset FUSER_DELAY +for dir in $(/bin/mount | grep -e 'type nfs ' -e 'type nfs4 ' | sed -e 's|.* on ||g' | cut -d ' ' -f 1) ; do + echo "Killing processes holding NFS mount $dir open..." + # Background this to prevent fuser from also blocking shutdown: + /usr/bin/fuser -k -M -m "$dir" & + FUSER_DELAY=5 +done +# If fuser was run, let it have some delay: +if [ ! -z "$FUSER_DELAY" ]; then + sleep $FUSER_DELAY +fi + +# Unmount any NFS, SMB, or CIFS filesystems: +echo "Unmounting remote filesystems:" +/bin/umount -v -a -l -f -r -t nfs,nfs4,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" + +# Shut down PCMCIA devices: +if [ -x /etc/rc.d/rc.pcmcia ] ; then + /etc/rc.d/rc.pcmcia stop + # The cards might need a little extra time here to deactivate: + sleep 5 +fi + +# Terminate acpid before syslog: +if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit + /etc/rc.d/rc.acpid stop +fi + +# Kill all processes. +OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon +echo +echo "Sending all processes the SIGHUP signal." +killall5 -1 $OMITPIDS +echo -n "Waiting for processes to hang up" +for loop in 0 1 2 3 4 5 ; do + sleep 1 + echo -n "." +done +echo +echo "Sending all processes the SIGTERM signal." +killall5 -15 $OMITPIDS +echo -n "Waiting for processes to terminate" +for loop in 0 1 2 3 4 5 ; do + sleep 1 + echo -n "." +done +echo +echo "Sending all processes the SIGKILL signal." +killall5 -9 $OMITPIDS +echo -n "Waiting for processes to exit" +for loop in 0 1 2 3 4 5 ; do + sleep 1 + echo -n "." +done +echo + +# Now go to the single user level +echo "Going to single user mode..." +/sbin/telinit -t 1 1 + diff --git a/etc/rc.d/rc.M b/etc/rc.d/rc.M new file mode 100755 index 000000000..fed372b5f --- /dev/null +++ b/etc/rc.d/rc.M @@ -0,0 +1,255 @@ +#!/bin/bash +# +# 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 1 through 6). It usually does mounting of file +# systems et al. +# +# Version: @(#)/etc/rc.d/rc.M 15.0 Fri Nov 12 18:51:28 UTC 2021 +# +# Author: Fred N. van Kempen, +# Heavily modified by Patrick Volkerding +# +# LimeTech - Modified for Unraid OS + +# Tell the viewers what's going to happen. +echo "Going multiuser..." + +# Update all the shared library links: +if [ -x /sbin/ldconfig ]; then + echo "Updating shared library links: /sbin/ldconfig &" + /sbin/ldconfig & +fi + +# Call the setterm init script to set screen blanking and power management +# defaults: +if [ -x /etc/rc.d/rc.setterm ]; then + /etc/rc.d/rc.setterm +fi + +# Set the hostname: +/bin/hostname $(cat /etc/HOSTNAME) + +# Set the permissions on /var/log/dmesg according to whether the kernel +# permits non-root users to access kernel dmesg information: +if [ -r /proc/sys/kernel/dmesg_restrict ]; then + if [ $(cat /proc/sys/kernel/dmesg_restrict) = 1 ]; then + touch /var/log/dmesg + chmod 640 /var/log/dmesg + fi +else + touch /var/log/dmesg + chmod 644 /var/log/dmesg +fi +# Save the contents of 'dmesg': +/bin/dmesg -s 65536 > /var/log/dmesg + +# Start the system logger. +if [ -x /etc/rc.d/rc.rsyslog ]; then + /etc/rc.d/rc.rsyslog start +fi + +# Update the X font indexes: +if [ -x /usr/bin/fc-cache ]; then + echo "Updating X font indexes: /usr/bin/fc-cache -f &" + /usr/bin/fc-cache -f & +fi + +# Run rc.udev again. This will start udev if it is not already running +# (for example, upon return from runlevel 1), otherwise it will trigger it +# to look for device changes and to generate persistent rules if needed. +if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then + if ! grep -wq nohotplug /proc/cmdline ; then + if [ -x /etc/rc.d/rc.udev ]; then + /etc/rc.d/rc.udev start + fi + fi +fi + +# Initialize the networking hardware. +if [ -x /etc/rc.d/rc.inet1 ]; then + /etc/rc.d/rc.inet1 +fi + +# Start D-Bus: +if [ -x /etc/rc.d/rc.messagebus ]; then + /etc/rc.d/rc.messagebus start +fi + +# Start the session/seat daemon: +if [ -x /etc/rc.d/rc.elogind -a -x /bin/loginctl ]; then + /etc/rc.d/rc.elogind start +elif [ -x /etc/rc.d/rc.consolekit -a -x /usr/sbin/console-kit-daemon ]; then + /etc/rc.d/rc.consolekit start +fi + +# Start Bluetooth: +if [ -x /etc/rc.d/rc.bluetooth ]; then + /etc/rc.d/rc.bluetooth start +fi + +# Start networking daemons: +if [ -x /etc/rc.d/rc.inet2 ]; then + /etc/rc.d/rc.inet2 +fi + +# Mount any additional filesystem types that haven't already been mounted: +mount -a -v 2> /dev/null | grep -v -e "already mounted" -e "ignored" | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep "${dev} " ; done + +# Start the Network Time Protocol daemon: +if [ -x /etc/rc.d/rc.ntpd ]; then + /etc/rc.d/rc.ntpd start +fi + +# Remove stale locks and junk files (must be done after mount -a!) +/bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/.X11-unix/* 2> /dev/null + +# Ensure basic filesystem permissions sanity. +chmod 755 / 2> /dev/null +chmod 1777 /tmp /var/tmp + +# Start ACPI daemon. +if [ -x /etc/rc.d/rc.acpid ]; then + /etc/rc.d/rc.acpid start +fi + +# Enable CPU frequency scaling: +if [ -x /etc/rc.d/rc.cpufreq ]; then + /etc/rc.d/rc.cpufreq start +fi + +# Update any existing icon cache files: +if find /usr/share/icons -maxdepth 2 2> /dev/null | grep -q icon-theme.cache ; then + for theme_dir in /usr/share/icons/* ; do + if [ -r ${theme_dir}/icon-theme.cache ]; then + echo "Updating icon-theme.cache in ${theme_dir}..." + /usr/bin/gtk-update-icon-cache -t -f ${theme_dir} 1> /dev/null 2> /dev/null & + fi + done + # This would be a large file and probably shouldn't be there. + if [ -r /usr/share/icons/icon-theme.cache ]; then + echo "Deleting icon-theme.cache in /usr/share/icons..." + #/usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1> /dev/null 2> /dev/null & + rm -f /usr/share/icons/icon-theme.cache + fi +fi + +# Update mime database: +if [ -x /usr/bin/update-mime-database -a -d /usr/share/mime ]; then + echo "Updating MIME database: /usr/bin/update-mime-database /usr/share/mime &" + /usr/bin/update-mime-database /usr/share/mime 1> /dev/null 2> /dev/null & +fi + +# These GTK+/pango files need to be kept up to date for +# proper input method, pixbuf loaders, and font support. +if [ -x /usr/bin/update-gtk-immodules ]; then + echo "Updating gtk.immodules:" + echo " /usr/bin/update-gtk-immodules &" + /usr/bin/update-gtk-immodules > /dev/null 2>&1 & +fi +if [ -x /usr/bin/update-gdk-pixbuf-loaders ]; then + echo "Updating gdk-pixbuf.loaders:" + echo " /usr/bin/update-gdk-pixbuf-loaders &" + HOME=/root /usr/bin/update-gdk-pixbuf-loaders > /dev/null 2>&1 & +fi +if [ -x /usr/bin/update-pango-querymodules ]; then + echo "Updating pango.modules:" + echo " /usr/bin/update-pango-querymodules &" + /usr/bin/update-pango-querymodules > /dev/null 2>&1 & +fi +if [ -x /usr/bin/glib-compile-schemas ]; then + echo "Compiling GSettings XML schema files:" + echo " /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas &" + /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas >/dev/null 2>&1 & +fi + +# Start dnsmasq, a simple DHCP/DNS server: +if [ -x /etc/rc.d/rc.dnsmasq ]; then + /etc/rc.d/rc.dnsmasq start +fi + +# Start smartd, which monitors the status of S.M.A.R.T. compatible +# hard drives and reports any problems: +if [ -x /etc/rc.d/rc.smartd ]; then + /etc/rc.d/rc.smartd start +fi + +# Turn on process accounting. To enable process accounting, make sure the +# option for BSD process accounting is enabled in your kernel, and then +# create the file /var/log/pacct (touch /var/log/pacct). By default, process +# accounting is not enabled (since /var/log/pacct does not exist). This is +# because the log file can get VERY large. +if [ -x /sbin/accton -a -r /var/log/pacct ]; then + chmod 640 /var/log/pacct + /sbin/accton /var/log/pacct +fi + +# Start crond (Dillon's crond): +if [ -x /etc/rc.d/rc.crond ]; then + /etc/rc.d/rc.crond start +fi + +# Start atd (manages jobs scheduled with 'at'): +if [ -x /etc/rc.d/rc.atd ]; then + /etc/rc.d/rc.atd start +fi + +# Load a custom screen font if the user has an rc.font script. +if [ -x /etc/rc.d/rc.font ]; then + /etc/rc.d/rc.font +fi + +# Load a custom keymap if the user has an rc.keymap script. +if [ -x /etc/rc.d/rc.keymap ]; then + /etc/rc.d/rc.keymap +fi + +# Start the MariaDB database: +if [ -x /etc/rc.d/rc.mysqld ]; then + /etc/rc.d/rc.mysqld start +fi + +# Start the SASL authentication server. This provides SASL +# authentication services for sendmail/postfix: +if [ -x /etc/rc.d/rc.saslauthd ]; then + /etc/rc.d/rc.saslauthd start +fi + +# Start OpenLDAP: +if [ -x /etc/rc.d/rc.openldap ]; then + /etc/rc.d/rc.openldap start +fi + +# Start WireGuard +if [ -x /etc/rc.d/rc.wireguard ]; then + /etc/rc.d/rc.wireguard start +fi + +# Start avahi: +if [ -x /etc/rc.d/rc.avahidaemon ]; then + /etc/rc.d/rc.avahidaemon start + /etc/rc.d/rc.avahidnsconfd start +fi + +# Start Samba (a file/print server for Windows machines). +# Samba can be started in /etc/inetd.conf instead. +if [ -x /etc/rc.d/rc.samba ]; then + /etc/rc.d/rc.samba start +fi + +# Start mcelog +if [ -x /etc/rc.d/rc.mcelog ]; then + /etc/rc.d/rc.mcelog start +fi + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + /etc/rc.d/rc.sysvinit +fi + +# Start the local setup procedure. +if [ -x /etc/rc.d/rc.local ]; then + /etc/rc.d/rc.local +fi + +# All done. diff --git a/etc/rc.d/rc.S b/etc/rc.d/rc.S new file mode 100755 index 000000000..ec8b993ca --- /dev/null +++ b/etc/rc.d/rc.S @@ -0,0 +1,156 @@ +#!/bin/bash +# +# /etc/rc.d/rc.S: System initialization script. +# +# Mostly written by: Patrick J. Volkerding, +# LimeTech - Modified for Unraid OS +# + +PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin + +# Mount /proc if it is not already mounted: +if [ ! -d /proc/sys ]; then + /sbin/mount -v proc /proc -n -t proc 2> /dev/null +fi + +# Mount /sys if it is not already mounted: +if [ ! -d /sys/kernel ]; then + /sbin/mount -v sysfs /sys -n -t sysfs 2> /dev/null +fi + +# The efivarfs filesystem is used for reading and writing EFI variables, such +# as the boot menu entries. By default efivarfs will be mounted read-write on +# the /sys/firmware/efi/efivars directory. To modify this behavior, edit the +# file: /etc/default/efivarfs +# Only try to mount if this directory exists (so the kernel supports efivarfs): +if [ -d /sys/firmware/efi/efivars ]; then + # Only try to mount if efivarfs is not already mounted: + if ! /sbin/mount | /bin/grep -wq efivarfs ; then + # Mount according to /etc/default/efivarfs: + if [ -r /etc/default/efivarfs ]; then + . /etc/default/efivarfs + else # default + EFIVARFS=rw + fi + case "$EFIVARFS" in + 'rw') + /sbin/mount -o rw -t efivarfs none /sys/firmware/efi/efivars + ;; + 'ro') + /sbin/mount -o ro -t efivarfs none /sys/firmware/efi/efivars + ;; + esac + fi +fi + +# If /run exists, mount a tmpfs on it (unless the +# initrd has already done so): +if [ -d /run ]; then + if ! /bin/grep -wq "tmpfs /run tmpfs" /proc/mounts ; then + /sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755,size=32M,nodev,nosuid,noexec + fi +fi + +# limetech - lets mount debugfs +/sbin/mount -v -t debugfs none /sys/kernel/debug + +# limetech - determine if the 'unraidlabel' kernel append parameter was +# provided to override which device is mounted for /boot (default: UNRAID) +UNRAIDLABEL="UNRAID" +UNRAIDROOT= +set -- $(cat /proc/cmdline) +for x in "$@"; do + case "$x" in + unraidlabel=*) + UNRAIDLABEL="${x#unraidlabel=}" + ;; + root=*) + UNRAIDROOT="${x#root=}" + ;; + esac +done + +# limetech - poll for device with $UNRAIDLABEL present, with 30-sec timeout +# this serves to synchronize this script with USB subsystem +abort() { + read -p "$1 - press ENTER key to reboot ..." + echo + /sbin/reboot +} +find_device() { + # find which USB flash device/partition has the indicated label + local i + for i in {1..30} ; do + DEVICE=$(/sbin/blkid -L $UNRAIDLABEL) + [[ -z $DEVICE ]] && sleep 1 || return 0 + done + return 1 +} +echo -n "waiting up to 30 sec for device with label $UNRAIDLABEL to come online ... " +find_device && echo "found $DEVICE" || abort "not found" + +echo "Checking $DEVICE ..." +/sbin/fsck.fat -a -w $DEVICE 2>/dev/null + +/sbin/mount -v -t vfat -o auto,rw,flush,noatime,nodiratime,dmask=77,fmask=177,shortname=mixed $DEVICE /boot || abort "cannot mount $DEVICE" + +# check initial files used to boot +bzcheck () { + local BZFILE=$1 + if [[ -f /boot/config/skipbzcheck ]]; then + echo "Skipping $BZFILE checksum verification" + return + fi + echo "Verifying $BZFILE checksum ..." + [[ ! -f "/boot/$BZFILE" ]] && abort "$BZFILE not present" + local BZFILECHK="$BZFILE.sha256" + [[ ! -f "/boot/$BZFILECHK" ]] && abort "$BZFILECHK not present" + local SUM1=$(/bin/sha256sum /boot/$BZFILE) + local SUM2=$(/bin/cat /boot/$BZFILECHK) + [[ "${SUM1:0:63}" != "${SUM2:0:63}" ]] && abort "$BZFILE checksum error" +} +bzmount () { + local BZFILE=$1 + local MNTDIR=$2 + bzcheck $BZFILE + /bin/mkdir -p /$MNTDIR + /sbin/mount -v -r -t squashfs /boot/$BZFILE /$MNTDIR || abort "cannot mount $BZFILE" + # setup an overlayfs + /bin/mkdir -p /var/local/overlay/$MNTDIR + /bin/mkdir -p /var/local/overlay-work/$MNTDIR + /sbin/mount -v -t overlay overlay -o lowerdir=/$MNTDIR,upperdir=/var/local/overlay/$MNTDIR,workdir=/var/local/overlay-work/$MNTDIR /$MNTDIR +} +if [[ $UNRAIDROOT == "" ]]; then + bzcheck "bzimage" + bzcheck "bzroot" + bzcheck "bzroot-gui" + + bzmount "bzmodules" "lib" + bzmount "bzfirmware" "usr" + + # now that /usr is mounted make /etc/rc.d a symlink + /bin/rm -r /etc/rc.d + /bin/ln -s /usr/local/etc/rc.d /etc + + # move /var/log to a tmpfs + /bin/mv /var/log/* /var/empty + /sbin/mount -t tmpfs -o size=128m,mode=0755 tmpfs /var/log + /bin/mv /var/empty/* /var/log +else + echo "Checking root filesystem" + /sbin/fsck -C -a $UNRAIDROOT + RETVAL=$? + [[ $RETVAL -ge 2 ]] && abort "fsck failed with return value $RETVAL" + # Remount the root filesystem in read-write mode + echo "Remounting $UNRAIDROOT with read-write enabled." + /sbin/mount -w -v -n -o remount / + RETVAL=$? + [[ $RETVAL -gt 0 ]] && abort "failed to remount $UNRAIDROOT r/w with return value $RETVAL" +fi + +# invoke testing hook +if [[ -f /boot/config/rc.S.extra ]]; then + source /boot/config/rc.S.extra +fi +# and continue in separate script +source /etc/rc.d/rc.S.cont diff --git a/etc/rc.d/rc.S.cont b/etc/rc.d/rc.S.cont new file mode 100755 index 000000000..3a6b9cd05 --- /dev/null +++ b/etc/rc.d/rc.S.cont @@ -0,0 +1,243 @@ +#!/bin/bash +# +# /etc/rc.d/rc.S: System initialization script (continuation) +# +# Mostly written by: Patrick J. Volkerding, +# LimeTech - Modified for Unraid OS +# + +# source'ed by rc.S + +# limetech - bind selected devices to vfio-pci +/usr/local/sbin/vfio-pci 1> /var/log/vfio-pci 2> /var/log/vfio-pci-errors + +# Run the kernel module script. This updates the module dependencies and +# also supports manually loading kernel modules through rc.modules.local. +if [ -x /etc/rc.d/rc.modules ]; then + /etc/rc.d/rc.modules +fi + +# Initialize udev to manage /dev entries and hotplugging. +# You may turn off udev by making the /etc/rc.d/rc.udev file non-executable +# or giving the "nohotplug" option at boot, but realize that if you turn off +# udev that you will have to load all the kernel modules that you need +# yourself (possibly in /etc/rc.d/rc.modules.local), and make any additional +# device nodes that you need in the /dev directory. Even USB and IEEE1394 +# devices will need to have the modules loaded by hand if udev is not used. +# So use it. :-) +if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then + if ! grep -wq nohotplug /proc/cmdline ; then + if [ -x /etc/rc.d/rc.udev ]; then + /etc/rc.d/rc.udev start + fi + fi +fi + +# Mount Control Groups filesystem interface: +if grep -wq cgroup /proc/filesystems ; then + # Christoph H. - Check if unraidcgroup1 is passed over in command line + if grep -wq unraidcgroup1 /proc/cmdline ; then + if [ -d /sys/fs/cgroup ]; then + # See linux-*/Documentation/cgroups/cgroups.txt (section 1.6) + # Check if we have some tools to autodetect the available cgroup controllers + if [ -x /bin/cut -a -x /bin/tail ]; then + # Mount a tmpfs as the cgroup filesystem root + mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup + # Autodetect available controllers and mount them in subfolders + controllers="$(/bin/cut -f 1 /proc/cgroups | /bin/tail -n +2)" + for i in $controllers; do + mkdir /sys/fs/cgroup/$i + mount -t cgroup -o $i $i /sys/fs/cgroup/$i + done + unset i controllers + # Eric S. figured out this needs to go here... + echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy + else + # We can't use autodetection so fall back mounting them all together + mount -t cgroup cgroup /sys/fs/cgroup + fi + else + mkdir -p /dev/cgroup + mount -t cgroup cgroup /dev/cgroup + fi + else + if [ -d /sys/fs/cgroup ]; then + # See https://docs.kernel.org/admin-guide/cgroup-v2.html (section Mounting) + # Mount a tmpfs as the cgroup2 filesystem root + mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup + mount -t cgroup2 none /sys/fs/cgroup + else + mkdir -p /dev/cgroup + mount -t cgroup2 none /dev/cgroup + fi + fi +fi + +# Huge page support: +mount /hugetlbfs + +# Enable swapping: +/sbin/swapon -a 2> /dev/null + +# Set the tick and frequency for the system clock. +# Default values are: TICK=10000 and FREQ=0 +TICK=10000 +FREQ=0 +# If there's a /etc/default/adjtimex config file, source it to override +# the default TICK and FREQ: +if [ -r /etc/default/adjtimex ]; then + . /etc/default/adjtimex +fi +if /sbin/adjtimex --tick $TICK --frequency $FREQ; then + echo "Setting the system clock rate: /sbin/adjtimex --tick $TICK --frequency $FREQ" +else + echo "Failed to set system clock with adjtimex, possibly invalid parameters? (TICK=$TICK FREQ=$FREQ)" +fi + +# Set the system time from the hardware clock using hwclock --hctosys. +if [ -x /sbin/hwclock ]; then + # Check for a broken motherboard RTC clock (where ioports for rtc are + # unknown) to prevent hwclock causing a hang: + if ! grep -q " : rtc" /proc/ioports ; then + CLOCK_OPT="--directisa" + fi + if [ /etc/adjtime -nt /etc/hardwareclock ]; then + if grep -q "^LOCAL" /etc/adjtime ; then + echo -n "Setting system time from the hardware clock (localtime): " + else + echo -n "Setting system time from the hardware clock (UTC): " + fi + /sbin/hwclock $CLOCK_OPT --hctosys + elif grep -wq "^localtime" /etc/hardwareclock 2> /dev/null ; then + echo -n "Setting system time from the hardware clock (localtime): " + /sbin/hwclock $CLOCK_OPT --localtime --hctosys + else + echo -n "Setting system time from the hardware clock (UTC): " + /sbin/hwclock $CLOCK_OPT --utc --hctosys + fi + date +fi + +# Configure ISA Plug-and-Play devices: +if [ -r /etc/isapnp.conf ]; then + if [ -x /sbin/isapnp ]; then + /sbin/isapnp /etc/isapnp.conf + fi +fi + +# Configure kernel parameters: +if [ -x /sbin/sysctl -a -r /etc/sysctl.conf ]; then + echo "Configuring kernel parameters: /sbin/sysctl -e --system" + /sbin/sysctl -e --system +elif [ -x /sbin/sysctl ]; then + echo "Configuring kernel parameters: /sbin/sysctl -e --system" + # Don't say "Applying /etc/sysctl.conf" or complain if the file doesn't exist + /sbin/sysctl -e --system 2> /dev/null | grep -v "Applying /etc/sysctl.conf" +fi + +# Clean up some temporary files: +rm -f /etc/nologin /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \ + /var/state/saslauthd/saslauthd.pid /tmp/.Xauth* 1> /dev/null 2> /dev/null +rm -rf /tmp/{kde-[a-zA-Z]*,ksocket-[a-zA-Z]*,hsperfdata_[a-zA-Z]*,plugtmp*} +if [ -d /var/lib/pkgtools/setup/tmp ]; then + ( cd /var/lib/pkgtools/setup/tmp && rm -rf * ) +elif [ -d /var/log/setup/tmp ]; then + ( cd /var/log/setup/tmp && rm -rf * ) +fi + +# Clear /var/lock/subsys: +if [ -d /var/lock/subsys ]; then + rm -f /var/lock/subsys/* +fi + +# Start libcgroup services: +if [ -x /etc/rc.d/rc.cgconfig -a -x /etc/rc.d/rc.cgred -a -d /sys/fs/cgroup ]; then + /etc/rc.d/rc.cgconfig start ; echo " /usr/sbin/cgconfigparser -l /etc/cgconfig.conf" + /etc/rc.d/rc.cgred start +fi + +# Create /tmp/{.ICE-unix,.X11-unix} if they are not present: +if [ ! -e /tmp/.ICE-unix ]; then + mkdir -p /tmp/.ICE-unix + chmod 1777 /tmp/.ICE-unix +fi +if [ ! -e /tmp/.X11-unix ]; then + mkdir -p /tmp/.X11-unix + chmod 1777 /tmp/.X11-unix +fi + +# Create a fresh utmp file: +touch /var/run/utmp +chown root:utmp /var/run/utmp +chmod 664 /var/run/utmp + +# In case pam_faillock(8) is being used, create the tally directory: +mkdir -p /var/run/faillock + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + /etc/rc.d/rc.sysvinit +fi + +# Run serial port setup script: +# CAREFUL! This can make some systems hang if the rc.serial script isn't +# set up correctly. If this happens, you may have to edit the file from a +# boot disk, and/or set it as non-executable: +if [ -x /etc/rc.d/rc.serial ]; then + /etc/rc.d/rc.serial start +fi + +# limetech - let's keep this on the USB flash +## Carry an entropy pool between reboots to improve randomness. +mkdir -p /var/lib/seedrng +chmod 600 /var/lib/seedrng +cp /boot/config/random-seed /var/lib/seedrng/seed.no-credit 2>/dev/null +/usr/sbin/seedrng + +# limetech - restore hostname from ident.cfg file on flash and ensure hostname is +# defined as localhost alias in /etc/hosts (this lets wins name resolution work) +NAME="Tower" +timeZone="America/Los_Angeles" +if [ -r /boot/config/ident.cfg ]; then + source <(/usr/bin/fromdos < /boot/config/ident.cfg) + NAME=${NAME//[^a-zA-Z\-\.0-9]/\-} +fi +echo "$NAME" >/etc/HOSTNAME +echo "# Generated" >/etc/hosts +echo "127.0.0.1 $NAME localhost" >>/etc/hosts +echo "54.149.176.35 keys.lime-technology.com" >>/etc/hosts + +# limetech - restore the configured timezone +if [ "$timeZone" = "custom" ]; then + ln -sf /boot/config/timezone /etc/localtime +else + ln -sf /usr/share/zoneinfo/$timeZone /etc/localtime +fi + +# limetech - restore password files stored on flash +if [ -r /boot/config/passwd ]; then + while IFS=: read -r username password userid groupid comment homedir cmdshell ; do + if [[ $username = root ]]; then + sed -i "s|^root:.*|root:x:0:0:$comment:/root:/bin/bash|" /etc/passwd + fi + if (( userid >= 1000 )); then + echo "$username:x:$userid:$groupid:$comment:/:/bin/false" >> /etc/passwd + fi + done < /boot/config/passwd + if [ -r /boot/config/shadow ]; then + cp /boot/config/shadow /etc + chmod 600 /etc/shadow + fi +fi +/usr/sbin/pwconv +if [ -r /boot/config/smbpasswd ]; then + cp /boot/config/smbpasswd /var/lib/samba/private +fi +if [ -r /boot/config/secrets.tdb ]; then + cp /boot/config/secrets.tdb /var/lib/samba/private +fi + +# limetech - restore custom rsyslog.conf config file from flash if present +if [ -r /boot/config/rsyslog.conf ]; then + /usr/bin/fromdos /etc/rsyslog.conf +fi diff --git a/etc/rc.d/rc.acpid b/etc/rc.d/rc.acpid new file mode 100755 index 000000000..d6b74e881 --- /dev/null +++ b/etc/rc.d/rc.acpid @@ -0,0 +1,40 @@ +#!/bin/sh +# Start/stop/restart acpid. + +# Start acpid: +acpid_start() { + if [ -x /usr/sbin/acpid -a -d /proc/acpi ]; then + echo "Starting ACPI daemon: /usr/sbin/acpid" + /usr/sbin/acpid + fi +} + +# Stop acpid: +acpid_stop() { + if [ -r /var/run/acpid.pid ]; then + kill $(cat /var/run/acpid.pid) + else + killall acpid + fi +} + +# Restart acpid: +acpid_restart() { + acpid_stop + sleep 1 + acpid_start +} + +case "$1" in +'start') + acpid_start + ;; +'stop') + acpid_stop + ;; +'restart') + acpid_restart + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.atd b/etc/rc.d/rc.atd new file mode 100755 index 000000000..d91990897 --- /dev/null +++ b/etc/rc.d/rc.atd @@ -0,0 +1,39 @@ +#!/bin/sh +# /etc/rc.d/rc.atd - start/stop the at daemon + +# To change the default options, edit /etc/default/atd. +if [ -r /etc/default/atd ]; then + . /etc/default/atd +fi + +start_atd() { + if ! /usr/bin/pgrep --ns $$ --euid daemon -f "^/usr/sbin/atd" 1> /dev/null 2> /dev/null ; then + echo "Starting atd: /usr/sbin/atd $ATD_OPTS" + /usr/sbin/atd $ATD_OPTS + fi +} + +stop_atd() { + echo "Stopping atd." + /usr/bin/pkill --ns $$ --euid daemon -f "^/usr/sbin/atd" 2> /dev/null +} + +restart_atd() { + stop_atd + sleep 1 + start_atd +} + +case "$1" in +'start') + start_atd + ;; +'stop') + stop_atd + ;; +'restart') + restart_atd + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.bind b/etc/rc.d/rc.bind new file mode 100644 index 000000000..169db8126 --- /dev/null +++ b/etc/rc.d/rc.bind @@ -0,0 +1,136 @@ +#!/bin/sh +# Start/stop/restart the BIND name server daemon (named). + +# Start BIND. By default this will run with user "named". If you'd like to +# change this or other options, see: /etc/default/named + +# You might also consider running BIND in a "chroot jail", +# a discussion of which may be found in +# /usr/doc/Linux-HOWTOs/Chroot-BIND-HOWTO. + +# One last note: rndc has a lot of other nice features that it is not +# within the scope of this start/stop/restart script to support. +# For more details, see "man rndc" or just type "rndc" to see the options. + +# Load command defaults: +if [ -f /etc/default/named ] ; then . /etc/default/named ; fi +if [ -f /etc/default/rndc ] ; then . /etc/default/rndc ; fi + +# In case /etc/default/named was missing, provide fallbacks: +if [ -z "$NAMED_USER" ]; then + NAMED_USER="named" +fi +if [ -z "$NAMED_GROUP" ]; then + NAMED_GROUP="named" +fi +if [ -z "$NAMED_OPTIONS" ]; then + NAMED_OPTIONS="-u $NAMED_USER" +fi + +# Sanity check. If /usr/sbin/named is missing then it +# doesn't make much sense to try to run this script: +if [ ! -x /usr/sbin/named ]; then + echo "/etc/rc.d/rc.bind: no /usr/sbin/named found (or not executable); cannot start." + exit 1 +fi + +# Start BIND. As many times as you like. ;-) +# Seriously, don't run "rc.bind start" if BIND is already +# running or you'll get more than one copy running. +bind_start() { + # Make sure /var/run/named exists: + mkdir -p /var/run/named + # Make sure that /var/run/named has correct ownership: + chown -R ${NAMED_USER}:${NAMED_GROUP} /var/run/named + # Make sure that /var/named has correct ownership: + chown -R ${NAMED_USER}:${NAMED_GROUP} /var/named + if [ -r /etc/rndc.key ]; then + # Make sure that /etc/rndc.key has correct ownership: + chown ${NAMED_USER}:${NAMED_GROUP} /etc/rndc.key + fi + # Start named: + if [ -x /usr/sbin/named ]; then + echo "Starting BIND: /usr/sbin/named $NAMED_OPTIONS" + /usr/sbin/named $NAMED_OPTIONS + sleep 1 + fi + # Make sure that named started: + if ! ps axc | grep -q named ; then + echo "WARNING: named did not start." + echo "Attempting to start named again: /usr/sbin/named $NAMED_OPTIONS" + /usr/sbin/named $NAMED_OPTIONS + sleep 1 + if ps axc | grep -q named ; then + echo "SUCCESS: named started." + else + echo "FAILED: Sorry, a second attempt to start named has also failed." + echo "There may be a configuration error that needs fixing. Good luck!" + fi + fi +} + +# Stop all running copies of BIND (/usr/sbin/named): +bind_stop() { + # If you've set up rndc, we can use this to make shutting down BIND faster. + # If you have /etc/rndc.conf, or you have /etc/rndc.key, or $RNDC_OPTIONS is + # not empty, we'll try it. + if [ -r /etc/rndc.conf -o -r /etc/rndc.key -o ! -z "$RNDC_OPTIONS" ]; then + if [ -z "$RNDC_OPTIONS" ]; then + echo "Stopping BIND: /usr/sbin/rndc stop" + else + echo "Stopping BIND: /usr/sbin/rndc $RNDC_OPTIONS stop" + fi + /usr/sbin/rndc $RNDC_OPTIONS stop + # Wait for up to $TIMEOUT seconds before moving on to try killall: + TIMEOUT=${TIMEOUT:-10} + while [ "$TIMEOUT" -gt "0" ]; do + # Exit the timeout loop if there are no named processes: + if ! ps axco command | grep -q -e "^named$"; then + break + fi + sleep 1 + TIMEOUT=$(expr $TIMEOUT - 1) + done + fi + # Kill named processes if there are any running: + if ps axco command | grep -q -e "^named$"; then + echo "Stopping all named processes in this namespace: /bin/killall -SIGTERM --ns \$\$ named" + /bin/killall -SIGTERM --ns $$ named 2> /dev/null + fi +} + +# Reload BIND: +bind_reload() { + /usr/sbin/rndc $RNDC_OPTIONS reload +} + +# Restart BIND: +bind_restart() { + bind_stop + bind_start +} + +# Get BIND status: +bind_status() { + /usr/sbin/rndc $RNDC_OPTIONS status +} + +case "$1" in +'start') + bind_start + ;; +'stop') + bind_stop + ;; +'reload') + bind_reload + ;; +'restart') + bind_restart + ;; +'status') + bind_status + ;; +*) + echo "usage $0 start|stop|reload|restart|status" +esac diff --git a/etc/rc.d/rc.cgconfig b/etc/rc.d/rc.cgconfig new file mode 100644 index 000000000..ad75f2057 --- /dev/null +++ b/etc/rc.d/rc.cgconfig @@ -0,0 +1,202 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-only +# +# Start/Stop the workload manager +# +# Copyright IBM Corporation. 2008 +# +# Authors: Balbir Singh +# +# cgconfig Control Groups Configuration Startup +# chkconfig: - 5 95 +# description: This script runs the cgconfigparser utility to parse and setup +# the control group filesystem. It uses /etc/cgconfig.conf +# and parses the configuration specified in there. + +### BEGIN INIT INFO +# Provides: cgconfig +# Required-Start: +# Required-Stop: +# Should-Start: ypbind +# Should-Stop: ypbind +# Short-Description: Create and setup control group filesystem(s) +# Description: Create and setup control group filesystem(s) +### END INIT INFO + +# get correct location of binaries from configure +sbindir=${exec_prefix}/sbin +CGCONFIGPARSER_BIN=$sbindir/cgconfigparser +CONFIG_FILE=/etc/cgconfig.conf +CONFIG_DIR=/etc/cgconfig.d +servicename=cgconfig + + +lockfile=/run/lock/subsys/$servicename + +# read the config +CREATE_DEFAULT=yes +if [ -e /etc/sysconfig/cgconfig ]; then + # shellcheck disable=SC1091 + source /etc/sysconfig/cgconfig +fi + +lockfiledir=$(dirname "$lockfile") + +create_default_groups() { + defaultcgroup= + + if [ -f /etc/cgrules.conf ]; then + # shellcheck disable=SC2034 + read -r user ctrl defaultcgroup <<< \ + "$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)" + if [[ ( -n "$defaultcgroup" ) && ( "$defaultcgroup" = "*" ) ]]; then + echo "/etc/cgrules.conf incorrect" + echo "Overriding it" + defaultcgroup= + fi + fi + + if [[ -z "$defaultcgroup" ]] + then + defaultcgroup=sysdefault/ + fi + + # + # Find all mounted subsystems and create comma-separated list + # of controllers. + # + controllers=$(lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//) + + # + # Create the default group, ignore errors when the default group + # already exists. + # + cgcreate -f 664 -d 775 -g "$controllers":"$defaultcgroup" 2>/dev/null + + # + # special rule for cpusets + # + if echo "$controllers" | grep -q -w cpuset; then + cpus=$(cgget -nv -r cpuset.cpus /) + cgset -r cpuset.cpus="$cpus $defaultcgroup" + mems=$(cgget -nv -r cpuset.mems /) + cgset -r cpuset.mems="$mems $defaultcgroup" + fi + + # + # Classify everything to default cgroup. Ignore errors, some processes + # may exit after ps is run and before cgclassify moves them. + # + cgclassify -g "$controllers:$defaultcgroup $(ps --no-headers -eL o tid)" \ + 2>/dev/null || : +} + +start() { + printf "Starting %s service: " "$servicename" + if [[ -f "$lockfile" ]]; then + echo "lock file already exists" + return 0 + fi + + if [[ ! -s "$CONFIG_FILE" ]]; then + echo $CONFIG_FILE "is not configured" + return 6 + fi + + + if ! "$CGCONFIGPARSER_BIN" -l "$CONFIG_FILE" -L "$CONFIG_DIR" + then + echo "Failed to parse " "$CONFIG_FILE" "or" "$CONFIG_DIR"'/*' + return 1 + fi + + if [ $CREATE_DEFAULT = "yes" ]; then + create_default_groups + fi + + if ! mkdir -p "$lockfiledir" ; then + echo "Failed to mkdir $lockfiledir directory" + return 1 + fi + + + if ! touch "$lockfile" ; then + echo "Failed to touch $lockfile" + return 1 + fi + echo "Started $servicename" + return 0 +} + +stop() { + printf "Stopping %s service is not supported!: " "$servicename" + echo "Failed to stop $servicename" + return 1 +} + +trapped() { + # + # Do nothing + # + true +} + +usage() { + echo "$0 " + exit 2 +} + +common() { + # + # main script work done here + # + trap "trapped ABRT" ABRT + trap "trapped QUIT" QUIT + trap "trapped TERM" TERM + trap "trapped INT" INT +} + +restart() { + common + stop + start +} + +RETVAL=0 + +case $1 in + 'stop') + common + stop + RETVAL=$? + ;; + 'start') + common + start + RETVAL=$? + ;; + 'restart'|'reload') + restart + RETVAL=$? + ;; + 'condrestart') + if [[ -f "$lockfile" ]]; then + restart + RETVAL=$? + fi + ;; + 'status') + if [ -f "$lockfile" ]; then + echo "Running" + exit 0 + else + echo "Stopped" + exit 3 + fi + ;; + *) + usage + ;; +esac + +exit $RETVAL diff --git a/etc/rc.d/rc.cgred b/etc/rc.d/rc.cgred new file mode 100644 index 000000000..6df2a6315 --- /dev/null +++ b/etc/rc.d/rc.cgred @@ -0,0 +1,170 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-only +# +# Start/Stop the CGroups Rules Engine Daemon +# +# Copyright Red Hat Inc. 2008 +# +# Authors: Steve Olivieri +# +# cgred CGroups Rules Engine Daemon +# chkconfig: - 14 86 +# description: This is a daemon for automatically classifying processes \ +# into cgroups based on UID/GID. +# +# processname: cgrulesengd +# pidfile: /var/run/cgred.pid +# +### BEGIN INIT INFO +# Provides: cgrulesengd +# Required-Start: $local_fs $syslog $cgconfig +# Required-Stop: $local_fs $syslog +# Should-Start: +# Should-Stop: +# Short-Description: start and stop the cgroups rules engine daemon +# Description: CGroup Rules Engine is a tool for automatically using \ +# cgroups to classify processes +### END INIT INFO + +sbindir=${exec_prefix}/sbin +CGRED_BIN=$sbindir/cgrulesengd + +# Sanity checks +[[ -x $CGRED_BIN ]] || exit 1 + +# +# Source LSB routines +# +SYSLIBFILE=/etc/rc.d/init.d/functions +OLDSYSLIBFILE=/etc/init.d/functions +if [[ -x $SYSLIBFILE ]] ; then + # shellcheck disable=SC1090 + source $SYSLIBFILE +elif [[ -x $OLDSYSLIBFILE ]] ; then + # shellcheck disable=SC1090 + source $OLDSYSLIBFILE + log_warning_msg() ( warning "$@" ; printf "\n" 1>&2 ; ) + log_failure_msg() ( failure "$@" ; printf "\n" 1>&2 ; ) + log_success_msg() ( success "$@" ; printf "\n" 1>&2 ; ) +else + log_warning_msg() ( printf "warning:%s\n" "$@" 1>&2 ;) + log_failure_msg() ( printf "failure:%s\n" "$@" 1>&2 ;) + log_success_msg() ( printf "success:%s\n" "$@" 1>&2 ;) +fi + +# Read in configuration options. +if [[ -f "/etc/cgred.conf" ]] ; then + # shellcheck disable=SC1091 + source /etc/cgred.conf + OPTIONS="$NODAEMON $LOG" + if [[ -n "$LOG_FILE" ]]; then + OPTIONS="$OPTIONS --logfile=$LOG_FILE" + fi + if [[ -n "$SOCKET_USER" ]]; then + OPTIONS="$OPTIONS -u $SOCKET_USER" + fi + if [[ -n "$SOCKET_GROUP" ]]; then + OPTIONS="$OPTIONS -g $SOCKET_GROUP" + fi +else + OPTIONS="" +fi + +# For convenience +processname=cgrulesengd +servicename=cgred +lockfile="/var/lock/subsys/$servicename" +pidfile=/var/run/cgred.pid + +start() +{ + echo -n $"Starting CGroup Rules Engine Daemon: " + if [[ -f "$lockfile" ]]; then + echo "$servicename is already running with PID $(cat ${pidfile})" + return 0 + fi + num=$(grep "cgroup" /proc/mounts | awk '$3=="cgroup"' | wc -l) + if [[ "$num" -eq 0 ]]; then + echo + echo $"Cannot find cgroups, is cgconfig service running?" + return 1 + fi + daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS + retval=$? + echo + if [[ $retval -ne 0 ]]; then + return 7 + fi + if ! touch "$lockfile"; then + return 1 + fi + pidof "$processname" > $pidfile + return 0 +} + +stop() +{ + echo -n $"Stopping CGroup Rules Engine Daemon..." + if [[ ! -f $pidfile ]]; then + #log_success_msg + return 0 + fi + killproc -p $pidfile -TERM "$processname" + retval=$? + echo + if [[ $retval -ne 0 ]]; then + return 1 + fi + rm -f "$lockfile" "$pidfile" + return 0 +} + +RETVAL=0 + +# See how we are called +case "$1" in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + status) + status -p $pidfile $servicename + RETVAL=$? + ;; + restart) + stop + start + RETVAL=$? + ;; + condrestart) + if [[ -f "$lockfile" ]]; then + stop + start + RETVAL=$? + fi + ;; + reload|flash) + if [[ -f "$lockfile" ]]; then + echo $"Reloading rules configuration..." + kill -s 12 "$(cat ${pidfile})" + RETVAL=$? + #if [[ $RETVAL -eq 0 ]] ; then + # log_success_msg "" + #else + # log_failure_msg "" + #fi + else + echo "$servicename is not running." + fi + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" + RETVAL=2 + ;; +esac + +exit $RETVAL diff --git a/etc/rc.d/rc.dnsmasq b/etc/rc.d/rc.dnsmasq new file mode 100755 index 000000000..f19a17239 --- /dev/null +++ b/etc/rc.d/rc.dnsmasq @@ -0,0 +1,43 @@ +#!/bin/sh +# Start/stop/restart dnsmasq (a small DNS/DHCP server): + +# Start dnsmasq: +dnsmasq_start() { + if [ -x /usr/sbin/dnsmasq ]; then + echo "Starting dnsmasq: /usr/sbin/dnsmasq" + /usr/sbin/dnsmasq + fi +} + +# Stop dnsmasq: +dnsmasq_stop() { + # Try to use the .pid file first: + if pgrep -l -F /var/run/dnsmasq.pid 2> /dev/null | grep -q dnsmasq ; then + echo "Stopping dnsmasq." + pkill -F /var/run/dnsmasq.pid 2> /dev/null + else # kill any dnsmasq processes in this namespace: + echo "Stopping dnsmasq." + killall --ns $$ dnsmasq 2> /dev/null + fi +} + +# Restart dnsmasq: +dnsmasq_restart() { + dnsmasq_stop + sleep 1 + dnsmasq_start +} + +case "$1" in +'start') + dnsmasq_start + ;; +'stop') + dnsmasq_stop + ;; +'restart') + dnsmasq_restart + ;; +*) + echo "usage rc.dnsmasq: start|stop|restart" +esac diff --git a/etc/rc.d/rc.font b/etc/rc.d/rc.font new file mode 100644 index 000000000..be204a10f --- /dev/null +++ b/etc/rc.d/rc.font @@ -0,0 +1,6 @@ +#!/bin/bash +# +# This selects your default screen font from among the ones in +# /usr/share/kbd/consolefonts. +# +setfont -v diff --git a/etc/rc.d/rc.inetd b/etc/rc.d/rc.inetd new file mode 100755 index 000000000..9fe141974 --- /dev/null +++ b/etc/rc.d/rc.inetd @@ -0,0 +1,36 @@ +#!/bin/sh +# Start/stop/restart inetd, the BSD Internet super-daemon. + +# Start inetd: +inetd_start() { + if [ -x /usr/sbin/inetd ]; then + echo "Starting Internet super-server daemon: /usr/sbin/inetd" + /usr/sbin/inetd + fi +} + +# Stop inetd: +inetd_stop() { + killall inetd +} + +# Restart inetd: +inetd_restart() { + inetd_stop + sleep 1 + inetd_start +} + +case "$1" in +'start') + inetd_start + ;; +'stop') + inetd_stop + ;; +'restart') + inetd_restart + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.ip_forward b/etc/rc.d/rc.ip_forward new file mode 100755 index 000000000..1fa6b57cd --- /dev/null +++ b/etc/rc.d/rc.ip_forward @@ -0,0 +1,100 @@ +#!/bin/sh +# /etc/rc.d/rc.ip_forward: start/stop IP packet forwarding +# +# If you intend to run your Linux box as a router, i.e. as a +# computer that forwards and redistributes network packets, you +# will need to enable IP packet forwarding in your kernel. +# +# To activate IP packet forwarding at boot time, make this +# script executable: chmod 755 /etc/rc.d/rc.ip_forward +# +# To disable IP packet forwarding at boot time, make this +# script non-executable: chmod 644 /etc/rc.d/rc.ip_forward + +# Start IP packet forwarding: +ip_forward_start() { + if [ -f /proc/sys/net/ipv4/ip_forward ]; then + echo "Activating IPv4 packet forwarding." + echo 1 > /proc/sys/net/ipv4/ip_forward + # Changing /proc/sys/net/ipv4/ip_forward results in resetting all + # non-default ipv4 parameters for the interface as mentioned in + # /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we + # will reapply any ipv4 sysctl parameters now: + if [ -r /etc/sysctl.conf ]; then + /bin/grep ipv4 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null + fi + fi + if [ -f /proc/sys/net/ipv6/conf/all/forwarding ]; then + echo "Activating IPv6 packet forwarding." + echo 1 > /proc/sys/net/ipv6/conf/all/forwarding + # Changing /proc/sys/net/ipv6/conf/all/forwarding results in resetting + # all non-default ipv6 parameters for the interface as mentioned in + # /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we + # will reapply any ipv6 sysctl parameters now: + if [ -r /etc/sysctl.conf ]; then + /bin/grep ipv6 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null + fi + fi + # When using IPv4 packet forwarding, you will also get the + # rp_filter, which automatically rejects incoming packets if the + # routing table entry for their source address doesn't match the + # network interface they're arriving on. This has security + # advantages because it prevents the so-called IP spoofing, + # however it can pose problems if you use asymmetric routing + # (packets from you to a host take a different path than packets + # from that host to you) or if you operate a non-routing host + # which has several IP addresses on different interfaces. To + # turn rp_filter off, uncomment the lines below: + #if [ -r /proc/sys/net/ipv4/conf/all/rp_filter ]; then + # echo "Disabling rp_filter." + # echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter + #fi +} + +# Stop IP packet forwarding: +ip_forward_stop() { + if [ -f /proc/sys/net/ipv4/ip_forward ]; then + echo "Disabling IPv4 packet forwarding." + echo 0 > /proc/sys/net/ipv4/ip_forward + # Changing /proc/sys/net/ipv4/ip_forward results in resetting all + # non-default ipv4 parameters for the interface as mentioned in + # /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we + # will reapply any ipv4 sysctl parameters now: + if [ -r /etc/sysctl.conf ]; then + /bin/grep ipv4 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null + fi + fi + if [ -f /proc/sys/net/ipv6/conf/all/forwarding ]; then + echo "Disabling IPv6 packet forwarding." + echo 0 > /proc/sys/net/ipv6/conf/all/forwarding + # Changing /proc/sys/net/ipv6/conf/all/forwarding results in resetting + # all non-default ipv6 parameters for the interface as mentioned in + # /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we + # will reapply any ipv6 sysctl parameters now: + if [ -r /etc/sysctl.conf ]; then + /bin/grep ipv6 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null + fi + fi +} + +# Restart IP packet forwarding: +ip_forward_restart() { + ip_forward_stop + sleep 1 + ip_forward_start +} + +case "$1" in +'start') + ip_forward_start + ;; +'stop') + ip_forward_stop + ;; +'restart') + ip_forward_restart + ;; +*) + echo "usage $0 start|stop|restart" +esac + diff --git a/etc/rc.d/rc.kadmind b/etc/rc.d/rc.kadmind new file mode 100644 index 000000000..2f838a7c4 --- /dev/null +++ b/etc/rc.d/rc.kadmind @@ -0,0 +1,40 @@ +#!/bin/sh +# Start the Kerberos administration server. This typically runs on the +# master Kerberos server, which stores the KDC database. + +# To change the default options, edit /etc/default/kadmind. +if [ -r /etc/default/kadmind ]; then + . /etc/default/kadmind +fi + +start_atd() { + if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/kadmind" 1> /dev/null 2> /dev/null ; then + echo "Starting kadmind: /usr/sbin/kadmind $KADMIND_OPTIONS" + /usr/sbin/kadmind $KADMIND_OPTIONS + fi +} + +stop_atd() { + echo "Stopping kadmind." + /usr/bin/pkill --ns $$ --euid root -f "^/usr/sbin/kadmind" 2> /dev/null +} + +restart_atd() { + stop_atd + sleep 1 + start_atd +} + +case "$1" in +'start') + start_atd + ;; +'stop') + stop_atd + ;; +'restart') + restart_atd + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.kpropd b/etc/rc.d/rc.kpropd new file mode 100644 index 000000000..8dde85d87 --- /dev/null +++ b/etc/rc.d/rc.kpropd @@ -0,0 +1,41 @@ +#!/bin/sh +# Start the Kerberos V5 slave KDC update server. This runs on a slave +# (secondary) KDC server. It allows the master Kerberos server to use +# kprop(8) to propagate its database to the slave servers. + +# To change the default options, edit /etc/default/kpropd. +if [ -r /etc/default/kpropd ]; then + . /etc/default/kpropd +fi + +start_atd() { + if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/kpropd" 1> /dev/null 2> /dev/null ; then + echo "Starting kpropd: /usr/sbin/kpropd $KPROPD_OPTIONS" + /usr/sbin/kpropd $KPROPD_OPTIONS + fi +} + +stop_atd() { + echo "Stopping kpropd." + /usr/bin/pkill --ns $$ --euid root -f "^/usr/sbin/kpropd" 2> /dev/null +} + +restart_atd() { + stop_atd + sleep 1 + start_atd +} + +case "$1" in +'start') + start_atd + ;; +'stop') + stop_atd + ;; +'restart') + restart_atd + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.krb5kdc b/etc/rc.d/rc.krb5kdc new file mode 100644 index 000000000..5e9baef1a --- /dev/null +++ b/etc/rc.d/rc.krb5kdc @@ -0,0 +1,41 @@ +#!/bin/sh +# Start krb5kdc, which is the Kerberos version 5 Authentication Service +# and Key Distribution Center (AS/KDC). This needs to run first on both +# master and secondary KDCs. + +# To change the default options, edit /etc/default/krb5kdc. +if [ -r /etc/default/krb5kdc ]; then + . /etc/default/krb5kdc +fi + +start_atd() { + if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/krb5kdc" 1> /dev/null 2> /dev/null ; then + echo "Starting krb5kdc: /usr/sbin/krb5kdc $KRB5KDC_OPTIONS" + /usr/sbin/krb5kdc $KRB5KDC_OPTIONS + fi +} + +stop_atd() { + echo "Stopping krb5kdc." + /usr/bin/pkill --ns $$ --euid root -f "^/usr/sbin/krb5kdc" 2> /dev/null +} + +restart_atd() { + stop_atd + sleep 1 + start_atd +} + +case "$1" in +'start') + start_atd + ;; +'stop') + stop_atd + ;; +'restart') + restart_atd + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.loop b/etc/rc.d/rc.loop new file mode 100755 index 000000000..6d15a60f8 --- /dev/null +++ b/etc/rc.d/rc.loop @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Load the loop device kernel module. +# + +if modinfo loop 1> /dev/null 2> /dev/null ; then + if ! lsmod | grep -wq "^loop" ; then + modprobe loop + fi +fi + diff --git a/etc/rc.d/rc.messagebus b/etc/rc.d/rc.messagebus new file mode 100755 index 000000000..9a1ffce9f --- /dev/null +++ b/etc/rc.d/rc.messagebus @@ -0,0 +1,81 @@ +#!/bin/sh +# +# messagebus: The D-BUS systemwide message bus +# +# description: This is a daemon which broadcasts notifications of system events \ +# and other messages. See http://www.freedesktop.org/software/dbus/ +# +# processname: dbus-daemon + +# This is a modified version of the rc.messagebus script distributed with the +# dbus sources. Thanks to Don Tanner of the GWare Project +# for most of the work involved --Robby Workman + + +PIDFILE=/var/run/dbus/dbus.pid + +start() { + mkdir -p $(dirname $PIDFILE) + if ! ps -u messagebus -c | grep -wq dbus-daemon; then + rm -f $(dirname $PIDFILE)/* + if [ -x /usr/bin/dbus-uuidgen -a -x /usr/bin/dbus-daemon ] ; then + echo "Starting system message bus: /usr/bin/dbus-uuidgen --ensure ; /usr/bin/dbus-daemon --system" + /usr/bin/dbus-uuidgen --ensure + /usr/bin/dbus-daemon --system 1> /dev/null + fi + fi +} + +stop() { + if [ -e "$PIDFILE" ]; then + echo "Stopping system message bus..." + pid=$(cat $PIDFILE) + kill $pid 1> /dev/null 2> /dev/null + # Just in case: + killall dbus-daemon 1> /dev/null 2> /dev/null + rm -f $PIDFILE + fi +} + +reload() { + echo "Reloading system message bus configuration..." + if [ -e "$PIDFILE" ]; then + pid=$(cat $PIDFILE) + kill -HUP $pid + else + killall -HUP dbus-daemon + fi +} + +status() { + if ps -u messagebus -c | grep -wq dbus-daemon; then + echo "System dbus-daemon is running." + else + echo "System dbus-daemon is stopped." + fi +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + echo "You may need to restart your Window Manager to reconnect to the system dbus." + ;; + reload) + reload + ;; + status) + status + ;; + *) + echo $"Usage: $0 {start|stop|restart|reload|status}" + ;; +esac + diff --git a/etc/rc.d/rc.saslauthd b/etc/rc.d/rc.saslauthd new file mode 100644 index 000000000..0e03710d5 --- /dev/null +++ b/etc/rc.d/rc.saslauthd @@ -0,0 +1,45 @@ +#!/bin/sh +# rc.saslauthd: start/stop/restart saslauthd +# +# saslauthd is a daemon process that handles plaintext authentication +# requests on behalf of the SASL library. The CMU Cyrus SASL library +# is a general purpose authentication library for server and client +# applications. It is mostly used to authenticate to mail servers. +# +# saslauthd should be started from the system boot scripts when going +# to multi-user mode. When running against a protected authentication +# database (e.g. the shadow mechanism), it must be run as the superuser. +# + +saslauthd_start() { + # If saslauthd is not running, start it: + if [ ! -r /var/state/saslauthd/saslauthd.pid ]; then + # Use PAM authentication with credential caching: + echo "Starting SASL authentication daemon: /usr/sbin/saslauthd -a pam -c" + /usr/sbin/saslauthd -a pam -c + fi +} + +saslauthd_stop() { + kill `cat /var/state/saslauthd/saslauthd.pid 2> /dev/null` 2> /dev/null + sleep 1 +} + +saslauthd_restart() { + saslauthd_stop + saslauthd_start +} + +case "$1" in +'start') + saslauthd_start + ;; +'stop') + saslauthd_stop + ;; +'restart') + saslauthd_restart + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/etc/rc.d/rc.serial b/etc/rc.d/rc.serial new file mode 100755 index 000000000..5f31c0194 --- /dev/null +++ b/etc/rc.d/rc.serial @@ -0,0 +1,132 @@ +# +# /etc/rc.serial +# Initializes the serial ports on your system +# +# chkconfig: 2345 50 75 +# description: This initializes the settings of the serial port +# +# FILE_VERSION: 19981128 +# +# Distributed with setserial and the serial driver. We need to use the +# FILE_VERSION field to assure that we don't overwrite a newer rc.serial +# file with a newer one. +# +# XXXX For now, the autosave feature doesn't work if you are +# using the multiport feature; it doesn't save the multiport configuration +# (for now). Autosave also doesn't work for the hayes devices. +# + +RCLOCKFILE=/var/lock/subsys/serial +DIRS="/lib/modules/`uname -r`/misc /lib/modules /usr/lib/modules ." +PATH=/bin:/sbin:/usr/bin +DRIVER=serial +DRIVER_NAME=serial +MODULE_REGEXP="serial\b" + +ALLDEVS="/dev/ttyS?" +if /bin/ls /dev/ttyS?? >& /dev/null ; then + ALLDEVS="$ALLDEVS /dev/ttyS??" +fi + +SETSERIAL="" +if test -x /bin/setserial ; then + SETSERIAL=/bin/setserial +elif test -x /sbin/setserial ; then + SETSERIAL=/sbin/setserial +fi + +# +# See if the serial driver is loaded +# +LOADED="" +if test -f /proc/devices; then + if grep -q " ttyS$" /proc/devices ; then + LOADED="yes" + else + LOADED="no" + fi +fi + +# +# Find the serial driver +# +for i in $DIRS +do + if test -z "$MODULE" -a -f $i/$DRIVER.o ; then + MODULE=$i/$DRIVER.o + fi +done + +if ! test -f /proc/modules ; then + MODULE="" +fi + +# +# Handle System V init conventions... +# +case $1 in +start) + action="start"; + ;; +stop) + action="stop"; + ;; +*) + action="start"; +esac + +if test $action = stop ; then + if test -n ${SETSERIAL} -a "$LOADED" != "no" -a \ + `head -1 /etc/serial.conf`X = "###AUTOSAVE###X" ; then + echo -n "Saving state of serial devices... " + grep "^#" /etc/serial.conf > /etc/.serial.conf.new + ${SETSERIAL} -G -g ${ALLDEVS} >> /etc/.serial.conf.new + mv /etc/serial.conf /etc/.serial.conf.old + mv /etc/.serial.conf.new /etc/serial.conf + echo "done." + fi + if test -n "$MODULE" ; then + module=`grep $MODULE_REGEXP /proc/modules | awk '{print $1}'` + if test -z "$module" ; then + echo "The $DRIVER_NAME driver is not loaded." + rm -f ${RCLOCKFILE} + exit 0 + fi + if rmmod $module ; then :; else + echo "The $DRIVER_NAME driver could NOT be unloaded." + exit 1; + fi + echo "The $DRIVER_NAME driver has been unloaded." + fi + rm -f ${RCLOCKFILE} + exit 0 +fi + +# +# If not stop, it must be a start.... +# + +if test -n "$MODULE" -a "$LOADED" != "yes" ; then + if insmod -f $MODULE $DRIVER_ARG ; then + true + else + echo "Couldn't load $DRIVER_NAME driver." + exit 1 + fi +fi + +if test -f /etc/serial.conf ; then + if test -n ${SETSERIAL} ; then + grep -v ^# < /etc/serial.conf | while read device args + do + if [ ! "$device" = "" -a ! "$args" = "" ]; then + ${SETSERIAL} -z $device $args + fi + done + fi +else + echo "###AUTOSAVE###" > /etc/serial.conf +fi + +touch ${RCLOCKFILE} +${SETSERIAL} -bg ${ALLDEVS} diff --git a/etc/rc.d/rc.smartd b/etc/rc.d/rc.smartd new file mode 100644 index 000000000..8254b3942 --- /dev/null +++ b/etc/rc.d/rc.smartd @@ -0,0 +1,50 @@ +#!/bin/sh +# +# /etc/rc.d/rc.smartd +# +# Start/stop/restart the smartd daemon, which monitors the status of +# S.M.A.R.T. compatible hard drives and reports any problems. +# +# By default, smartd will scan for all ATA/SATA and SCSI/SAS hard drives +# and solid-state drives. Settings may be customized in /etc/smartd.conf. + +# Import script defaults: +if [ -r /etc/default/smartd ]; then + . /etc/default/smartd +fi + +smart_start() { + if [ -x /usr/sbin/smartd -a -r /etc/smartd.conf ]; then + echo "Starting smartd: /usr/sbin/smartd -p /run/smartd.pid $SMARTD_OPTIONS &" + /usr/sbin/smartd -p /run/smartd.pid $SMARTD_OPTIONS & + fi +} + +smart_stop() { + echo "Stopping smartd." + if [ -r /run/smartd.pid ]; then + kill $(cat /run/smartd.pid) + else + killall smartd + fi +} + +smart_restart() { + smart_stop + sleep 1 + smart_start +} + +case "$1" in +'start') + smart_start + ;; +'stop') + smart_stop + ;; +'restart') + smart_restart + ;; +*) + echo "Usage: $0 {start|stop|restart}" +esac diff --git a/etc/rc.d/rc.sshd b/etc/rc.d/rc.sshd index f3c4ca8c3..3cecab880 100755 --- a/etc/rc.d/rc.sshd +++ b/etc/rc.d/rc.sshd @@ -28,11 +28,11 @@ sshd_start() { # make sure ssh dir exists on flash mkdir -p $SSH_BOOT # restore saved keys, config file, etc. (but not subdirs) - cp $SSH_BOOT/* $SSH_ETC &>/dev/null - chmod 600 $SSH_ETC/* &>/dev/null + cp $SSH_BOOT/* $SSH_ETC 2>/dev/null + chmod 600 $SSH_ETC/* 2>/dev/null # create host keys if needed and copy any newly generated key(s) back to flash ssh-keygen -A - cp -n $SSH_ETC/ssh_host*_key* $SSH_BOOT/ + cp -n $SSH_ETC/ssh_host*_key* $SSH_BOOT/ 2>/dev/null # build configuration build_ssh # start daemon diff --git a/etc/rc.d/rc.sysvinit b/etc/rc.d/rc.sysvinit new file mode 100755 index 000000000..4cbd873ef --- /dev/null +++ b/etc/rc.d/rc.sysvinit @@ -0,0 +1,56 @@ +#!/bin/bash +# +# rc.sysvinit This file provides basic compatibility with SystemV style +# startup scripts. The SystemV style init system places +# start/stop scripts for each runlevel into directories such as +# /etc/rc.d/rc3.d/ (for runlevel 3) instead of starting them +# from /etc/rc.d/rc.M. This makes for a lot more init scripts, +# and a more complicated execution path to follow through if +# something goes wrong. For this reason, Slackware has always +# used the traditional BSD style init script layout. +# +# However, many binary packages exist that install SystemV +# init scripts. With rc.sysvinit in place, most well-written +# startup scripts will work. This is primarily intended to +# support commercial software, though, and probably shouldn't +# be considered bug free. +# +# Written by Patrick Volkerding , 1999 +# from an example by Miquel van Smoorenburg . + +# Run an init script: +startup() { + case "$1" in + *.sh) + sh "$@" + ;; + *) + "$@" + ;; + esac +} + +# Set onlcr to avoid staircase effect. +stty onlcr 0>&1 + +if [ "$runlevel" = "" ]; then + runlevel=$RUNLEVEL + export runlevel + prevlevel=$PREVLEVEL + export prevlevel +fi + +# Run kill scripts: +for script in /etc/rc.d/rc$runlevel.d/K* ; do + if [ -x $script ]; then + startup $script stop + fi +done + +# Now do the startup scripts: +for script in /etc/rc.d/rc$runlevel.d/S* ; do + if [ -x $script ]; then + startup $script start + fi +done + diff --git a/etc/rc.d/rc.wsdd2 b/etc/rc.d/rc.wsdd2 new file mode 100755 index 000000000..594e1faab --- /dev/null +++ b/etc/rc.d/rc.wsdd2 @@ -0,0 +1,58 @@ +#!/bin/sh +# +# /etc/rc.d/rc.wsdd2 +# +# start/stop/restart the wsdd2 daemon. +# +# To make wsdd2 start automatically at boot make sure this +# file is executable, and add the following entry to rc.local +# after the samba test (uncommented) + +# if [ -x /etc/rc.d/rc.wsdd2 ]; then +# /etc/rc.d/rc.wsdd2 start +# fi + +# you may also add the following entry to rc.local_shutdown +# (uncommented) + +# if [ -x /etc/rc.d/rc.wsdd2 ]; then +# /etc/rc.d/rc.wsdd2 stop +# fi + +wsdd2_start() { + if [ -r /etc/samba/smb.conf -a -x /etc/rc.d/rc.samba -a -x /usr/sbin/wsdd2 ]; then + echo "Starting wsdd2: /usr/bin/wsdd2 -d" + /usr/sbin/wsdd2 -d + elif [ ! -r /etc/samba/smb.conf ]; then + echo "ERROR: samba not configured, so wsdd2 has no service to advertise" + fi +} +wsdd2_stop() { + #check something is running before trying to kill it. + if [ "x`ps -A|grep ' wsdd2'|wc -l`" != "x0" ]; then + killall wsdd2 + fi +} +wsdd2_restart() { + wsdd2_stop + sleep 1 + wsdd2_start +} +case "$1" in +'start') + #we don't want to run this more than once, + #so kill off any instance already running + wsdd2_stop + wsdd2_start + ;; +'stop') + wsdd2_stop + ;; +'restart') + wsdd2_restart + ;; +*) + # default is start + wsdd2_start +esac +