#!/bin/bash # ============================================================================ # DarkForge Linux — System Shutdown # ============================================================================ # /etc/rc.d/rc.shutdown — stops daemons and cleans up before halt/reboot. # ============================================================================ . /etc/rc.conf echo ":: Shutting down..." # --- Stop daemons in reverse order ------------------------------------------ REVERSED=() for daemon in "${DAEMONS[@]}"; do REVERSED=("${daemon}" "${REVERSED[@]}") done for daemon in "${REVERSED[@]}"; do if [ -x "/etc/rc.d/${daemon}" ]; then "/etc/rc.d/${daemon}" stop fi done # --- Save random seed ------------------------------------------------------- dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null # --- Write wtmp shutdown entry ---------------------------------------------- halt -w # --- Deactivate swap -------------------------------------------------------- swapoff -a # --- Unmount filesystems ---------------------------------------------------- echo ":: Unmounting filesystems..." umount -a -r 2>/dev/null # --- Remount root read-only ------------------------------------------------- mount -o remount,ro / echo ":: Shutdown complete"