Debian Codegraph @

sbin/drbl-swapfile

raw symbols SCIP
1 #!/bin/bash
2 # Author: Blake, Kuo-Lien Huang
3 # License: GPL
4 # Description: put/get the file to/from all DRBL clients,
5 # file utility for host(fuh)
6 #
7 # Modified by Steven Shiau <[email protected]> to be used in DRBL for RedHat
8
9 # Load DRBL setting and functions
10 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
11
12 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
13
14 #
15 usage() {
16 echo "Start or stop the swapfile service in the DRBL client (This will make client to turn on/off the swap file when client boots)."
17 echo "Usage: $0 -s swapfile_size [start|stop]"
18 echo "-s, --size=SIZE: the maximum swap file SIZE (in MB)"
19 }
20
21 #
22 check_if_root
23
24 #
25 while [ $# -gt 0 ]; do
26 case "$1" in
27 -s|--size)
28 shift; maxswapsize="$1"
29 shift;;
30 -*) echo "${0}: ${1}: invalid option" >&2
31 usage >& 2
32 exit 2 ;;
33 *) break ;;
34 esac
35 done
36
37 # if maxswapsize is NOT specified, set the default value
38 [ -z "$maxswapsize" ] && maxswapsize=maxswapsize_default
39 #
40 switch=$1
41 case "$switch" in
42 start)
43 echo "Set the max swapfile size for each client as $maxswapsize MB."
44 for ihost in $drblroot/*; do
45 echo "maxswapsize=$maxswapsize" > \
46 $ihost/$SYSCONF_PATH/mkswapfile
47 done
48 drbl-client-service mkswapfile on
49 ;;
50 stop)
51 for ihost in $drblroot/*; do
52 [ -f "$ihost/$SYSCONF_PATH/mkswapfile" ] && \
53 rm -f $ihost/$SYSCONF_PATH/mkswapfile
54 done
55 drbl-client-service mkswapfile off
56 ;;
57 *)
58 usage
59 exit 1
60 esac
61 # Note, since drbl-client-service will run drbl-gen-ssi-files, so we do not have to run it here.