Debian Codegraph @

scripts/sbin/drbl-nfs-conf

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: change the setting of NFS client
5 #
6
7 # Load DRBL setting and functions
8 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
9
10 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
11
12 #
13 check_if_root
14
15 #
16 run_cmd="`basenamescip-shell system . . basename. $0`"
17
18 #
19 usagescip-shell shell shell-project 0.0.0 usage().() {
20 echoscip-shell system . . echo. "Set the NFS parameters for DRBL client."
21 echoscip-shell system . . echo. "Usage: $run_cmd [-s|--size] SIZE [--rsize] SIZE [--wsize] SIZE [-p|--protocol] PROTOCOL [-v|--verbose]"
22 echoscip-shell system . . echo. "-s, --size SIZE: set the NFS blocksize (both rszie & wsize) to be SIZE bytes."
23 echoscip-shell system . . echo. "-g, --no-gen-ssi do NOT generate DRBL SSI template tarball."
24 echoscip-shell system . . echo. "--rsize SIZE: set the NFS rsize blocksize to be SIZE bytes."
25 echoscip-shell system . . echo. "--wsize SIZE: set the NFS wsize blocksize to be SIZE bytes."
26 echoscip-shell system . . echo. "-p, --protocol PROTOCOL: set the NFS to use the PROTOCOL (tcp, udp or auto)."
27 echoscip-shell system . . echo. "-v, --verbose print out verbose information."
28 }
29
30 if [scip-shell system . . `[`. $# -le 0 ]; then
31 usagescip-shell shell shell-project 0.0.0 usage().
32 exit 1
33 fi
34 #
35 while [scip-shell system . . `[`. $# -gt 0 ]; do
36 case "$1" in
37 -s|--size)
38 shift;
39 rsize="$1"
40 wsize="$1"
41 shift;;
42 --rsize)
43 shift; rsize="$1"
44 shift;;
45 --wsize)
46 shift; wsize="$1"
47 shift;;
48 -p|--protocol)
49 shift; protocol="$1"
50 shift;;
51 -g|--no-gen-ssi)
52 gen_ssi="no"
53 shift;;
54 -v|--verbose)
55 shift; VERBOSE="on"
56 ;;
57 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
58 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
59 exit 2 ;;
60 *) break ;;
61 esac
62 done
63
64
65 # check parameter
66 [scip-shell system . . `[`. -n "`echoscip-shell system . . echo. $rsize | grepscip-shell system . . grep. [^0-9]`" ] && echoscip-shell system . . echo. "rsize is \"$rsize\", but rsize must be numbers!!! Program terminated!" && exit 1
67 [scip-shell system . . `[`. -n "`echoscip-shell system . . echo. $wsize | grepscip-shell system . . grep. [^0-9]`" ] && echoscip-shell system . . echo. "wsize is \"$wsize\", but wsize must be numbers!!! Program terminated!" && exit 1
68 # The specified protocol is higher priority, it will overwrite the protocol gton from kernel config
69 if [scip-shell system . . `[`. -n "$protocol" ]; then
70 case "$protocol" in
71 [uU][dD][pP])
72 protocol="udp"
73 ;;
74 [tT][cC][pP])
75 protocol="tcp"
76 ;;
77 "auto")
78 check_kernel_nfsd_tcp_config
79 rtv=$?
80 case "$rtv" in
81 0)
82 protocol="udp"
83 ;;
84 1)
85 protocol="tcp"
86 ;;
87 esac
88 ;;
89 *)
90 echoscip-shell system . . echo. "PROTOCOL must be \"tcp\" or \"udp\" only"
91 exit 1
92 esac
93 fi
94
95 run_mknic_nbi="0"
96
97 # for rsize
98 if [scip-shell system . . `[`. -n "$rsize" ]; then
99 echoscip-shell system . . echo. "The rsize you set for DRBL client is: $rsize"
100 echoscip-shell system . . echo. -n "Modifying the NFS rsize parameter of clients... "
101 perl_str="s/,rsize=[[:digit:]]*,/,rsize=$rsize,/"
102 # change the fstab of clients
103 for itab in $drblroot/*; do
104 [scip-shell system . . `[`. -f $itab/etc/fstab ] && perlscip-shell system . . perl. -pi -e "$perl_str" $itab/etc/fstab
105 done
106 # change the drbl init in common root
107 perlscip-shell system . . perl. -pi -e "$perl_str" $drblroot/../node_root/sbin/init
108
109 # change the mkinitrd mount
110 perlscip-shell system . . perl. -pi -e "$perl_str" /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-postscip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-post`.
111 echoscip-shell system . . echo. "done!"
112 # set the flag to run mknic_nbi
113 run_mknic_nbi="1"
114 fi
115
116 # for wsize
117 if [scip-shell system . . `[`. -n "$wsize" ]; then
118 echoscip-shell system . . echo. "The wsize you set for DRBL client is: $wsize"
119
120 echoscip-shell system . . echo. -n "Modifying the NFS wsize parameter of clients... "
121 perl_str="s/,wsize=[[:digit:]]*,/,wsize=$wsize,/"
122 # change the fstab of clients
123 for itab in $drblroot/*; do
124 [scip-shell system . . `[`. -f $itab/etc/fstab ] && perlscip-shell system . . perl. -pi -e "$perl_str" $itab/etc/fstab
125 done
126 # change the drbl init in common root
127 perlscip-shell system . . perl. -pi -e "$perl_str" $drblroot/../node_root/sbin/init
128
129 # change the mkinitrd mount
130 perlscip-shell system . . perl. -pi -e "$perl_str" /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-postscip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-post`.
131 echoscip-shell system . . echo. "done!"
132 # set the flag to run mknic_nbi
133 run_mknic_nbi="1"
134 fi
135
136 # for protocol
137 if [scip-shell system . . `[`. -n "$protocol" ]; then
138 echoscip-shell system . . echo. "The NFS protocol you set for DRBL client is: $protocol"
139
140 echoscip-shell system . . echo. -n "Modifying the NFS protocol parameter of clients... "
141 perl_str="s/,tcp,|,udp,/,$protocol,/"
142 # change the fstab of clients
143 for itab in $drblroot/*; do
144 [scip-shell system . . `[`. -f $itab/etc/fstab ] && perlscip-shell system . . perl. -pi -e "$perl_str" $itab/etc/fstab
145 done
146 # change the drbl init in common root
147 perlscip-shell system . . perl. -pi -e "$perl_str" $drblroot/../node_root/sbin/init
148
149 # change the mkinitrd mount
150 perlscip-shell system . . perl. -pi -e "$perl_str" /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-postscip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-post`.
151 echoscip-shell system . . echo. "done!"
152 # set the flag to run mknic_nbi
153 run_mknic_nbi="1"
154 fi
155
156 # make the initrd-net effect if necessary
157 if [scip-shell system . . `[`. "$run_mknic_nbi" -eq "1" ]; then
158 echoscip-shell system . . echo. "-------------------------------------------------------"
159 echoscip-shell system . . echo. "Creating the network boot kernel image for DRBL clients..."
160 mknic-nbi -a
161 fi
162 #
163 if [scip-shell system . . `[`. "$gen_ssi" != "no" ]; then
164 echoscip-shell system . . echo. "-------------------------------------------------------"
165 echoscip-shell system . . echo. "Since some config files are modified in template client, creating template tarball for DRBL SSI..."
166 drbl-gen-ssi-files
167 fi
168
169 echoscip-shell system . . echo. "Please reboot the CLIENTS to make the new setting of NFS effect!"