git.iko.soy/typeable/nixpkgs
on master help sign in
add a bit more boiler plate code. Right now I just touch a file in $STATEDIR,

maybe this should include the path to the Nix store and a sanity check should be added to make sure that if we check the file in $STATEDIR that it is indeed from an instance of the service that we want to start. This adds complexity, because how should we deal with the situation of they are not equal. TODO: add a "status" command, or a "version" command, which displays which service is currently registered with the system as "running" svn path=/nixpkgs/trunk/; revision=5015

commit742c1ef85eb002896309d3d22c49051c39234ea0 authorArmijn Hemel <armijn@gpl-violations.org> dateThu 9 Mar 2006, 13:20 (21 years ago) parent9a198b5
1 file changed+19−4
pkgs/servers/server-scripts/generic/functions+19−4
pkgs/servers/server-scripts/generic/functions+19−4
@@ -18,21 +18,36 @@ start_deps() {
1818 exit $RETVAL
1919}
2020
21+start_softdeps() {
22+ for i in $softdeps
23+ $i start
24+ RETVAL=$?
25+ if test $RETVAL != 0; then
26+ continue
27+}
28+
2129start() {
22− # aren't we already running?
23− # @gnugrep@/bin/grep $prog
30+ # are we already running?
31+ # if so, exit with code 0
32+ if test -a $STATDIR/$prog = 1; then
33+ exit 0
34+ # if not, continue
2435 # launch all hard dependencies
2536 start_deps
2637 # launch all preferred dependencies
38+ start_softdeps
39+ # launch our own program
2740}
2841
2942stop() {
3043 # are we running? If so, then stop, otherwise, do nothing...
31− if test -a $STATDIR/program = 0; then
32− echo "bla"
44+ if test -a $STATDIR/$prog = 0; then
45+ exit 0
46+ # stop our own program
3347}
3448
3549register() {
50+ touch $STATEDIR/$prog
3651}
3752
3853unregister() {