diff options
Diffstat (limited to 'pkgs/servers/server-scripts/generic/functions')
-rw-r--r-- | pkgs/servers/server-scripts/generic/functions | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/pkgs/servers/server-scripts/generic/functions b/pkgs/servers/server-scripts/generic/functions deleted file mode 100644 index d67370388f032..0000000000000 --- a/pkgs/servers/server-scripts/generic/functions +++ /dev/null @@ -1,117 +0,0 @@ -#! @bash@/bin/sh -e - -## Generic service scripts for NixOS, which provide -## * functions to write state to files (/var/run/nix-services) -## * functions to read state from file (/var/run/nix-services) -## * sanity checking functions - -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 - echo $i - 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 - - RETVAL=$? - if test $RETVAL != 0; then - exit $RETVAL - fi - done -} - -start_softdeps() { - for i in $softdeps; do - echo $i - - 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 - - RETVAL=$? - if test $RETVAL != 0; then - continue - fi - done -} - -start() { - # are we already running? - # if so, exit with code 0 - if test -a $STATEDIR/$prog; then - exit 0 - fi - # if not, continue - # launch all hard dependencies - start_deps - - RETVAL=$? - - if test $RETVAL != 0; then - echo $prog failed - exit $RETVAL - fi - - # launch all preferred dependencies - echo "softdeps" $softdeps - start_softdeps - # launch our own program - startService - # if successful, then register - - RETVAL=$? - - if test $RETVAL != 0; then - echo $prog failed - exit $RETVAL - fi - - register -} - -stop() { - echo "stopping $prog" - # are we running? If so, then stop, otherwise, do nothing... - if ! test -a $STATEDIR/$prog; then - exit 0 - fi - # stop our own program - stopService - echo "unregistering" - unregister -} - -register() { - touch $STATEDIR/$prog -} - -unregister() { - rm $STATEDIR/$prog -} - -status() { - # are we running? If so, report - if test -a $STATEDIR/$prog; then - echo "running" - else - echo "stopped" - fi -} - -name() { - echo $prog -} |