Debian Codegraph @

init.d.example

raw
1 #!/bin/sh
2 # /etc/init.d/dphys-swapfile - automatically set up an swapfile
3 # author Neil Franklin, last modification 2006.12.22
4 # This script is copyright ETH Zuerich Physics Departement,
5 # use under either modified/non-advertising BSD or GPL license
6
7 # this init.d script is intended to be run from rcS.d
8 # must run after mount of /var which may only happen in S35mountall.sh
9 # for this reason we can not build swapfile until after S35mountall.sh
10 # so we also need to use init.d start|stop to swapon|off our file
11 # and sensibly before the lots of stuff which may happen in S40networking
12 # and may want to use a lot of memory, and so requires swap to be running
13 # so we run it as rcS.d/S37dphys-config
14
15 # get ready to work
16 # /usr/local added for Slackware, because self installed stuff ends up in there
17 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
18 export PATH
19
20 # what we are
21 NAME=dphys-swapfile
22 PNAME=dphys-swapfile
23
24 case "$1" in
25
26 start)
27 echo "Starting ${NAME} swapfile setup ..."
28
29 # (re-)size/-generate (and also first time install)
30 # this will produce output, so no -n in above echo
31 dphys-swapfile setup
32
33 # as S35mountall.sh has already run, do this from here
34 # as there can be no swapon in /etc/fstab
35 dphys-swapfile swapon
36
37 echo "done."
38 ;;
39
40
41 stop)
42 echo -n "Stopping ${NAME} swapfile setup ..."
43
44 # as no swapon or swapoff in /etc/fstab, do this from here
45 dphys-swapfile swapoff
46
47 echo ", done."
48 ;;
49
50
51 restart|reset|reload|force-reload)
52 echo "No daemon to (force-)re[start|set|load] in ${NAME}"
53 ;;
54
55
56 *)
57 echo "Usage: $0 {start|stop}"
58
59 exit 1
60 ;;
61
62 esac
63
64 exit 0