From 6562861ba416fa5f6154d2e047e0591abafb3c71 Mon Sep 17 00:00:00 2001 From: Armijn Hemel Date: Fri, 10 Mar 2006 13:32:54 +0000 Subject: [PATCH] fix some brainfarts svn path=/nixpkgs/trunk/; revision=5021 --- .../servers/server-scripts/generic/builder.sh | 5 ++++ .../server-scripts/generic/default.nix | 9 +++++++ pkgs/servers/server-scripts/generic/functions | 25 +++++++++++++++---- pkgs/servers/syslog-script/builder.sh | 1 + pkgs/servers/syslog-script/default.nix | 4 +-- pkgs/servers/syslog-script/syslog | 16 ++++++------ 6 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 pkgs/servers/server-scripts/generic/builder.sh create mode 100644 pkgs/servers/server-scripts/generic/default.nix diff --git a/pkgs/servers/server-scripts/generic/builder.sh b/pkgs/servers/server-scripts/generic/builder.sh new file mode 100644 index 000000000000..841430aaf449 --- /dev/null +++ b/pkgs/servers/server-scripts/generic/builder.sh @@ -0,0 +1,5 @@ +source $stdenv/setup + +ensureDir $out + +cp $functions $out/$nicename diff --git a/pkgs/servers/server-scripts/generic/default.nix b/pkgs/servers/server-scripts/generic/default.nix new file mode 100644 index 000000000000..fb9fafcaf669 --- /dev/null +++ b/pkgs/servers/server-scripts/generic/default.nix @@ -0,0 +1,9 @@ +{stdenv}: + +stdenv.mkDerivation { + name = "generic-server-script-0.0.1"; + server = "generic"; + nicename = "functions"; + builder = ./builder.sh ; + functions = [./functions]; +} diff --git a/pkgs/servers/server-scripts/generic/functions b/pkgs/servers/server-scripts/generic/functions index 9ab462b1dee3..48c6a4d0d7b9 100644 --- a/pkgs/servers/server-scripts/generic/functions +++ b/pkgs/servers/server-scripts/generic/functions @@ -11,31 +11,36 @@ RCDIR=/etc/rc.d/ ## resolve $deps to real start/stop scripts first start_deps() { - for i in $deps + for i in $deps; do $i start RETVAL=$? if test $RETVAL != 0; then exit $RETVAL + fi + done } start_softdeps() { - for i in $softdeps + for i in $softdeps; do $i start RETVAL=$? if test $RETVAL != 0; then continue + fi + done } start() { # are we already running? # if so, exit with code 0 - if test -a $STATDIR/$prog = 1; then + if test -a $STATDIR/$prog; then exit 0 + fi # if not, continue # launch all hard dependencies - start_deps + #start_deps # launch all preferred dependencies - start_softdeps + #start_softdeps # launch our own program } @@ -43,6 +48,7 @@ stop() { # are we running? If so, then stop, otherwise, do nothing... if test -a $STATDIR/$prog = 0; then exit 0 + fi # stop our own program } @@ -53,3 +59,12 @@ register() { unregister() { rm $STATEDIR/$prog } + +status() { + # are we running? If so, report + if test -a $STATDIR/$prog; then + echo "running" + else + echo "stopped" + fi +} diff --git a/pkgs/servers/syslog-script/builder.sh b/pkgs/servers/syslog-script/builder.sh index a4aa01aa4c21..a1f1e2077084 100644 --- a/pkgs/servers/syslog-script/builder.sh +++ b/pkgs/servers/syslog-script/builder.sh @@ -5,6 +5,7 @@ ensureDir $out sed -e "s^@bash\@^$bash^g" \ -e "s^@syslog\@^$syslog^g" \ -e "s^@nicename\@^$nicename^g" \ + -e "s^@initscripts\@^$initscripts^g" \ < $script > $out/$nicename chmod +x $out/$nicename diff --git a/pkgs/servers/syslog-script/default.nix b/pkgs/servers/syslog-script/default.nix index 937aef9de4da..c98da1e49efc 100644 --- a/pkgs/servers/syslog-script/default.nix +++ b/pkgs/servers/syslog-script/default.nix @@ -1,10 +1,10 @@ -{stdenv, bash, syslog}: +{stdenv, bash, syslog, initscripts}: stdenv.mkDerivation { name = "syslog-script-0.0.1"; server = "syslog"; nicename = "syslog"; builder = ./builder.sh ; - inherit bash syslog; + inherit bash syslog initscripts; script = [./syslog]; } diff --git a/pkgs/servers/syslog-script/syslog b/pkgs/servers/syslog-script/syslog index fc06c8f1d552..3ec29884c1d5 100755 --- a/pkgs/servers/syslog-script/syslog +++ b/pkgs/servers/syslog-script/syslog @@ -8,7 +8,7 @@ # processname: sshd # source function library -#. @initscripts@/etc/rc.d/init.d/functions +source @initscripts@/functions # pull in sysconfig settings #[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd @@ -16,23 +16,23 @@ RETVAL=0 prog=@nicename@ -start() +startService() { # just do networking - echo -n $"Starting $prog:" + echo -n "Starting $prog:" @syslog@/usr/sbin/syslogd @syslog@/usr/sbin/klogd } -stop() +stopService() { - echo -n $"Stopping $prog:" + echo -n "Stopping $prog:" } -reload() +reloadService() { - start stop + start } case "$1" in @@ -50,7 +50,7 @@ case "$1" in reload ;; status) - echo "all OK" + status ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}"