-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-nfs-server.sh
executable file
·61 lines (46 loc) · 1.37 KB
/
setup-nfs-server.sh
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
#!/bin/sh
set -x
if [ -z "$EUID" ]; then
EUID=`id -u`
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
if [ -f $OURDIR/nfs-server-done ]; then
exit 0
fi
logtstart "nfs-server"
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
if [ -f $LOCALSETTINGS ]; then
. $LOCALSETTINGS
fi
maybe_install_packages nfs-kernel-server
service_stop nfs-kernel-server
$SUDO mkdir -p $NFSEXPORTDIR
$SUDO chmod 755 $NFSEXPORTDIR
dataip=`getnodeip $HEAD $DATALAN`
prefix=`getnetmaskprefix $DATALAN`
networkip=`getnetworkip $HEAD $DATALAN`
syncopt="sync"
if [ -n "$NFSASYNC" -a $NFSASYNC -eq 1 ]; then
syncopt="async"
fi
echo "$NFSEXPORTDIR $networkip/$prefix(rw,$syncopt,no_root_squash,no_subtree_check,fsid=0)" | $SUDO tee -a /etc/exports
echo "OPTIONS=\"-l -h 127.0.0.1 -h $dataip\"" | $SUDO tee /etc/default/rpcbind
$SUDO sed -i.bak -e "s/^rpcbind/#rpcbind/" /etc/hosts.deny
echo "rpcbind: ALL EXCEPT 127.0.0.1, $networkip/$prefix" | $SUDO tee -a /etc/hosts.deny
service_enable rpcbind
service_restart rpcbind
service_enable rpc-statd
service_restart rpc-statd
service_enable nfs-idmapd
service_restart nfs-idmapd
service_enable nfs-kernel-server
service_restart nfs-kernel-server
$SUDO mkdir -p $NFSMOUNTDIR
$SUDO chmod 755 $NFSMOUNTDIR
echo "$NFSEXPORTDIR $NFSMOUNTDIR none defaults,bind 0 0" | $SUDO tee -a /etc/fstab
$SUDO mount $NFSMOUNTDIR
logtend "nfs-server"
touch $OURDIR/nfs-server-done