From 6fc8397da83278c990b5ea11d2539f64029d5a9d Mon Sep 17 00:00:00 2001 From: kueller Date: Thu, 22 Apr 2010 18:02:19 +0000 Subject: [PATCH] =?UTF-8?q?rc=20und=20rcS=20von=20sysvinit=20werden=20aus?= =?UTF-8?q?=20kompatiblit=C3=A4tszwecken=20ben=C3=B6tigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.compuextreme.de/Viitor/V962/Viitor_upstart@5582 504e572c-2e33-0410-9681-be2bf7408885 --- etc/init.d/rc | 157 +++++++++++++++++++++++++++++++++++++++++++++++++ etc/init.d/rcS | 99 +++++++++++++++++++++++++++++++ 2 files changed, 256 insertions(+) create mode 100644 etc/init.d/rc create mode 100644 etc/init.d/rcS 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..c6703cd --- /dev/null +++ b/etc/init.d/rcS @@ -0,0 +1,99 @@ +#!/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 + +mount -t proc none /proc + +if mount|grep /dev/root|grep nfs &>/dev/null; then + echo -n "Mounting tmpfs on /var" + mount -t tmpfs none /var + evaluate_retval + echo -n "Getting Hostname ..." + 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" + evaluate_retval + echo -n "Restoring var folder" + cd /var + tar -zxf /boot/var_${HOSTNAME}.tgz + echo $HOSTNAME >etc/sysconfig/nodename + cd - + evaluate_retval +else + mount -t tmpfs none /var/lock +fi + +umount /proc + +if [ -f /sbin/udevd ]; then + echo -n "Mounting /sys" + mount -t sysfs none /sys + evaluate_retval + if [ ! -d /var/lock/subsys ]; then + mkdir /var/lock/subsys + fi + if [ ! -d /dev ]; then + mkdir /dev + fi +fi + +for i in /etc/init.d/rcS.d/S??* +do + [ ! -f "$i" ] && continue; + $i start +done + +# End /etc/init.d/rcS