File: drbl-nfs-conf

package info (click to toggle)
drbl 5.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,996 kB
  • sloc: sh: 43,555; perl: 8,820; xml: 867; makefile: 135
file content (169 lines) | stat: -rwxr-xr-x 4,886 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# Author: Steven Shiau <steven _at_ clonezilla org>
# License: GPL
# Description: change the setting of NFS client
#

# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions

#
check_if_root

#
run_cmd="`basename $0`"

#
usage() {
  echo "Set the NFS parameters for DRBL client."
  echo "Usage: $run_cmd [-s|--size] SIZE [--rsize] SIZE [--wsize] SIZE [-p|--protocol] PROTOCOL [-v|--verbose]"
  echo "-s, --size SIZE:  set the NFS blocksize (both rszie & wsize) to be SIZE bytes." 
  echo "-g, --no-gen-ssi do NOT generate DRBL SSI template tarball."
  echo "--rsize SIZE:  set the NFS rsize blocksize to be SIZE bytes." 
  echo "--wsize SIZE:  set the NFS wsize blocksize to be SIZE bytes." 
  echo "-p, --protocol PROTOCOL:   set the NFS to use the PROTOCOL (tcp, udp or auto)." 
  echo "-v, --verbose    print out verbose information."
}

if [ $# -le 0 ]; then
  usage
  exit 1
fi
#
while [ $# -gt 0 ]; do
  case "$1" in
    -s|--size)
		shift; 
		rsize="$1"
		wsize="$1"
		shift;;
    --rsize)
		shift; rsize="$1"
		shift;;
    --wsize)
		shift; wsize="$1"
		shift;;
    -p|--protocol)
		shift; protocol="$1"
		shift;;
    -g|--no-gen-ssi)
		gen_ssi="no"
                shift;;
    -v|--verbose)
		shift; VERBOSE="on"
                ;;
    -*)		echo "${0}: ${1}: invalid option" >&2
		usage >& 2
		exit 2 ;;
    *)		break ;;
  esac
done


# check parameter
[ -n "`echo $rsize | grep [^0-9]`" ] && echo "rsize is \"$rsize\", but rsize must be numbers!!! Program terminated!" && exit 1
[ -n "`echo $wsize | grep [^0-9]`" ] && echo "wsize is \"$wsize\", but wsize must be numbers!!! Program terminated!" && exit 1
# The specified protocol is higher priority, it  will overwrite the protocol gton from kernel config
if [ -n "$protocol" ]; then
  case "$protocol" in
     [uU][dD][pP])
                 protocol="udp"
                 ;;
     [tT][cC][pP])
                 protocol="tcp"
                 ;;
          "auto")
                 check_kernel_nfsd_tcp_config
                 rtv=$?
                 case "$rtv" in
                   0)
                      protocol="udp"
                      ;;
                   1)
                      protocol="tcp"
                      ;;
                 esac
                 ;;
  	       *)
  	         echo "PROTOCOL must be \"tcp\" or \"udp\" only"
                 exit 1
  esac
fi

run_mknic_nbi="0"

# for rsize
if [ -n "$rsize" ]; then
  echo "The rsize you set for DRBL client is: $rsize"
  echo -n "Modifying the NFS rsize parameter of clients... "
  perl_str="s/,rsize=[[:digit:]]*,/,rsize=$rsize,/"
  # change the fstab of clients
  for itab in $drblroot/*; do
     [ -f $itab/etc/fstab ] && perl -pi -e "$perl_str" $itab/etc/fstab
  done
  # change the drbl init in common root
  perl -pi -e "$perl_str" $drblroot/../node_root/sbin/init

  # change the mkinitrd mount
  perl -pi -e "$perl_str" /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-post
  echo "done!"
  # set the flag to run mknic_nbi
  run_mknic_nbi="1"
fi

# for wsize
if [ -n "$wsize" ]; then
  echo "The wsize you set for DRBL client is: $wsize"

  echo -n "Modifying the NFS wsize parameter of clients... "
  perl_str="s/,wsize=[[:digit:]]*,/,wsize=$wsize,/"
  # change the fstab of clients
  for itab in $drblroot/*; do
     [ -f $itab/etc/fstab ] && perl -pi -e "$perl_str" $itab/etc/fstab
  done
  # change the drbl init in common root
  perl -pi -e "$perl_str" $drblroot/../node_root/sbin/init

  # change the mkinitrd mount
  perl -pi -e "$perl_str" /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-post
  echo "done!"
  # set the flag to run mknic_nbi
  run_mknic_nbi="1"
fi

# for protocol
if [ -n "$protocol" ]; then
  echo "The NFS protocol you set for DRBL client is: $protocol"

  echo -n "Modifying the NFS protocol parameter of clients... "
  perl_str="s/,tcp,|,udp,/,$protocol,/"
  # change the fstab of clients
  for itab in $drblroot/*; do
     [ -f $itab/etc/fstab ] && perl -pi -e "$perl_str" $itab/etc/fstab
  done
  # change the drbl init in common root
  perl -pi -e "$perl_str" $drblroot/../node_root/sbin/init

  # change the mkinitrd mount
  perl -pi -e "$perl_str" /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/udhcpc-post
  echo "done!"
  # set the flag to run mknic_nbi
  run_mknic_nbi="1"
fi

# make the initrd-net effect if necessary
if [ "$run_mknic_nbi" -eq "1" ]; then
   echo "-------------------------------------------------------"
   echo "Creating the network boot kernel image for DRBL clients..."
   mknic-nbi -a
fi
#
if [ "$gen_ssi" != "no" ]; then
  echo "-------------------------------------------------------"
  echo "Since some config files are modified in template client, creating template tarball for DRBL SSI..."
  drbl-gen-ssi-files
fi

echo "Please reboot the CLIENTS to make the new setting of NFS effect!"