diff --git a/pkgs/servers/server-scripts/generic/builder.sh b/pkgs/servers/server-scripts/generic/builder.sh index 841430aaf449..7eae08df6249 100644 --- a/pkgs/servers/server-scripts/generic/builder.sh +++ b/pkgs/servers/server-scripts/generic/builder.sh @@ -2,4 +2,10 @@ source $stdenv/setup ensureDir $out -cp $functions $out/$nicename +sed -e "s^@bash\@^$bash^g" \ + -e "s^@sshd\@^$ssh^g" \ + -e "s^@initscripts\@^$initscripts^g" \ + -e "s^@coreutils\@^$coreutils^g" \ + -e "s^@nixpkgs\@^$nixpkgs^g" \ + -e "s^@nix\@^$nix^g" \ + < $functions > $out/$nicename diff --git a/pkgs/servers/server-scripts/generic/default.nix b/pkgs/servers/server-scripts/generic/default.nix index fb9fafcaf669..4e9022568b4a 100644 --- a/pkgs/servers/server-scripts/generic/default.nix +++ b/pkgs/servers/server-scripts/generic/default.nix @@ -1,4 +1,4 @@ -{stdenv}: +{stdenv, bash, nix}: stdenv.mkDerivation { name = "generic-server-script-0.0.1"; @@ -6,4 +6,6 @@ stdenv.mkDerivation { nicename = "functions"; builder = ./builder.sh ; functions = [./functions]; + nixpkgs = "/nixpkgs/trunk/pkgs"; + inherit bash nix; } diff --git a/pkgs/servers/server-scripts/generic/functions b/pkgs/servers/server-scripts/generic/functions index ceb46a481495..6e7bd2785fb3 100644 --- a/pkgs/servers/server-scripts/generic/functions +++ b/pkgs/servers/server-scripts/generic/functions @@ -7,12 +7,18 @@ STATEDIR=/var/run/nix-services RCDIR=/etc/rc.d/ +NIXPKGS=@nixpkgs@ ## resolve $deps to real start/stop scripts first start_deps() { for i in $deps; do - $i start + name=`$i/control name` + if ! test -a $RCDIR/$name; then + echo "blaat" + fi + + $i/control start RETVAL=$? if test $RETVAL != 0; then exit $RETVAL @@ -23,7 +29,16 @@ start_deps() { start_softdeps() { for i in $softdeps; do echo $i - $i start + + name=`$i/control name` + if ! test -a "$RCDIR/$name"; then + echo $RCDIR/$name $i + @nix@/bin/nix-env -p $RCDIR/$name -i $i + fi + + $i/control start + + #$i start RETVAL=$? if test $RETVAL != 0; then continue @@ -34,7 +49,7 @@ start_softdeps() { start() { # are we already running? # if so, exit with code 0 - if test -a $STATDIR/$prog; then + if test -a $STATEDIR/$prog; then exit 0 fi # if not, continue diff --git a/pkgs/servers/ssh-script/builder.sh b/pkgs/servers/ssh-script/builder.sh index a041a00118c3..0450c96322e7 100644 --- a/pkgs/servers/ssh-script/builder.sh +++ b/pkgs/servers/ssh-script/builder.sh @@ -7,6 +7,6 @@ sed -e "s^@bash\@^$bash^g" \ -e "s^@initscripts\@^$initscripts^g" \ -e "s^@coreutils\@^$coreutils^g" \ -e "s^@softdeps\@^$softdeps^g" \ - < $script > $out/$nicename + < $script > $out/control -chmod +x $out/$nicename +chmod +x $out/control diff --git a/pkgs/servers/ssh-script/sshd b/pkgs/servers/ssh-script/sshd index 6dd7131bc41d..eb2e3a2e720b 100755 --- a/pkgs/servers/ssh-script/sshd +++ b/pkgs/servers/ssh-script/sshd @@ -109,7 +109,6 @@ stopService() { echo -n $"Stopping $prog:" #killproc $SSHD -TERM - echo "blaat" @coreutils@/bin/kill `@coreutils@/bin/cat /var/run/sshd.pid` RETVAL=$? [ "$RETVAL" = 0 ] && @coreutils@/bin/rm -f /var/lock/subsys/sshd diff --git a/pkgs/servers/syslog-script/builder.sh b/pkgs/servers/syslog-script/builder.sh index a1f1e2077084..9c6cf385c242 100644 --- a/pkgs/servers/syslog-script/builder.sh +++ b/pkgs/servers/syslog-script/builder.sh @@ -6,6 +6,6 @@ sed -e "s^@bash\@^$bash^g" \ -e "s^@syslog\@^$syslog^g" \ -e "s^@nicename\@^$nicename^g" \ -e "s^@initscripts\@^$initscripts^g" \ - < $script > $out/$nicename + < $script > $out/control -chmod +x $out/$nicename +chmod +x $out/control diff --git a/pkgs/servers/syslog-script/syslog b/pkgs/servers/syslog-script/syslog index d6291271f48a..9a82f5eaf03a 100755 --- a/pkgs/servers/syslog-script/syslog +++ b/pkgs/servers/syslog-script/syslog @@ -54,6 +54,9 @@ case "$1" in status) status ;; + name) + name + ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}" RETVAL=1