#!/bin/sh
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
|
|
#
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
# Please add additional copyright information _after_ the line containing
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
|
|
#
|
|
# ROCK Linux: rock-src/target/tor/fixedfiles/system
|
|
# ROCK Linux is Copyright (C) 1998 - 2007 Clifford Wolf
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version. A copy of the GNU General Public
|
|
# License can be found at Documentation/COPYING.
|
|
#
|
|
# Many people helped and are helping developing ROCK Linux. Please
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
|
|
# file for details.
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-END ---
|
|
#
|
|
# Desc: System bootup and shutdown
|
|
# Runlevel: 01 rcX rc1 rc2 rc3 rc4 rc5
|
|
#
|
|
|
|
title() {
|
|
local x w="$( stty size 2>/dev/null </dev/tty | cut -d" " -f2 )"
|
|
[ -z "$w" ] && w="$( stty size </dev/console | cut -d" " -f2 )"
|
|
for (( x=1; x<w; x++ )) do echo -n .; done
|
|
echo -e "\e[222G\e[3D v \r\e[36m$* \e[0m"
|
|
error=0
|
|
}
|
|
|
|
status() {
|
|
if [ $error -eq 0 ]
|
|
then
|
|
echo -e "\e[1A\e[222G\e[4D\e[32m :-)\e[0m"
|
|
else
|
|
echo -e "\e[1A\e[222G\e[4D\a\e[1;31m :-(\e[0m"
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
title "Creating valid /etc/mtab ..."
|
|
grep -v "^rootfs " /proc/mounts > /etc/mtab || error=$?
|
|
status
|
|
if [ -f /etc/conf/hardware ] ; then
|
|
. /etc/conf/hardware
|
|
fi
|
|
|
|
if [ -f /etc/conf/devfs ] ; then
|
|
title "Configuring the /dev filesystem ..."
|
|
sh /etc/conf/devfs || error=$?
|
|
status
|
|
fi
|
|
|
|
if [ -d /etc/hotplug ] ; then
|
|
title "Configuring hardware by activating hotplug."
|
|
[ -f /proc/sys/kernel/hotplug ] && \
|
|
echo "/sbin/hotplug" > /proc/sys/kernel/hotplug
|
|
for RC in /etc/hotplug/*.rc; do
|
|
echo -n "[$( basename ${RC%.rc} )] "
|
|
$RC start || error=$?;
|
|
done ; echo
|
|
mkdir -p /var/lock/subsys
|
|
touch /var/lock/subsys/hotplug
|
|
status
|
|
fi
|
|
|
|
title "Loading kernel modules and configuring the kernel."
|
|
if [ -f /etc/conf/kernel ] ; then
|
|
sh /etc/conf/kernel || error=$?
|
|
fi
|
|
|
|
[ -f /etc/conf/clock ] && . /etc/conf/clock
|
|
if [ "$clock_tz" = localtime ] ; then
|
|
status
|
|
|
|
title "Setting kernel clock to local time."
|
|
hwclock --hctosys --localtime || error=$?
|
|
fi
|
|
status
|
|
|
|
if [ "$clock_rtc" ] ; then
|
|
if [ -w /proc/sys/dev/rtc/max-user-freq ] ; then
|
|
title "Setting enhanced real time clock precision to $clock_rtc."
|
|
echo $clock_rtc > /proc/sys/dev/rtc/max-user-freq || error=$?
|
|
status
|
|
fi
|
|
fi
|
|
|
|
title "Setting hostname to $(cat /etc/HOSTNAME)."
|
|
hostname "$(cat /etc/HOSTNAME)" || error=$?
|
|
status
|
|
|
|
mkdir /tmp/.ICE-unix
|
|
chmod 1777 /tmp/.ICE-unix
|
|
|
|
title "Writing /var/log/boot.msg."
|
|
dmesg > /var/log/boot.msg || error=$?
|
|
status
|
|
|
|
if [ -e /etc/default.keymap ] ; then
|
|
title "Setting keyboard mappings."
|
|
mapfile=$( readlink -f /etc/default.keymap )
|
|
loadkeys $mapfile || error=$?
|
|
status
|
|
fi
|
|
|
|
title "Setting keyboard repeat rate and delay time."
|
|
kbd_rate=30; kbd_delay=250
|
|
[ -f /etc/conf/kbd ] && . /etc/conf/kbd
|
|
/usr/bin/kbdrate -r $kbd_rate -d $kbd_delay < /dev/console || error=$?
|
|
status
|
|
|
|
if [ -e /etc/default.vcfont ] ; then
|
|
title "Setting console screen font."
|
|
fontfile=$( readlink -f /etc/default.vcfont )
|
|
setfont $fontfile || error=$?
|
|
status
|
|
fi
|
|
|
|
title "Setting console terminal type and blank interval."
|
|
con_term=linux; con_blank=0
|
|
[ -f /etc/conf/console ] && . /etc/conf/console
|
|
/usr/bin/setterm -term $con_term -blank $con_blank > /dev/console || error=$?
|
|
status
|
|
|
|
title "Setting up loopback networking."
|
|
ip link set lo up || error=$?
|
|
ip addr add 127.0.0.1/8 dev lo || error=$?
|
|
ip route add 127/8 dev lo || error=$?
|
|
status
|
|
|
|
title "Setting overflow UID and GID kernel parameters."
|
|
sysctl -w kernel.overflowuid=$(id -u nobody) > /dev/null || error=$?
|
|
sysctl -w kernel.overflowgid=$(id -g nobody) > /dev/null || error=$?
|
|
status
|
|
|
|
if [ -e /etc/sysctl.conf ] ; then
|
|
title "Reading /etc/sysctl.conf file."
|
|
sysctl -p || error=$?
|
|
status
|
|
fi
|
|
|
|
if [ -e /var/state/random-seed ] ; then
|
|
title "Initializing kernel random number generator."
|
|
cat /var/state/random-seed >/dev/urandom || error=$?
|
|
status
|
|
fi
|
|
|
|
title "Setting mixer devices Master and PCM to 65%."
|
|
/usr/bin/amixer sset PCM 20 >/dev/null 2>&1 || error=$?
|
|
/usr/bin/amixer sset PCM unmute >/dev/null 2>&1 || error=$?
|
|
/usr/bin/amixer sset Master 20 >/dev/null 2>&1 || error=$?
|
|
/usr/bin/amixer sset Master unmute >/dev/null 2>&1 || error=$?
|
|
status
|
|
|
|
title "Configuring Windowmanager"
|
|
{
|
|
grep -q 'vga=0x31A' /proc/cmdline && echo "DesktopBackgroundImage=/usr/share/icewm/rockate_1280x1024.jpg" >> /usr/share/icewm/preferences
|
|
grep -q 'vga=0x317' /proc/cmdline && echo "DesktopBackgroundImage=/usr/share/icewm/rockate_1024x768.jpg" >> /usr/share/icewm/preferences
|
|
grep -q 'vga=0x314' /proc/cmdline && echo "DesktopBackgroundImage=/usr/share/icewm/rockate_800x600.jpg" >> /usr/share/icewm/preferences
|
|
grep -q 'vga=0x311' /proc/cmdline && echo "DesktopBackgroundImage=/usr/share/icewm/rockate_640x480.jpg" >> /usr/share/icewm/preferences
|
|
}
|
|
status
|
|
;;
|
|
|
|
stop)
|
|
title "Unconfiguring hardware by de-activating hotplug."
|
|
for RC in /etc/hotplug/*.rc; do
|
|
echo -n "[$( basename ${RC%.rc} )] "
|
|
$RC stop || error=$?;
|
|
done ; echo
|
|
rm -f /var/lock/subsys/hotplug
|
|
status
|
|
|
|
title "Sending all processes a SIGTERM (15)."
|
|
killall5 -15 || error=$? ; sleep 5
|
|
status
|
|
|
|
title "Sending all processes a 2nd SIGTERM (15)."
|
|
killall5 -15 || error=$? ; sleep 5
|
|
status
|
|
|
|
title "Sending all processes a SIGKILL (9)."
|
|
killall5 -9 || error=$? ; sleep 5
|
|
status
|
|
|
|
title "Turning off swap devices."
|
|
swapoff -a || error=$?
|
|
sync ; sleep 1
|
|
status
|
|
|
|
title "Remounting sync/ro and umount filesystems."
|
|
cut -d' ' -f-3 /etc/mtab /proc/mounts | sort -k2 -u -r | \
|
|
while read dev dir fs ; do
|
|
[ "$dir" = "/" ] && continue
|
|
[ "$dir" = "/dev" ] && continue
|
|
[ "$dir" = "/dev/shm" ] && continue
|
|
[ "$dir" = "/proc" ] && continue
|
|
[ "$dir" = "/sys" ] && continue
|
|
[ "$dir" = "/tmp" ] && continue
|
|
echo "Umounting $dev on $dir ($fs)."
|
|
mount -o remount,sync $dir
|
|
mount -o remount,ro $dir
|
|
umount -d $dir
|
|
bash
|
|
done
|
|
status
|
|
|
|
title "Unmounting remaining file systems."
|
|
grep -E -v '^none (/|[a-z]+:) ' /proc/mounts > /etc/mtab
|
|
sync ; sleep 1 ; sync
|
|
umount -vdnra -t nodevfs,proc,sysfs,shm
|
|
mount -vn -o remount,sync /
|
|
mount -vn -o remount,ro /
|
|
sleep 1 ; sync ; sleep 1
|
|
status
|
|
|
|
command=""
|
|
[ "$RUNLEVEL" = 0 ] && command=halt
|
|
[ "$RUNLEVEL" = 6 ] && command=reboot
|
|
if [ -n "$command" ] ; then
|
|
echo "Going to $command the system ..."
|
|
$command -d -f -i -p
|
|
while true ; do sleep 1 ; done
|
|
fi
|
|
;;
|
|
|
|
restart)
|
|
$0 stop; $0 start
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: $0 { start | stop | restart }"
|
|
exit 1
|
|
;;
|
|
|
|
esac
|
|
|
|
exit 0
|