summaryrefslogtreecommitdiff
path: root/init.d.Linux
diff options
context:
space:
mode:
Diffstat (limited to 'init.d.Linux')
-rw-r--r--init.d.Linux/Makefile5
-rwxr-xr-xinit.d.Linux/clock131
-rwxr-xr-xinit.d.Linux/consolefont87
-rwxr-xr-xinit.d.Linux/keymaps80
-rwxr-xr-xinit.d.Linux/modules104
-rwxr-xr-xinit.d.Linux/numlock35
-rwxr-xr-xinit.d.Linux/volumes42
7 files changed, 484 insertions, 0 deletions
diff --git a/init.d.Linux/Makefile b/init.d.Linux/Makefile
new file mode 100644
index 0000000..286266d
--- /dev/null
+++ b/init.d.Linux/Makefile
@@ -0,0 +1,5 @@
+DIR = /etc/init.d
+EXES = clock consolefont keymaps modules numlock volumes
+
+TOPDIR = ..
+include $(TOPDIR)/default.mk
diff --git a/init.d.Linux/clock b/init.d.Linux/clock
new file mode 100755
index 0000000..596b18d
--- /dev/null
+++ b/init.d.Linux/clock
@@ -0,0 +1,131 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+opts="save"
+
+depend() {
+ case "${CLOCK_ADJTIME}" in
+ "") before *;;
+ /etc/*) need checkroot;;
+ *) need localmount;;
+ esac
+}
+
+setupopts() {
+ case "${RC_SYS}" in
+ UML|VPS|XEN)
+ TBLURB="${RC_SYS}"
+ fakeit=1
+ ;;
+ *)
+ case "$(uname -m)" in
+ s390*)
+ TBLURB="s390"
+ fakeit=1
+ ;;
+ *)
+ if [ -e /proc/devices ] && grep -q " cobd$" /proc/devices ; then
+ TBLURB="coLinux"
+ fakeit=1
+ elif [ "${CLOCK}" = "UTC" ] ; then
+ myopts="--utc"
+ TBLURB="UTC"
+ else
+ myopts="--localtime"
+ TBLURB="Local Time"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ [ ${fakeit} -eq 1 ] && return 0
+
+ if [ -z "${CLOCK_ADJTIME}" -o ! -w /etc ] ; then
+ myadj="--noadjfile"
+ else
+ myadj="--adjust"
+ fi
+
+ [ "${SRM}" = "yes" ] && myopts="${myopts} --srm"
+ [ "${ARC}" = "arc" ] && myopts="${myopts} --arc"
+ myopts="${myopts} ${CLOCK_OPTS}"
+
+ # Make sure user isn't using rc.conf anymore.
+ if grep -q "^CLOCK=" /etc/rc.conf ; then
+ ewarn $"CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
+ fi
+
+ # Make sure people set their timezone ... we do it here
+ # even though we don't actually use the variable so that
+ # people see the warning on boot.
+ if [ "${TIMEZONE-Factory}" = "Factory" ] ; then
+ ewarn "Your TIMEZONE in /etc/conf.d/clock is still set to Factory!"
+ fi
+}
+
+start() {
+ local myopts= myadj= TBLURB= fakeit=0 errstr="" retval=0
+
+ if [ -x /sbin/hwclock ] ; then
+ [ -w "${CLOCK_ADJTIME}" ] && echo "0.0 0 0.0" > "${CLOCK_ADJTIME}"
+ fi
+
+ setupopts
+
+ if [ ${fakeit} -ne 1 -a -e /proc/modules -a ! -e /dev/rtc ] ; then
+ modprobe rtc 2>/dev/null || modprobe genrtc 2>/dev/null
+ fi
+
+ ebegin "Setting system clock using the hardware clock" "[${TBLURB}]"
+ if [ ${fakeit} -eq 1 ] ; then
+ ret=0
+ elif [ -x /sbin/hwclock ] ; then
+ # Since hwclock always exit's with a 0, need to check its output.
+ errstr="$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null)"
+ errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
+
+ if [ -n "${errstr}" ] ; then
+ ewarn "${errstr}"
+ ret=1
+ else
+ ret=0
+ fi
+ errstr="Failed to set clock"
+ else
+ ret=1
+ errstr="/sbin/hwclock not found"
+ fi
+ eend ${ret} "${errstr}" "You will need to set the clock yourself"
+
+ return 0
+}
+
+stop() {
+ # Don't tweak the hardware clock on LiveCD halt.
+ [ -n "${CDBOOT}" -o "${CLOCK_SYSTOHC}" != "yes" ] && return 0
+
+ local myopts= myadj= TBLURB= fakeit=0 errstr="" retval=0
+
+ setupopts
+
+ ebegin "Setting hardware clock using the system clock" "[${TBLURB}]"
+ if [ ${fakeit} -eq 1 ] ; then
+ ret=0
+ elif [ -x /sbin/hwclock ] ; then
+ [ -z "$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)" ]
+ ret=$?
+ errstr="Failed to sync clocks"
+ else
+ ret=1
+ errstr="/sbin/hwclock not found"
+ fi
+ eend ${ret} "${errstr}"
+}
+
+save() {
+ CLOCK_SYSTOHC="yes"
+ stop
+}
+
+# vim: set ts=4 :
diff --git a/init.d.Linux/consolefont b/init.d.Linux/consolefont
new file mode 100755
index 0000000..5401a7b
--- /dev/null
+++ b/init.d.Linux/consolefont
@@ -0,0 +1,87 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need localmount
+ need keymaps # sets up terminal encoding scheme
+ after hotplug
+}
+
+start() {
+ # Forget about any font until we are successful
+ rm -rf "${RC_LIBDIR}"/console
+
+ case "${RC_SYS}" in
+ UML|VPS|XEN) return 0 ;;
+ esac
+
+ if [ -z "${CONSOLEFONT}" ] ; then
+ ebegin $"Using the default console font"
+ eend 0
+ return 0
+ fi
+
+ local x= param= sf_param= retval=1
+
+ # Get additional parameters
+ if [ -n "${CONSOLETRANSLATION}" ] ; then
+ param="${param} -m ${CONSOLETRANSLATION}"
+ fi
+ if [ -n "${UNICODEMAP}" ] ; then
+ param="${param} -u ${UNICODEMAP}"
+ fi
+
+ # Set the console font
+ local errmsg=
+ ebegin "Setting user font"
+ if [ -x /bin/setfont ] ; then
+ # We patched setfont to have --tty support ...
+ if [ -n "$(setfont --help 2>&1 | grep -e '--tty')" ] || \
+ [ -n "$(setfont --help 2>&1 | grep -e '-C')" ]
+ then
+ if [ -n "$(setfont --help 2>&1 | grep -e '--tty')" ] ; then
+ sf_param="--tty="
+ else
+ sf_param="-C "
+ fi
+ local ttydev=
+ [ -d /dev/vc ] \
+ && ttydev=/dev/vc/ \
+ || ttydev=/dev/tty
+
+ x=1
+ while [ ${x} -le "${RC_TTY_NUMBER}" ] ; do
+ /bin/setfont ${CONSOLEFONT} ${param} \
+ ${sf_param}/${ttydev}${x} > /dev/null
+ retval=$?
+ x=$((${x} + 1))
+ done
+ else
+ /bin/setfont ${CONSOLEFONT} ${param} > /dev/null
+ retval=$?
+ fi
+ errmsg="Failed to set user font"
+ else
+ retval=1
+ errmsg="/bin/setfont not found"
+ fi
+ eend ${retval} "${errmsg}"
+
+ # Store the last font so we can use it ASAP on boot
+ if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ] ; then
+ mkdir -p "${RC_LIBDIR}"/console
+
+ # Pipe errors to null as maps may not be in use
+ /bin/setfont -o "${RC_LIBDIR}"/console/font 2>/dev/null \
+ || rm -f "${RC_LIBDIR}"/console/font
+ /bin/setfont -om "${RC_LIBDIR}"/console/map 2>/dev/null \
+ || rm -f "${RC_LIBDIR}"/console/map
+ /bin/setfont -ou "${RC_LIBDIR}"/console/unimap 2>/dev/null \
+ || rm -f "${RC_LIBDIR}"/console/unimap
+ fi
+
+ return ${retval}
+}
+
+# vim: set ts=4 :
diff --git a/init.d.Linux/keymaps b/init.d.Linux/keymaps
new file mode 100755
index 0000000..2118ffc
--- /dev/null
+++ b/init.d.Linux/keymaps
@@ -0,0 +1,80 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need localmount
+}
+
+checkconfig() {
+ if [ -z "${KEYMAP}" ] ; then
+ eerror "You need to setup KEYMAP in /etc/conf.d/keymaps first"
+ return 1
+ fi
+
+ # Make sure user isn't using rc.conf anymore
+ if grep -q "^KEYMAP=" /etc/rc.conf ; then
+ ewarn "KEYMAP should not be set in /etc/rc.conf but in /etc/conf.d/keymaps"
+ fi
+}
+
+start() {
+ case "${RC_SYS}" in
+ UML|VPS|XEN)
+ ebegin "Loading key mappings"
+ eend 0
+ return 0
+ ;;
+ esac
+
+ local WINDOWKEYS_KEYMAP=
+
+ checkconfig || return 1
+
+ # Force linux keycodes for PPC.
+ if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ] ; then
+ echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes
+ fi
+
+ # Turn on unicode if user wants it
+ [ "${UNICODE}" = "yes" ] && kbd_mode -u
+
+ ebegin "Loading key mappings"
+ if [ -x /bin/loadkeys ] ; then
+ [ "${SET_WINDOWKEYS}" = "yes" ] && WINDOWKEYS_KEYMAP="windowkeys"
+ loadkeys -q ${WINDOWKEYS_KEYMAP} ${KEYMAP} \
+ ${EXTENDED_KEYMAPS} > /dev/null
+ eend $? "Error loading key mappings"
+ else
+ eend 1 "/bin/loadkeys not found"
+ return 1
+ fi
+
+ # Set terminal encoding to either ASCII or UNICODE.
+ # See utf-8(7) for more information.
+ local termencoding= termmsg=
+ if [ "${UNICODE}" = "yes" ] ; then
+ local dumpkey_opts=
+ [ -n "${DUMPKEYS_CHARSET}" ] && dumpkey_opts="-c ${DUMPKEYS_CHARSET}"
+
+ dumpkeys ${dumpkey_opts} | loadkeys --unicode
+ termencoding="\033%%G"
+ termmsg="UTF-8"
+ else
+ termencoding="\033(K"
+ termmsg="ASCII"
+ fi
+ local n=1 ttydev=
+ [ -d /dev/vc ] \
+ && ttydev=/dev/vc/ \
+ || ttydev=/dev/tty
+ ebegin "Setting terminal encoding to" ${termmsg}
+ while [ ${n} -le "${RC_TTY_NUMBER}" ] ; do
+ printf "${termencoding}" >"${ttydev}${n}"
+ n=$((${n} + 1))
+ done
+ eend 0
+}
+
+
+# vim:ts=4
diff --git a/init.d.Linux/modules b/init.d.Linux/modules
new file mode 100755
index 0000000..ff6faf6
--- /dev/null
+++ b/init.d.Linux/modules
@@ -0,0 +1,104 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need checkroot
+ use isapnp
+}
+
+load_modules() {
+ local modules=""
+ local config="$1"
+
+ [ -z "${config}" -o ! -r "${config}" ] && return 0
+
+ modules=$(sed -e 's:#.*::' -e '/^[[:space:]]*$/d' "${config}")
+ [ -z "${modules}" ] && return 0
+
+ einfo "Using ${config} as config:"
+ eindent
+
+ local x= cnt=0 OIFS=${IFS} SIFS=${IFS-y}
+ IFS=\n
+ for x in ${modules} ; do
+ set -- ${x}
+ ebegin "Loading module $1"
+ modprobe -q "$@" >& /dev/null
+ eend $? "Failed to load $1" && cnt=$((${cnt} + 1))
+ done
+ if [ "${SIFS}" = "y" ] ; then
+ IFS=${save_IFS}
+ else
+ unset IFS
+ fi
+
+ einfo "Autoloaded ${cnt} module(s)"
+
+ return 0
+}
+
+start() {
+ # Should not fail if kernel do not have module
+ # support compiled in ...
+ [ ! -f /proc/modules -o "${RC_SYS}" = "VPS" ] && return 0
+
+ local KV=$(uname -r)
+ local KV_MAJOR=${KV%%.*}
+ local x=${KV#*.}
+ local KV_MINOR=${x%%.*}
+ x=${KV#*.*.}
+ local KV_MICRO=${x%%-*}
+
+ # Make sure depmod from modutils do not whine, but do not bother if
+ # we are on a 2.6 kernel without modprobe.old
+ if [ -z "${CDBOOT}" -a ! -e /etc/modules.conf ] && \
+ [ $(KV_to_int "${KV}") -lt $(KV_to_int '2.5.48') -o -x /sbin/modprobe.old ]
+ then
+ echo '### This file is automatically generated by modules-update' \
+ > /etc/modules.conf 2>/dev/null
+ [ ! -f /etc/modules.conf ] && \
+ ewarn "Cannot update /etc/modules.conf!"
+ fi
+
+ # Only do this if we have modules.conf or a 2.6 kernel
+ if [ -z "${CDBOOT}" ] && \
+ [ -f /etc/modules.conf -o $(KV_to_int "${KV}") -ge $(KV_to_int '2.5.48') ]
+ then
+ /sbin/modules-update
+ fi
+
+ local auto=""
+ if [ -f /etc/modules.autoload -a ! -L /etc/modules.autoload ]; then
+ auto=/etc/modules.autoload
+ else
+ local x= f="/etc/modules.autoload.d/kernel"
+ for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR} ; do
+ if [ -f "${f}-${x}.${RC_SOFTLEVEL}" ] ; then
+ auto="${f}-${x}.${RC_SOFTLEVEL}"
+ break
+ fi
+ if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" -a -f "${f}-${x}.${RC_DEFAULTLEVEL}" ] ; then
+ auto="${f}-${x}.${RC_DEFAULTLEVEL}"
+ break
+ fi
+ if [ -f "${f}-${x}" ] ; then
+ auto="${f}-${x}"
+ break
+ fi
+ done
+ fi
+ [ -n "${auto}" ] && load_modules "${auto}"
+
+ #
+ # Just in case a sysadmin prefers generic symbolic links in
+ # /lib/modules/boot for boot time modules we will load these modules
+ #
+ [ -n "$(modprobe -l -t boot)" ] && modprobe -a -t boot \* 2>/dev/null
+
+ # Above test clobbers the return
+ return 0
+}
+
+
+# vim:ts=4
diff --git a/init.d.Linux/numlock b/init.d.Linux/numlock
new file mode 100755
index 0000000..9597475
--- /dev/null
+++ b/init.d.Linux/numlock
@@ -0,0 +1,35 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need localmount
+}
+
+_setleds() {
+ [ -z "$1" ] && return 1
+
+ local dev=/dev/tty t= i=1 retval=0
+ [ -d /dev/vc ] && dev=/dev/vc/
+
+ while [ ${i} -le ${RC_TTY_NUMBER:-11} ] ; do
+ setleds -D "$1"num < ${dev}${i} || retval=1
+ i=$((${i} + 1))
+ done
+
+ return ${retval}
+}
+
+start() {
+ ebegin "Enabling numlock on ttys"
+ _setleds +
+ eend $? "Failed to enable numlock"
+}
+
+stop() {
+ ebegin "Disabling numlock on ttys"
+ _setleds -
+ eend $? "Failed to disable numlock"
+}
+
+# vim: set ts=4 :
diff --git a/init.d.Linux/volumes b/init.d.Linux/volumes
new file mode 100755
index 0000000..4f2a7f5
--- /dev/null
+++ b/init.d.Linux/volumes
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+VOLUME_ORDER=${VOLUME_ORDER:-${RC_VOLUME_ORDER:-raid evms lvm dm}}
+
+# Dependancy information is in /etc/conf.d/volumes
+
+start() {
+ local x=
+
+ # Start our volumes, RAID, LVM, etc
+ for x in ${VOLUME_ORDER} ; do
+ start_addon "${x}"
+ done
+
+ # Setup dm-crypt mappings if any
+ start_addon dm-crypt
+
+ return 0
+}
+
+stop() {
+ local x= rev=
+
+ # Stop dm-crypt mappings if any
+ stop_addon dm-crypt
+ stop_addon truecrypt
+
+ # Stop our volumes, RAID, LVM, etc
+ for x in ${VOLUME_ORDER} ; do
+ rev="${x} ${rev}"
+ done
+
+ for x in ${rev} ; do
+ stop_addon "${x}"
+ done
+
+ return 0
+}
+
+# vim: set ts=4 :