commit 79b2635d4640ccea0b7454021fab69208d9b174b Author: kueller Date: Mon Jan 3 10:48:06 2011 +0000 Neue Version V963 git-svn-id: svn://svn.compuextreme.de/Viitor/V963/Viitor_upstart@5933 504e572c-2e33-0410-9681-be2bf7408885 diff --git a/etc/init.d/functions b/etc/init.d/functions new file mode 100755 index 0000000..fd2c25b --- /dev/null +++ b/etc/init.d/functions @@ -0,0 +1,416 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source: /export/Data/cvs/Viitor_sysvinit/etc/init.d/functions,v $ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#InitScript zum Start des Daemons: +#Funktionen für die init scripten +#Dieses Script basiert auf der Vorlage des Linuxfromscratch Projetes +# +#Letzte Änderung von: $Author: kueller $ +#Datum der letzten Änderung: $Date: 2004/03/03 12:48:07 $ +#Version der Datei: $Revision: 1.12 $ +# +#$Log: functions,v $ +#Revision 1.12 2004/03/03 12:48:07 kueller +#Header auf neuen Viitor GPL Header umgestellt +# +# +#Revision 1.11 2002/09/30 20:32:22 kueller +#Korrektur der Funktion getmasks - bei nichtvorhandener /etc/netmasks +#bricht die Funktion mit einem [] Fehler ab. Variable FOUND wurde +#in diesem Fall nicht gesetzt. Fehler behoben +# +#Revision 1.10 2002/09/23 20:22:09 hkueller +#Anpassung der Funktionen an BASH - dazu musste jedes typeset kommando +#entfernt werden, da bash keine zahlenumrechnung kann. Durch Neue Funktion +#GetShortMask problem mit short mask angabe bei ip kommando ohne verwendung +#von umrechnungsfunktionen gelöst. +# +#Revision 1.9 2002/09/11 18:16:05 hkueller +#Korrekturen bei der netzmask erkennung unter zsh +# +#Revision 1.8 2002/08/09 07:00:00 hkueller +#getmask vereinfacht und beschleunigt +# +#Revision 1.6 2002/05/05 14:40:08 hkueller +#mit neuem Release wandert basename von /usr/bin nach /bin. functions +#entsprechend angepasst +# +#Revision 1.5 2002/02/05 02:59:04 hkueller +#functions: getbroadcast() hinzugefuegt - gibt broadcast eines Netzes +# zurueck - Aufruf: getbroadcast +# getmask erweitert - keine mask in /etc/netmasks -> +# defaultmask (Class A/B/C) +#networks: Ueberfaelliger eintrag fuer PTP entfernt +# Eintraege zur Konfiguration mit ifconfig hinzugefuegt - aber +# auskommentiert. +# +#Revision 1.4 2001/11/18 21:25:52 kueller +#Korrektur der Aufräumfunktion (sed Regulare Expression) für /etc/netmasks +#(getmask funktion) +# +#Revision 1.3 2001/11/17 23:41:35 kueller +#Network Setup erweitert. Netmasks werden jetzt aus /etc/netmasks erkannt. +#Konfiguration der Netmask in /etc/sysconfig/hostname. nicht mehr +#notwendig! +# +#Revision 1.2 2001/11/17 22:20:33 kueller +#Funktionen dectohex und dectobin zur Umrechnung von dezimalen IP Adressen in +#Binäre bzw. Dezimale Darstellung hinzugefügt. +#Achtung: Diese Funktione funktionieren nur in Verbindung mit der zsh oder +#eine ksh - nicht mit sh oder bash!!!! +# +#Revision 1.1.1.1 2001/09/23 00:02:08 kueller +#Neustart wg. Datenverlust +# +#Revision 1.2 2001/08/25 10:14:28 kueller +# +#Optische Retusche der READY und FAILED Meldungen +# +#Revision 1.1.1.1 2001/08/08 10:02:32 kueller +#sysvinit addons +# +# + +if [ "$COLUMNS" ]; then + (( COL = $COLUMNS - 10 )) +else + COL=70 +fi +SET_COL="/bin/echo -en \\033[${COL}G" +NORMAL="/bin/echo -en \\033[0;39m" +SUCCESS="/bin/echo -en \\033[1;42m" +FAILURE="/bin/echo -en \\033[1;41m" + +evaluate_retval() +{ + if [ $? = 0 ] + then + print_status success + else + print_status failure + fi +} + +print_status() +{ + if [ $# = 0 ] + then + echo "Usage: print_status {success|failure}" + exit 1 + fi + + case "$1" in + success) + $SET_COL + $SUCCESS + echo -n " READY " + $NORMAL + echo "" + ;; + failure) + $SET_COL + $FAILURE + echo -n " FAILED " + $NORMAL + echo "" + ;; + esac + +} + +loadproc() +{ + + if [ $# = 0 ] + then + echo "Usage: loadproc {program}" + exit 1 + fi + + base=`/bin/basename $1` + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + + if [ ! -n "$pid" ] + then + $* + evaluate_retval + else + print_status failure + fi + +} + +killproc() +{ + + if [ $# = 0 ] + then + echo "Usage: killproc {program} [signal]" + exit 1 + fi + + base=`/bin/basename $1` + + if [ "$2" != "" ] + then + killlevel=$2 + else + nolevel=1 + fi + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + + pid="" + + for apid in $pidlist + + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + + if [ -n "$pid" ] + then + if [ "$nolevel" = 1 ] + then + /bin/kill -TERM $pid + if ps h $pid >/dev/null 2>&1 + then + /bin/kill -KILL $pid + fi + /bin/ps h $pid >/dev/null 2>&1 + if [ $? = 0 ] + then + print_status failure + else + /bin/rm -f /var/run/$base.pid + print_status success + fi + else + /bin/kill $killlevel $pid + /bin/ps h $pid >/dev/null 2>&1 + if [ $? = 0 ] + then + print_status failure + else + /bin/rm -f /var/run/$base.pid + print_status success + fi + fi + else + print_status failure + fi +} + +reloadproc() +{ + if [ $# = 0 ] + then + echo "Usage: reloadproc {program} [signal]" + exit 1 + fi + + base=`/bin/basename $1` + + if [ -n "$2" ] + then + killlevel=-$2 + else + nolevel=1 + fi + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + + if [ -n "$pid" ] + then + if [ "$nolevel" = 1 ] + then + /bin/kill -SIGHUP $pid + evaluate_retval + else + /bin/kill -$killlevel $pid + evaluate_retval + fi + else + print_status failure + fi +} + +statusproc() + +{ + if [ $# = 0 ] + then + echo "Usage: status {program}" + return 1 + fi + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + if [ -n "$pid" ] + then + echo "$1 running with Process ID $pid" + return 0 + fi + + if [ -f /var/run/$1.pid ] + then + pid=`/usr/bin/head -1 /var/run/$1.pid` + if [ -n "$pid" ] + then + echo "$1 not running but /var/run/$1.pid exists" + return 1 + fi + else + echo "$i is not running" + fi + +} + +getbroadcast() { + IP=$1 + MASK=$2 + for i in 1 2 3 4; do + IP[$i]=`echo $IP|awk -F. '{print $'$i'}'` + MASK[$i]=`echo $MASK|awk -F. '{print $'$i'}'` + (( BCAST[$i] = ${IP[$i]} | (( ${MASK[$i]} ^ 255 )) )) + done + echo ${BCAST[1]}.${BCAST[2]}.${BCAST[3]}.${BCAST[4]} +} + +getnetaddr() { + IP=$1 + MASK=$2 + for i in 1 2 3 4; do + IPS=`echo $IP|awk -F. '{print $'$i'}'` + MASKS=`echo $MASK|awk -F. '{print $'$i'}'` + (( BCASTS = $IPS & $MASKS )) + if [ "$i" = "4" ]; then + printf "$BCASTS" + else + printf "$BCASTS." + fi + done + echo +} + +getmask() { + IP=$1 + FOUND=0 + if [ -f /etc/netmasks ]; then + sed -e "/^#/d" /etc/netmasks |\ + sed -e "/^ *$/d" >/tmp/if + while read NETADDR NETMASK; do + NETIP=`getnetaddr $IP $NETMASK` + if [ "$NETADDR" = "$NETIP" ]; then + echo $NETMASK + FOUND=1 + break + fi + done /tmp/autofs + exec 3&- + rm /tmp/autofs +} +# End /etc/init.d/functions diff --git a/etc/init.d/rc b/etc/init.d/rc new file mode 100644 index 0000000..4c3a495 --- /dev/null +++ b/etc/init.d/rc @@ -0,0 +1,157 @@ +#!/bin/sh +# Begin /etc/init.d/rc +# +# By Jason Pearce - jason.pearce@linux.org +# Modified by Gerard Beekmans - gerard@linuxfromscratch.org +# print_error_msg based on ideas by Simon Perreault - nomis80@yahoo.com +# +#$Date: 2003-10-22 20:35:29 +0200 (Mi, 22 Okt 2003) $ +#$Revision: 3339 $ +# +#$Log$ +#Revision 1.3 2003/10/22 18:35:29 kueller +#Korrektur von rechtschreibfehlern +# +#Revision 1.2 2003/04/07 10:22:30 kueller +#Fehlermeldungen an CompuExtreme, nicht mehr an RainMaker +# +#Revision 1.1.1.1 2001/09/23 00:02:08 kueller +#Neustart wg. Datenverlust +# +#Revision 1.1.1.1 2001/08/08 10:02:32 kueller +#sysvinit addons +# +# + + +source /etc/init.d/functions + +print_error_msg() +{ + + echo + $FAILURE + echo "Sie sollten diese Fehlermeldung niemals sehen" + echo "Sie bedeutet, das ein unvorhergesehener Fehler" + echo "Aufgetreten ist." + echo "Das Subscript $i ist hat sich mit dem Returnwert" + echo "$error_value beendet." + echo "Bitte melden sie den Fehler der Fa. CompuExtreme" + $NORMAL + echo +} + + +# Un-comment the following for debugging. +# debug=echo + +# +# Start script or program. +# +startup() { +case "$1" in + *.sh) + $debug sh "$@" + ;; + *) + $debug "$@" + ;; +esac +} + +# Ignore CTRL-C only in this shell, so we can interrupt subprocesses. + +trap ":" INT QUIT TSTP + +# Set onlcr to avoid staircase effect. +stty onlcr 0>&1 + +# Now find out what the current and what the previous runlevel are. +runlevel=$RUNLEVEL +# Get first argument. Set new runlevel to this argument. + +[ "$1" != "" ] && runlevel=$1 +if [ "$runlevel" = "" ] +then + echo "Usage: $0 " >&2 + exit 1 +fi + +previous=$PREVLEVEL +[ "$previous" = "" ] && previous=N + +export runlevel previous + +# Is there an rc directory for this new runlevel? + +if [ -d /etc/init.d/rc$runlevel.d ] +then + # First, run the KILL scripts for this runlevel. + if [ $previous != N ] + then + for i in /etc/init.d/rc$runlevel.d/K* + do + [ ! -f $i ] && continue + + suffix=${i#/etc/init.d/rc$runlevel.d/K[0-9][0-9]} + previous_start=/etc/init.d/rc$previous.d/S[0-9][0-9]$suffix + sysinit_start=/etc/init.d/rcS.d/S[0-9][0-9]$suffix + + # Stop the service if there is a start script + # in the previous run level. + [ ! -f $previous_start ] && + [ ! -f $sysinit_start ] && continue + + startup $i stop + error_value=$? + if [ $error_value != 0 ] + then + print_error_msg + fi + + done + fi + + # Now run the START scripts for this runlevel. + for i in /etc/init.d/rc$runlevel.d/S* + do + [ ! -f $i ] && continue + + if [ $previous != N ] + then + # Find start script in previous runlevel and + # stop script in this runlevel. + suffix=${i#/etc/init.d/rc$runlevel.d/S[0-9][0-9]} + stop=/etc/init.d/rc$runlevel.d/K[0-9][0-9]$suffix + previous_start=/etc/init.d/rc$previous.d/S[0-9][0-9]$suffix + + # If there is a start script in the previous + # level + # and _no_ stop script in this level, we don't + # have to re-start the service. + [ -f $previous_start ] && [ ! -f $stop ] && + continue + fi + + case "$runlevel" in + 0|6) + startup $i stop + error_value=$? + if [ $error_value != 0 ] + then + print_error_msg + fi + ;; + *) + startup $i start + error_value=$? + if [ $error_value != 0 ] + then + print_error_msg + fi + ;; + esac + done +fi + +# End /etc/init.d/rc diff --git a/etc/init.d/rcS b/etc/init.d/rcS new file mode 100644 index 0000000..131213a --- /dev/null +++ b/etc/init.d/rcS @@ -0,0 +1,49 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source$ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#InitScript zum Start des Daemons: +#rcS Script des sysvinit Projektes +#Basierend auf einer Vorlage von linuxfromscratch.org +# +#Letzte Änderung von: $Author: kueller $ +#Datum der letzten Änderung: $Date: 2009-03-30 21:53:23 +0200 (Mo, 30 Mär 2009) $ +#Version der Datei: $Revision: 4568 $ +# + +# Begin /etc/init.d/rcS + +runlevel=S +prevlevel=N +umask 022 +export runlevel prevlevel + +trap ":" INT QUIT TSTP + +source /etc/init.d/functions + +for i in /etc/init.d/rcS.d/S??* +do + [ ! -f "$i" ] && continue; + $i start +done + +# End /etc/init.d/rcS diff --git a/etc/init/checkfs.conf b/etc/init/checkfs.conf new file mode 100644 index 0000000..84c1761 --- /dev/null +++ b/etc/init/checkfs.conf @@ -0,0 +1,50 @@ +description "Check Filesystems" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped initlvm + +console output +script + echo "running checkfs" + source /etc/init/functions + if [ ! -f /fastboot ]; then + /bin/mount -n -o remount,ro / + status_message "change / to ro ..." + if [ $? = 0 ]; then + if [ -f /forcefsck ]; then + echo -n "/forcefsck exists, forcing " + echo "file system check" + force="-f" + else + force="" + fi + echo "Checking file systems..." + /sbin/fsck $force -a -A -C -T + + if [ $? -gt 1 ]; then + $FAILURE + echo + echo -n "fsck failed. Please repair your file " + echo "systems manually by running /sbin/fsck" + echo "without the -a option" + echo + echo -n "Please note that the root file system " + echo "is currently mounted in read-only mode." + echo + echo -n "I will start sulogin now. When you " + echo "logout I will reboot your system." + echo + $NORMAL + /sbin/initctl emit stalled + exit 1 + else + print_status success + fi + else + echo -n "Cannot check root file system because it " + echo "could not be mounted in read-only mode." + fi + fi +end script diff --git a/etc/init/checkvar.conf b/etc/init/checkvar.conf new file mode 100644 index 0000000..5fc10e4 --- /dev/null +++ b/etc/init/checkvar.conf @@ -0,0 +1,28 @@ +description "Check if / ist nfs" +author "Harald Kueller " +version 1.0 +emits varmake startudev + + +start on startup + +console output +script + echo "Starting checkvar script" + source /etc/init/functions + mount -o remount,rw / + rm /etc/mtab + touch /etc/mtab + mount -o remount,ro / + mount -t proc none /proc + status_message "/proc mounted" + if mount|grep /dev/root|grep nfs &>/dev/null; then + /sbin/initctl emit varmake + status_message "emitting varmake" + else + umount /proc + mount -t tmpfs none /var/lock + /sbin/initctl emit startudev + status_message "emitting startudev" + fi +end script diff --git a/etc/init/control-alt-delete.conf b/etc/init/control-alt-delete.conf new file mode 100644 index 0000000..590528d --- /dev/null +++ b/etc/init/control-alt-delete.conf @@ -0,0 +1,12 @@ +# control-alt-delete - emergency keypress handling +# +# This task is run whenever the Control-Alt-Delete key combination is +# pressed, and performs a safe reboot of the machine. + +description "emergency keypress handling" +author "Scott James Remnant " + +start on control-alt-delete + +task +exec shutdown -r now "Control-Alt-Delete pressed" diff --git a/etc/init/dbus.conf b/etc/init/dbus.conf new file mode 100755 index 0000000..6f642f9 --- /dev/null +++ b/etc/init/dbus.conf @@ -0,0 +1,27 @@ +description "Startup autofs System for local configuration files" +author "Harald Kueller " +version 1.0 +emits none special + +start on (runlevel [2345] and (started ifup)) +stop on runlevel [016] + +console output + +pre-start script + dbus-uuidgen --ensure + if [ -f /var/run/dbus/system_bus_socket ]; then + rm /var/run/dbus/system_bus_socket + fi +end script + +script + export PATH=$PATH:/usr/X11R7/bin + /usr/bin/dbus-daemon --system --nofork +end script + +post-stop script + if [ -f /var/run/dbus/pid ]; then + rm /var/run/dbus/pid + fi +end script diff --git a/etc/init/functions b/etc/init/functions new file mode 100755 index 0000000..5cfafbe --- /dev/null +++ b/etc/init/functions @@ -0,0 +1,415 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source: /export/Data/cvs/Viitor_sysvinit/etc/init.d/functions,v $ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#InitScript zum Start des Daemons: +#Funktionen für die init scripten +#Dieses Script basiert auf der Vorlage des Linuxfromscratch Projetes +# +#Letzte Änderung von: $Author: kueller $ +#Datum der letzten Änderung: $Date: 2004/03/03 12:48:07 $ +#Version der Datei: $Revision: 1.12 $ +# +#$Log: functions,v $ +#Revision 1.12 2004/03/03 12:48:07 kueller +#Header auf neuen Viitor GPL Header umgestellt +# +# +#Revision 1.11 2002/09/30 20:32:22 kueller +#Korrektur der Funktion getmasks - bei nichtvorhandener /etc/netmasks +#bricht die Funktion mit einem [] Fehler ab. Variable FOUND wurde +#in diesem Fall nicht gesetzt. Fehler behoben +# +#Revision 1.10 2002/09/23 20:22:09 hkueller +#Anpassung der Funktionen an BASH - dazu musste jedes typeset kommando +#entfernt werden, da bash keine zahlenumrechnung kann. Durch Neue Funktion +#GetShortMask problem mit short mask angabe bei ip kommando ohne verwendung +#von umrechnungsfunktionen gelöst. +# +#Revision 1.9 2002/09/11 18:16:05 hkueller +#Korrekturen bei der netzmask erkennung unter zsh +# +#Revision 1.8 2002/08/09 07:00:00 hkueller +#getmask vereinfacht und beschleunigt +# +#Revision 1.6 2002/05/05 14:40:08 hkueller +#mit neuem Release wandert basename von /usr/bin nach /bin. functions +#entsprechend angepasst +# +#Revision 1.5 2002/02/05 02:59:04 hkueller +#functions: getbroadcast() hinzugefuegt - gibt broadcast eines Netzes +# zurueck - Aufruf: getbroadcast +# getmask erweitert - keine mask in /etc/netmasks -> +# defaultmask (Class A/B/C) +#networks: Ueberfaelliger eintrag fuer PTP entfernt +# Eintraege zur Konfiguration mit ifconfig hinzugefuegt - aber +# auskommentiert. +# +#Revision 1.4 2001/11/18 21:25:52 kueller +#Korrektur der Aufräumfunktion (sed Regulare Expression) für /etc/netmasks +#(getmask funktion) +# +#Revision 1.3 2001/11/17 23:41:35 kueller +#Network Setup erweitert. Netmasks werden jetzt aus /etc/netmasks erkannt. +#Konfiguration der Netmask in /etc/sysconfig/hostname. nicht mehr +#notwendig! +# +#Revision 1.2 2001/11/17 22:20:33 kueller +#Funktionen dectohex und dectobin zur Umrechnung von dezimalen IP Adressen in +#Binäre bzw. Dezimale Darstellung hinzugefügt. +#Achtung: Diese Funktione funktionieren nur in Verbindung mit der zsh oder +#eine ksh - nicht mit sh oder bash!!!! +# +#Revision 1.1.1.1 2001/09/23 00:02:08 kueller +#Neustart wg. Datenverlust +# +#Revision 1.2 2001/08/25 10:14:28 kueller +# +#Optische Retusche der READY und FAILED Meldungen +# +#Revision 1.1.1.1 2001/08/08 10:02:32 kueller +#sysvinit addons +# +# + +if [ "$COLUMNS" ]; then + (( COL = $COLUMNS - 10 )) +else + COL=70 +fi +SET_COL="/bin/echo -en \\033[${COL}G" +NORMAL="/bin/echo -en \\033[0;39m" +SUCCESS="/bin/echo -en \\033[1;42m" +FAILURE="/bin/echo -en \\033[1;41m" + +evaluate_retval() +{ + if [ $? = 0 ] + then + print_status success + else + print_status failure + fi +} + +status_message() { + STATUS=$? + Message=$1 + if [ $# = 0 ]; then + echo "Usage: status_message " + fi + echo -n $Message + if [ $STATUS = 0 ]; then + print_status success + else + print_status failure + fi + return 0 + +} + +print_status() +{ + if [ $# = 0 ] + then + echo "Usage: print_status {success|failure}" + exit 1 + fi + + case "$1" in + success) + $SET_COL + $SUCCESS + echo -n " READY " + $NORMAL + echo "" + ;; + failure) + $SET_COL + $FAILURE + echo -n " FAILED " + $NORMAL + echo "" + ;; + esac + +} + +loadproc() +{ + + if [ $# = 0 ] + then + echo "Usage: loadproc {program}" + exit 1 + fi + + base=`/bin/basename $1` + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + + if [ ! -n "$pid" ] + then + $* + status_message "$* ..." + else + print_status failure + fi + +} + +killproc() +{ + + if [ $# = 0 ] + then + echo "Usage: killproc {program} [signal]" + exit 1 + fi + + base=`/bin/basename $1` + + if [ "$2" != "" ] + then + killlevel=$2 + else + nolevel=1 + fi + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + + pid="" + + for apid in $pidlist + + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + + if [ -n "$pid" ] + then + if [ "$nolevel" = 1 ] + then + /bin/kill -TERM $pid + if ps h $pid >/dev/null 2>&1 + then + /bin/kill -KILL $pid + fi + /bin/ps h $pid >/dev/null 2>&1 + if [ $? = 0 ] + then + print_status failure + else + /bin/rm -f /var/run/$base.pid + print_status success + fi + else + /bin/kill $killlevel $pid + /bin/ps h $pid >/dev/null 2>&1 + if [ $? = 0 ] + then + print_status failure + else + /bin/rm -f /var/run/$base.pid + print_status success + fi + fi + else + print_status failure + fi +} + +reloadproc() +{ + if [ $# = 0 ] + then + echo "Usage: reloadproc {program} [signal]" + exit 1 + fi + + base=`/bin/basename $1` + + if [ -n "$2" ] + then + killlevel=-$2 + else + nolevel=1 + fi + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + + if [ -n "$pid" ] + then + if [ "$nolevel" = 1 ] + then + /bin/kill -SIGHUP $pid + evaluate_retval + else + /bin/kill -$killlevel $pid + evaluate_retval + fi + else + print_status failure + fi +} + +statusproc() + +{ + if [ $# = 0 ] + then + echo "Usage: status {program}" + return 1 + fi + + pidlist=`/bin/pidof $base|sed -e "s/$$//"|sed -e "s/$PPID//"` + if [ -n "$pid" ] + then + echo "$1 running with Process ID $pid" + return 0 + fi + + if [ -f /var/run/$1.pid ] + then + pid=`/usr/bin/head -1 /var/run/$1.pid` + if [ -n "$pid" ] + then + echo "$1 not running but /var/run/$1.pid exists" + return 1 + fi + else + echo "$i is not running" + fi + +} + +getbroadcast() { + IP=$1 + MASK=$2 + for i in 1 2 3 4; do + IP[$i]=`echo $IP|awk -F. '{print $'$i'}'` + MASK[$i]=`echo $MASK|awk -F. '{print $'$i'}'` + (( BCAST[$i] = ${IP[$i]} | (( ${MASK[$i]} ^ 255 )) )) + done + echo ${BCAST[1]}.${BCAST[2]}.${BCAST[3]}.${BCAST[4]} +} + +getnetaddr() { + IP=$1 + MASK=$2 + for i in 1 2 3 4; do + IPS=`echo $IP|awk -F. '{print $'$i'}'` + MASKS=`echo $MASK|awk -F. '{print $'$i'}'` + (( BCASTS = $IPS & $MASKS )) + if [ "$i" = "4" ]; then + printf "$BCASTS" + else + printf "$BCASTS." + fi + done + echo +} + +getmask() { + IP=$1 + FOUND=0 + if [ -f /etc/netmasks ]; then + sed -e "/^#/d" /etc/netmasks |\ + sed -e "/^ *$/d" >/tmp/if + while read NETADDR NETMASK; do + NETIP=`getnetaddr $IP $NETMASK` + if [ "$NETADDR" = "$NETIP" ]; then + echo $NETMASK + FOUND=1 + break + fi + done " +version 1.0 +emits none special + +start on ( runlevel [0] and ( stopped udev )) + +console output +script + echo "System reboot in progress..." + /sbin/halt -f -p +end script diff --git a/etc/init/hostname.conf b/etc/init/hostname.conf new file mode 100644 index 0000000..6ad44fe --- /dev/null +++ b/etc/init/hostname.conf @@ -0,0 +1,19 @@ +description "Setup System Hostname" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [S012345] and ( started udev )) + +console none +script + echo "setting up hostname" + source /etc/init/functions + if [ -f /etc/sysconfig/nodename ]; then + /bin/hostname `cat /etc/sysconfig/nodename` + status_message "Hostname set to $HOSTNAME" + else + /bin/hostname "localhost" + status_message "Hostname set to $HOSTNAME" + fi +end script diff --git a/etc/init/hotplug.conf b/etc/init/hotplug.conf new file mode 100644 index 0000000..d33363a --- /dev/null +++ b/etc/init/hotplug.conf @@ -0,0 +1,16 @@ +description "Startup Hotplug Service" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped virtualfs + +script + echo "starting hotplug scripts" + source /etc/init/functions + for RC in /etc/hotplug/*.rc; do + $RC start + done + touch /var/lock/subsys/hotplug + status_message "hotplug startup ready" +end script diff --git a/etc/init/ifdown.conf b/etc/init/ifdown.conf new file mode 100644 index 0000000..e7c73eb --- /dev/null +++ b/etc/init/ifdown.conf @@ -0,0 +1,16 @@ +description "Shutdown all network interfaces without Loopback" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopping udev + +console output + +script + echo "Stopping network" + for IF in `ls -d /sys/class/net/*[^lo]`; do + DEVNAME=`basename $IF` + /sbin/if_down $DEVNAME + done +end script diff --git a/etc/init/ifup.conf b/etc/init/ifup.conf new file mode 100644 index 0000000..f2907be --- /dev/null +++ b/etc/init/ifup.conf @@ -0,0 +1,34 @@ +description "Setup all configured Network Interfaces" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (stopped maccfg)) + +console output + +script + echo "Configuring network" + for IF in `ls -d /sys/class/net/*[^lo]`; do + DEVNAME=`basename $IF` + /sbin/if_up $DEVNAME + done +end script + +post-start script + if [ ! -f /var/run/net_up ] && [ -f /etc/nsswitch.default ]; then + cp /etc/nsswitch.files /etc/nsswitch.conf + touch /var/state/ldap_disable + else + if [ ! -f /var/run/nsswitch_done ] && [ -f /etc/nsswitch.default ]; then + cp /etc/nsswitch.default /etc/nsswitch.conf + touch /var/state/ldap_disable + fi + if [ -f /var/run/net_up ]; then + rm /var/run/net_up + fi + if [ -f /var/run/nsswitch.done ]; then + rm /var/run/nsswitch.done + fi + fi +end script diff --git a/etc/init/initlvm.conf b/etc/init/initlvm.conf new file mode 100644 index 0000000..ae2c4b0 --- /dev/null +++ b/etc/init/initlvm.conf @@ -0,0 +1,20 @@ +description "Initialize Logical Volume Manager (LVM)" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped virtualfs + +console output +script + echo "Initializing volumes" + source /etc/init/functions + if [ -f /sbin/vgscan ]; then + /sbin/vgscan >/dev/null 2>&1 + status_message "Scanning of Volumes....." + for i in `vgdisplay|grep "VG Name"|awk '{print $3}'`; do + vgchange -a y $i + status_message "Volume Aktivation of $i ..." + done + fi +end script diff --git a/etc/init/klogd.conf b/etc/init/klogd.conf new file mode 100644 index 0000000..d488d15 --- /dev/null +++ b/etc/init/klogd.conf @@ -0,0 +1,13 @@ +description "Startup Kernel Logging daemon" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [12345] and (stopped mountfs)) +stop on ( runlevel [06] and (stopping udev)) + +pre-start script + echo "Starting kernel log daemon" +end script + +exec /usr/sbin/klogd -n -f /var/log/kern.log diff --git a/etc/init/loadkeys.conf b/etc/init/loadkeys.conf new file mode 100644 index 0000000..8dbe4ca --- /dev/null +++ b/etc/init/loadkeys.conf @@ -0,0 +1,22 @@ +description "Load System default Keymap" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped mountfs + +console output +script + echo "Loading Keymap" + source /etc/init/functions + if [ -f /etc/sysconfig/kbd/setkeys ]; then + exec 3&- + fi + /usr/bin/loadkeys -d >/dev/null + status_message "Loaded Keymap ..." +end script diff --git a/etc/init/loadmodules.conf b/etc/init/loadmodules.conf new file mode 100644 index 0000000..e7f8323 --- /dev/null +++ b/etc/init/loadmodules.conf @@ -0,0 +1,21 @@ +description "Force load of special Modules defined in /etc/sysconfig/loadmods" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [12345] and ( started udev )) + +pre-start script + echo "Loading additional modules" + source /etc/init/functions + if [ -f /etc/sysconfig/loadmods ]; then + sed -e "/^#/d" /etc/sysconfig/loadmods | + sed -e "/^ *$/d" >/tmp/loadmods + exec 3" +version 1.0 +emits none special + +start on ( runlevel [S012345] and ( started udev )) + +console output + +script + echo "Setting up localhost" + source /etc/init/functions + /sbin/ifconfig lo 127.0.0.1 up + status_message "Setup local net..." +end script diff --git a/etc/init/maccfg.conf b/etc/init/maccfg.conf new file mode 100644 index 0000000..74e6122 --- /dev/null +++ b/etc/init/maccfg.conf @@ -0,0 +1,17 @@ +description "Special MAC Address Setup based on /etc/mactab*" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (stopped mountfs)) + +console output + +script + if ls /etc/mactab* &>/dev/null; then + for maccfg in /etc/mactab*; do + nameif -c $maccfg >/dev/null + done + status_message "Setup of mac adresses" + fi +end script diff --git a/etc/init/mountfs.conf b/etc/init/mountfs.conf new file mode 100644 index 0000000..6d80f52 --- /dev/null +++ b/etc/init/mountfs.conf @@ -0,0 +1,47 @@ +description "Mounting all Filesystem not depending on Network" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped checkfs + +console output +script + source /etc/init/functions + /bin/mount -n -o remount,rw / + status_message "Remount of / to rw" + /bin/rm -f /fastboot /forcefsck + /sbin/swapon -a + status_message "Swap Aktivated" + POINTS=`sed -e "/^#/d" -e "/^$/d" /etc/fstab|\ + awk '{if ( ( $2 != "/" ) && \ + ( $3 != "swap" ) && \ + ( $3 != "nfs" ) ) print $2 }'` + Do_Mount=1 + FOUND=0 + MP_DEPTH=1 + while [ $Do_Mount -eq 1 ]; do + for i in $POINTS; do + DEPTH=`echo $i|awk -F"/" '{print NF-1}'` + if [ $DEPTH == $MP_DEPTH ]; then + if [ ! -d $i ]; then + mkdir -p $i + fi + mount $i & + status_message "Mount of $i" + FOUND=1 + fi + done + wait `pgrep /bin/mount` + if [ $FOUND -eq 0 ]; then + Do_Mount=0 + else + FOUND=0 + (( MP_DEPTH++ )) + fi + done + /sbin/ldconfig + if [ -f /var/run/utmp ]; then + cp /dev/null /var/run/utmp + fi +end script diff --git a/etc/init/mountnfs.conf b/etc/init/mountnfs.conf new file mode 100644 index 0000000..c7b029d --- /dev/null +++ b/etc/init/mountnfs.conf @@ -0,0 +1,20 @@ +description "Mounting NFS Filesystems" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (started nfsclient)) + +console output + +script + source /etc/init/functions + for i in `sed -e "/^#/d" /etc/fstab|awk '{print $2}'`; do + MOUNTPOINT=$i + FILESYSTEM=`awk '{if( $2 == "'$MOUNTPOINT'") print $3}' /etc/fstab` + if [ "$FILESYSTEM" == "nfs" ]; then + mount $MOUNTPOINT + status_message "Mount nfs Filesystem on $MOUNTPOINT" + fi + done +end script diff --git a/etc/init/nfsroot.conf b/etc/init/nfsroot.conf new file mode 100644 index 0000000..46faa8c --- /dev/null +++ b/etc/init/nfsroot.conf @@ -0,0 +1,38 @@ +description "Special Handling for nfs / (root) Filesystem" +author "Harald Kueller " +version 1.0 +emits none special + +start on varmake + +console output +script + source /etc/init/functions + mount -t tmpfs none /var + status_message "Mount tmpfs on /var" + ifconfig|\ + grep Protokoll|\ + awk '{ if ( $2 == "Protokoll:Ethernet" ) print $1 }' >/var/devices + for i in `cat /var/devices`; do + INET=`ifconfig $i|\ + grep inet|\ + awk -F ":" '{print $2}'|\ + awk '{print $1}'` + ANET=`echo $INET|awk -F "." '{print $1}'` + if [ ! "$ANET" == "127" ]; then + HOSTNAME=`getent hosts $INET` + HOSTNAME=`echo $HOSTNAME|\ + awk '{print $2}'|\ + awk -F "." '{print $1}'` + break + fi + done + status_message "Getting Hostname $HOSTNAME.." + cd /var + tar -zxf /boot/var_${HOSTNAME}.tgz + echo $HOSTNAME >etc/sysconfig/nodename + cd - + status_message "Restore of /var folder" + umount /proc + /sbin/initctl mount_virtual +end script diff --git a/etc/init/nscd.conf b/etc/init/nscd.conf new file mode 100644 index 0000000..deffb86 --- /dev/null +++ b/etc/init/nscd.conf @@ -0,0 +1,12 @@ +description "Startup nscd" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [12345] and (stopped routing)) +stop on (runlevel [06] and stopping udev) + +console none + +respawn +exec /usr/sbin/nscd -f /etc/nscd.conf -d diff --git a/etc/init/reboot.conf b/etc/init/reboot.conf new file mode 100644 index 0000000..99c3262 --- /dev/null +++ b/etc/init/reboot.conf @@ -0,0 +1,11 @@ +description "Force a reboot after all daemons are down" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [6] and ( stopped udev )) + +script + echo "System reboot in progress..." + /sbin/reboot -f +end script diff --git a/etc/init/routing.conf b/etc/init/routing.conf new file mode 100644 index 0000000..ef0261c --- /dev/null +++ b/etc/init/routing.conf @@ -0,0 +1,41 @@ +description "Setup Routing depending on several config files" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped ifup + +console output + +script + source /etc/init/functions + if [ ! -f /etc/sysconfig/net/notrouter ]; then + echo "Configuring System with routing allowed" + if [ -f /etc/sysconfig/net/gateways ]; then + sed -e "/^#/d" /etc/sysconfig/net/gateways | \ + sed -e "/^ *$/d" >/tmp/gateways + exec 3&- + rm /tmp/gateways + fi + if [ -f /etc/sysconfig/net/defaultrouter ]; then + /sbin/route add default gw `cat /etc/sysconfig/net/defaultrouter` + status_message "Default Router set to `cat /etc/sysconfig/net/defaultrouter`" + fi + NUMIF=`/sbin/ip -f inet addr show|/bin/grep inet|/bin/grep -v "host lo"|wc -l` + if [ $NUMIF -gt 2 ]; then + echo "1" >/proc/sys/net/ipv4/ip_forward + status_message "Enable of ip_forwarding" + fi + fi +end script diff --git a/etc/init/sendsignals.conf b/etc/init/sendsignals.conf new file mode 100644 index 0000000..7ca55b2 --- /dev/null +++ b/etc/init/sendsignals.conf @@ -0,0 +1,13 @@ +description "Send all remaining prozesses the kill signal" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopped udev + +script + echo -n "sending all remaining processes the TERM signal" + killall -15 + sleep 3 + killall -9 +end script diff --git a/etc/init/setclock.conf b/etc/init/setclock.conf new file mode 100644 index 0000000..1c83fd7 --- /dev/null +++ b/etc/init/setclock.conf @@ -0,0 +1,19 @@ +description "Set Clock from hw System clock" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [12345] and (started mountfs)) + +console output +script + source /etc/init/functions + CLOCKPARAMS="--hctosys" + case "$UTC" in + yes|true|1) + CLOCKPARAMS="$CLOCKPARAMS -u" + ;; + esac + /sbin/hwclock $CLOCKPARAMS + status_message "Load of hwclock..." +end script diff --git a/etc/init/sulogin.conf b/etc/init/sulogin.conf new file mode 100644 index 0000000..03823a1 --- /dev/null +++ b/etc/init/sulogin.conf @@ -0,0 +1,18 @@ +# sulogin - rescue mode +# +# This task ensures that should the system fail to have any active jobs +# that the system administrator can rescue it; by giving them a shell. + +start on stalled + +exec /sbin/sulogin +console owner + +pre-start script + echo + echo "The system has reached a state where there are no jobs running." + echo "A shell will be spawned so that you may start such jobs that are" + echo "necessary." + echo + echo "Type 'exit' when finished." +end script diff --git a/etc/init/syslogd.conf b/etc/init/syslogd.conf new file mode 100644 index 0000000..511086f --- /dev/null +++ b/etc/init/syslogd.conf @@ -0,0 +1,12 @@ +description "Startup Syslog" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [12345] and (stopped routing)) +stop on (runlevel [06] and stopping udev) + +console none + +respawn +exec /usr/sbin/syslogd -n -m 0 diff --git a/etc/init/tty1.conf b/etc/init/tty1.conf new file mode 100644 index 0000000..45ea3a1 --- /dev/null +++ b/etc/init/tty1.conf @@ -0,0 +1,10 @@ +description "Startup login getty on tty1" +author "Harald Kueller " +version 1.0 +emits none special + +start on runlevel [2345] +stop on runlevel [016] + +respawn +exec /sbin/agetty /dev/tty1 9600 diff --git a/etc/init/tty2.conf b/etc/init/tty2.conf new file mode 100644 index 0000000..be69cd3 --- /dev/null +++ b/etc/init/tty2.conf @@ -0,0 +1,10 @@ +description "Startup login getty on tty2" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and ( started udev )) +stop on ( runlevel [016] and ( stopping udev )) + +respawn +exec /sbin/agetty /dev/tty2 9600 diff --git a/etc/init/tty3.conf b/etc/init/tty3.conf new file mode 100644 index 0000000..b4ec6b4 --- /dev/null +++ b/etc/init/tty3.conf @@ -0,0 +1,10 @@ +description "Startup login getty on tty3" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (started udev)) +stop on ( runlevel [016] and (stopping udev)) + +respawn +exec /sbin/agetty /dev/tty3 9600 diff --git a/etc/init/tty4.conf b/etc/init/tty4.conf new file mode 100644 index 0000000..da601c4 --- /dev/null +++ b/etc/init/tty4.conf @@ -0,0 +1,10 @@ +description "Startup login getty on tty4" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (started udev)) +stop on ( runlevel [016] and (stopping udev)) + +respawn +exec /sbin/agetty /dev/tty4 9600 diff --git a/etc/init/tty5.conf b/etc/init/tty5.conf new file mode 100644 index 0000000..853d3c4 --- /dev/null +++ b/etc/init/tty5.conf @@ -0,0 +1,10 @@ +description "Startup login getty on tty5" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (started udev)) +stop on ( runlevel [016] and (stopping udev)) + +respawn +exec /sbin/agetty /dev/tty5 9600 diff --git a/etc/init/tty6.conf b/etc/init/tty6.conf new file mode 100644 index 0000000..f8bd9ac --- /dev/null +++ b/etc/init/tty6.conf @@ -0,0 +1,10 @@ +description "Startup login getty on tty6" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( runlevel [2345] and (started udev)) +stop on ( runlevel [016] and (stopping udev)) + +respawn +exec /sbin/agetty /dev/tty6 9600 diff --git a/etc/init/udev.conf b/etc/init/udev.conf new file mode 100644 index 0000000..aaaa779 --- /dev/null +++ b/etc/init/udev.conf @@ -0,0 +1,51 @@ +description "Staring udevdaemon to create all the /dev entrys" +author "Harald Kueller " +version 1.0 +emits none special + +start on startudev +stop on runlevel [06] + +console output +pre-start script + source /etc/init/functions + echo "Starting udev" + mount -t sysfs none /sys + status_message "udev: mount sysfs" + if [ ! -d /var/lock/subsys ]; then + mkdir /var/lock/subsys + fi + if [ ! -d /dev ]; then + mkdir /dev + fi + mount -n -t tmpfs -o mode=0755 udev /dev + status_message "udev: tmpfs on /dev created" + if [ -d /lib/udev/devices ]; then + cp --preserve=all --recursive --remove-destination /lib/udev/devices/* /dev + status_message "udev: Static entries copied..." + fi + /bin/mkdir -p /dev/shm + /bin/mkdir -p /dev/pts + /bin/mount -n -t tmpfs -o mode=1755 none /dev/shm + if [ ! -c /dev/null ]; then + /bin/mknod /dev/null c 1 3 + fi + /bin/chmod 666 /dev/null + if [ ! -c /dev/console ]; then + /bin/mknod /dev/console c 5 1 + fi + status_message "udev prestart ready" +end script + +respawn +exec /sbin/udevd + +post-start script + source /etc/init/functions + /bin/mkdir -p /dev/.udev/queue + status_message "udev: queue maked" + /sbin/udevadm trigger + status_message "udev: trigger done" + /sbin/udevadm settle + status_message "udev: Coldplug ready..." +end script diff --git a/etc/init/umountfs.conf b/etc/init/umountfs.conf new file mode 100644 index 0000000..562dc01 --- /dev/null +++ b/etc/init/umountfs.conf @@ -0,0 +1,17 @@ +description "Umount all Filesystems, and turn off swap" +author "Harald Kueller " +version 1.0 +emits none special + +start on (runlevel[06] and (stopped udev)) + +console none +script + source /etc/init/functions + + /sbin/swapoff -a + status_message "swap deaktivated..." + + /bin/umount -a -r + status_message "All File Systems umounted..." +end script diff --git a/etc/init/umountnfs.conf b/etc/init/umountnfs.conf new file mode 100644 index 0000000..87763f9 --- /dev/null +++ b/etc/init/umountnfs.conf @@ -0,0 +1,20 @@ +description "Mounting NFS Filesystems" +author "Harald Kueller " +version 1.0 +emits none special + +start on stopping nfsclient + +console output + +script + source /etc/init/functions + for i in `sed -e "/^#/d" /etc/fstab|awk '{print $2}'`; do + MOUNTPOINT=$i + FILESYSTEM=`awk '{if( $2 == "'$MOUNTPOINT'") print $3}' /etc/fstab` + if [ "$FILESYSTEM" == "nfs" ]; then + umount $MOUNTPOINT + status_message "umount NFS Filesystem from $MOUNTPOINT" + fi + done +end script diff --git a/etc/init/unloadmodules.conf b/etc/init/unloadmodules.conf new file mode 100644 index 0000000..39bcf2f --- /dev/null +++ b/etc/init/unloadmodules.conf @@ -0,0 +1,23 @@ +description "Force load of special Modules defined in /etc/sysconfig/loadmods" +author "Harald Kueller " +version 1.0 +emits none special + +start on ( (runlevel [06]) and ( stopping udev )) + +pre-start script + echo "unload all modules" + source /etc/init/functions + Z=0 + while [ $z -le 9 ]; do + exec 3/dev/null + status_message "$MODNAME unload..." + read <&3 MODNAME INFO + done + (( Z = $Z + 1 )) + exec 3>&- + done +end script diff --git a/etc/init/varmake.conf b/etc/init/varmake.conf new file mode 100644 index 0000000..b6c8b7d --- /dev/null +++ b/etc/init/varmake.conf @@ -0,0 +1,38 @@ +description "Make special handling for ro nfs root" +author "Harald Kueller " +version 1.0 +emits none special + +start on varmake + +console output +script + source /etc/init.d/functions + mount -t tmpfs none /var + status_message "Mount of tmpfs to /var ...." + ifconfig|\ + grep Protokoll|\ + awk '{ if ( $2 == "Protokoll:Ethernet" ) print $1 }' >/var/devices + for i in `cat /var/devices`; do + INET=`ifconfig $i|\ + grep inet|\ + awk -F ":" '{print $2}'|\ + awk '{print $1}'` + ANET=`echo $INET|awk -F "." '{print $1}'` + if [ ! "$ANET" == "127" ]; then + HOSTNAME=`getent hosts $INET` + HOSTNAME=`echo $HOSTNAME|\ + awk '{print $2}'|\ + awk -F "." '{print $1}'` + break + fi + done + echo -n " $HOSTNAME" + status_message "Trying to find out hostname..." + cd /var + tar -zxf /boot/var_${HOSTNAME}.tgz + echo $HOSTNAME >etc/sysconfig/nodename + cd - + status_message "Restore of var Filesystem..." + /sbin/initctl emit startudev +end script diff --git a/etc/init/virtualfs.conf b/etc/init/virtualfs.conf new file mode 100644 index 0000000..24087cd --- /dev/null +++ b/etc/init/virtualfs.conf @@ -0,0 +1,27 @@ +description "Mount all Virtual Filesystems like /proc /sys /tmp.." +author "Harald Kueller " +version 1.0 +emits none special + +start on started udev + +console output +script + source /etc/init/functions + /bin/mount -n -o remount,rw / + status_message "Changing state of rootfs to rw" + echo >/dev/mtab + /bin/mount -f -o remount,rw / + for i in `sed -e "/^#/d" /etc/fstab|awk '{print $2}'`; do + MOUNTPOINT=$i + DEVICE=`awk '{if( $2 == "'$MOUNTPOINT'") print $1}' /etc/fstab` + if [ "$DEVICE" == "none" ]; then + if [ -d $MOUNTPOINT ]; then + mount $MOUNTPOINT + status_message "Mounting $MOUNTPOINT ..." + else + echo "Mountpoint $MOUNTPOINT not existing" + fi + fi + done +end script diff --git a/etc/inittab b/etc/inittab new file mode 100644 index 0000000..94d18a1 --- /dev/null +++ b/etc/inittab @@ -0,0 +1,6 @@ +# +#Helper for upstart to determine the runlevel +#needet only in compatibly mode vor sysvinit +# + +id:4:initdefault: diff --git a/init/genpkg b/init/genpkg new file mode 100644 index 0000000..660b4c5 --- /dev/null +++ b/init/genpkg @@ -0,0 +1,65 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source$ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#Script: +#cvs module init script zur initialisierung +#der /etc/init.d scripten +#des Viitor_sysvinit archives. +# +#Letzte Änderung von: $Author: kueller $ +#Datum der letzten Änderung: $Date: 2009-03-30 21:53:23 +0200 (Mo, 30 Mär 2009) $ +#Version der Datei: $Revision: 4568 $ +# +#$Log$ +#Revision 1.5 2004/03/03 12:53:40 kueller +#Umstellung auf Viitor GPL Header +# +# +#$Log$ +#Revision 1.5 2004/03/03 12:53:40 kueller +#Umstellung auf Viitor GPL Header +# +#Revision 1.4 2002/06/12 09:55:41 hkueller +#Eintrag für das install script hinzugefügt +# +#Revision 1.3 2001/10/16 22:01:47 kueller +#Init Scripten werden nun mit den passenden Berechtigungen versehen +# +#Revision 1.2 2001/09/28 22:04:46 kueller +#/etc/sysconfig/net wird nun explizit angelegt +# +#Revision 1.1.1.1 2001/09/23 00:02:08 kueller +#Neustart wg. Datenverlust +# +# + +WDIR=`pwd` +mkdir -p etc/sysconfig/net +cd etc/init.d +for i in *; do + if [ -f $i ]; then + chmod 755 $i + fi +done +mkdir rc{S,0,1,2,3,4,5,6}.d +ln -s ../init.d init.d +cd $WDIR diff --git a/sbin/if_down b/sbin/if_down new file mode 100755 index 0000000..f88fa93 --- /dev/null +++ b/sbin/if_down @@ -0,0 +1,95 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source: /Data/cvs/ViitorMake/templates/Script.template,v $ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#Script:if_up +# +#Letzte Änderung von: $Author: $ +#Datum der letzten Änderung: $Date: $ +#Version der Datei: $Revision: $ +# +#$Log: $ +# + +source /etc/init.d/functions +DEV=$1 +if [ ! "$DEV" ]; then + echo "Usage: $0 " + exit 10 +fi +if pgrep vtun >/dev/null; then + /etc/init.d/vtund stop +fi +if [ -f /etc/sysconfig/net/${DEV}.dhcp ]; then + echo -n "Stopping dhclient for $DEV" + DHPID=`ps -ef|grep dhclient|grep ${DEV}|awk '{print $2}'` + if [ "$DHPID" ]; then + kill $DHPID + fi + evaluate_retval + echo -n "Shutting down Interface $DEV" + ifconfig $DEV 0.0.0.0 down + evaluate_retval +elif [ -f /etc/sysconfig/net/hostname.${DEV} ]; then + HOST=`cat /etc/sysconfig/net/hostname.${DEV}|awk '{print $1}'` + IP=`grep $HOST /etc/hosts|awk '{print $1}'` + NETMASK=`getmask $IP` + SHMASK=`GetShortMask $NETMASK` + echo -n "shutting down interface $i:IP=$IP NMASK=$NETMASK" + if [ "$NETMASK" = "" ]; then + DEV=`echo $i|cut -d ":" -f 1` + $DEBUG ip addr del $IP broadcast + dev $DEV + $DEBUG ip link set $DEV down + else + DEV=`echo $i|cut -d ":" -f 1` + $DEBUG ip addr del $IP/$SHMASK broadcast + dev $DEV + $DEBUG ip link set $DEV down + fi + evaluate_retval +fi +if [ -f /var/run/shutdown/wlan_nis ]; then + if [ -f /etc/sysconfig/nis/defaultdomain.wlan ]; then + echo -n "Restoring nis defaultdomain" + mv /etc/sysconfig/nis/defaultdomain.wlan \ + /etc/sysconfig/nis/defaultdomain + evaluate_retval + fi + if [ -f /etc/yp.conf.wlan ]; then + echo -n "Restoring nis yp.conf" + mv /etc/yp.conf.wlan \ + /etc/yp.conf + evaluate_retval + fi + rm /var/run/shutdown/wlan_nis + if [ -f /var/run/shutdown/wlan_dns ]; then + if [ -f /etc/resolv.conf.wlan ]; then + echo -n "Restoring resolv.conf" + mv /etc/resolv.conf.wlan /etc/resolv.conf + evaluate_retval + fi + rm /var/run/shutdown/wlan_dns + fi +fi +if pgrep wpa_supplicant >/dev/null; then + echo -n "Stopping wpa_supplicant" + pkill wpa_supplicant + evaluate_retval +fi diff --git a/sbin/if_up b/sbin/if_up new file mode 100755 index 0000000..f9233e3 --- /dev/null +++ b/sbin/if_up @@ -0,0 +1,125 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source: /Data/cvs/ViitorMake/templates/Script.template,v $ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#Script:if_up +# +#Letzte Änderung von: $Author: $ +#Datum der letzten Änderung: $Date: $ +#Version der Datei: $Revision: $ +# +#$Log: $ +# + +source /etc/init.d/functions + +DEV=$1 + +CheckForLink() { + NETDEVICE=$1 + if [ -f /usr/sbin/ethtool ]; then + #Einige Dumme Interfaces (z.B. die VMware Emulationen) Zeiten + #den korrekten Status erst nach einem ifconfig up + WAITTIME=7 + ZAHLER=0 + if ! ethtool $NETDEVICE|grep -q "No data available"; then + while [ ${ZAHLER} -le ${WAITTIME} ]; do + if [ ! `ethtool $NETDEVICE|grep Link|awk '{print $3}'` == "yes" ]; then + (( ZAHLER++ )) + else + break + fi + sleep 1 + done + if [ `ethtool $NETDEVICE|grep Link|awk '{print $3}'` == "yes" ]; then + touch /var/run/net_up + return 0 + else + return 1 + fi + else + touch /var/run/net_up + return 0 + fi + else + touch /var/run/net_up + return 0 + fi +} + +if [ ! "$DEV" ]; then + echo "Usage: $0 " + exit 10 +fi + +#Check for files in /etc/sysconfig/net +#hostname. will setup static ip for the interfaces, based +#on /etc/hosts (hostname) and /etc/networks (netmask/Broadcast) +#.dhcp will do a dynamic setup for the interface with dhcp + +if [ -f /etc/sysconfig/net/${DEV}.dhcp ]; then + #ok this is the dynamic part for setup ${DEV} + #first we have to startup interface to check interface type + ifconfig ${DEV} up + #Let check in /sys if the interface is a wireless interface + if [ -d /sys/class/net/${DEV}/wireless ]; then + #wireless interface need special setup.. + /sbin/wlan_setup ${DEV} + #give wlan time to startup and create a link + sleep 1 + fi + #let check if there is a link on the interface. + #only if there is a link, we will setup the interface.. + if CheckForLink ${DEV}; then + echo -n "Setting up ${DEV} with dhcp" + dhclient -q ${DEV} + evaluate_retval + else + ifconfig ${DEV} down + fi +elif ls /etc/sysconfig/net/hostname.${DEV}* &>/dev/null; then + ifconfig ${DEV} up + if [ -d /sys/class/net/${DEV}/wireless ]; then + /sbin/wlan_setup ${DEV} + #give wlan time to startup and create a link + sleep 1 + fi + if CheckForLink ${DEV}; then + for NETDEV in `ls /etc/sysconfig/net/hostname.${DEV}*|awk -F "." '{print $2}'`; do + HOST=`cat /etc/sysconfig/net/hostname.${NETDEV}|awk '{print $1}'` + IP=`grep $HOST /etc/hosts|awk '{print $1}'` + NETMASK=`getmask $IP` + SHMASK=`GetShortMask $NETMASK` + echo -n "setting up interface $NETDEV:IP=$IP NMASK=$NETMASK" + if [ "$NETMASK" = "" ]; then + DEV=`echo $NETDEV|cut -d ":" -f 1` + $DEBUG ip addr add $IP broadcast + dev $DEV + $DEBUG ip link set $DEV up + else + DEV=`echo $NETDEV|cut -d ":" -f 1` + $DEBUG ip addr add $IP/$SHMASK broadcast + dev $DEV + $DEBUG ip link set $DEV up + fi + done + else + ifconfig ${DEV} down + fi +fi diff --git a/sbin/wlan_setup b/sbin/wlan_setup new file mode 100755 index 0000000..b39df83 --- /dev/null +++ b/sbin/wlan_setup @@ -0,0 +1,159 @@ +#!/bin/bash +#Framework, welches ein komplettes Linux System aus den Sourcen erstellt +#dieses Framework wird im CVS Repository +#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt +# +#Lage dieser Datei im Archiv: $Source: /export/Data/cvs/Viitor_wireless/etc/init.d/wireless,v $ +# +#(c) 2003 Harald Kueller, Germany +#This program is free software; you can redistribute it and/or +#modify ist 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. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not write to the Free Software Foundation, +#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +#Script:wlan_setup +#Setup eines WLAN Interfaces per accesspoint config files in +#/etc/sysconfig/wlan/ +# +#Letzte Änderung von: $Author$ +#Datum der letzten Änderung: $Date$ +#Version der Datei: $Revision$ +# +#$Log: wireless,v $ +#Revision 1.1.1.1 2004/12/05 13:10:59 kueller +#New Package wireless +# +# +source /etc/init.d/functions + +if [ ! -f /var/state/ldap_disable ]; then + touch /var/state/ldap_disable +fi + +if [ ! -d /var/run/shutdown ]; then + mkdir -p /var/run/shutdown +fi +NSSWITCH=/etc/nsswitch.conf +DEV=$1 +if [ ! "$DEV" ]; then + echo "usage: $0 " + exit 1 +fi +/sbin/ifconfig $DEV up +if [ ! -d /sys/class/net/$DEV/wireless ]; then + echo "No Wireless Device" + exit 2 +fi +for AP in `iwlist $DEV scan 2>/dev/null|\ + grep ESSID|\ + cut -d":" -f 2-`; do + AP=`echo $AP|sed -e "s/\"//g"` + if [ -f /etc/sysconfig/wlan/$AP ]; then + echo -n "Binding Wireless Network to AP $AP" + $DEBUG iwconfig $DEV essid $AP + evaluate_retval + sed -e "/^#/d" /etc/sysconfig/wlan/$AP | \ + sed -e "/^ *$/d" >/tmp/AP + exec 3/etc/sysconfig/nis/defaultdomain + fi + if [ "$ARG2" ]; then + if [ -f /etc/yp.conf ]; then + mv /etc/yp.conf{,.wlan} + fi + echo "domain $ARG1 server $ARG2" >/etc/yp.conf + fi + NISSTR="nis" + ;; + LDAP) + export USE_LDAP=1 + LDAPSTR="ldap" + rm /var/state/ldap_disable + ;; + DNS) + if [ -f /var/run/shutdown/wlan_dns ]; then + echo "No Clean Shutdown, cleaning up" + if [ -f /etc/resolv.conf.wlan ]; then + mv /etc/resolv.conf.wlan /etc/resolv.conf + fi + fi + touch /var/run/shutdown/wlan_dns + if [ -f /etc/resolv.conf ]; then + mv /etc/resolv.conf{,.wlan} + fi + echo "#Resolv.conf generatet by wlan_setup" >/etc/resolv.conf + echo "nameserver $ARG1" >>/etc/resolv.conf + ;; + VTUN) + echo "Starting vtun client" + /etc/init.d/vtund start + ;; + esac + read <&3 OPTION ARG1 ARG2 + done + exec 3>&- + ifconfig $DEV down + ifconfig $DEV up + rm /tmp/AP + fi +done +FILESTR="files" +echo "passwd: $FILESTR $LDAPSTR $NISSTR" >$NSSWITCH +echo "group: $FILESTR $LDAPSTR $NISSTR" >>$NSSWITCH +echo "shadow: $FILESTR $LDAPSTR" >>$NSSWITCH +echo "publickkey: $FILESTR" >>$NSSWITCH +echo "hosts: dns $FILESTR $LDAPSTR $NISSTR" >>$NSSWITCH +echo "networks: $FILESTR $NISSTR" >>$NSSWITCH +echo "protocols: db $NISSTR $FILESTR" >>$NSSWITCH +echo "services: db $NISSTR $FILESTR" >>$NSSWITCH +echo "rpc: db $NISSTR $FILESTR" >>$NSSWITCH +echo "ethers: db $NISSTR $FILESTR" >>$NSSWITCH +echo "netmasks: $FILESTR $NISSTR" >>$NSSWITCH +echo "netgroup: $FILESTR $NISSTR" >>$NSSWITCH +echo "bootparams: $FILESTR" >>$NSSWITCH +echo "automount: $FILESTR $NISSTR" >>$NSSWITCH +echo "aliases: $FILESTR" >>$NSSWITCH +touch /var/run/nsswitch_done