forked from ananace/docker-nfs-ganesha-ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·126 lines (101 loc) · 2.74 KB
/
start.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
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
#!/bin/bash
set -e
# Options for starting Ganesha
: ${GANESHA_LOGFILE:="/dev/stdout"}
: ${GANESHA_CONFIGFILE:="/etc/ganesha/ganesha.conf"}
: ${GANESHA_OPTIONS:="-N NIV_EVENT"} # NIV_DEBUG
: ${GANESHA_EPOCH:=""}
: ${GANESHA_EXPORT_ID:="77"}
: ${GANESHA_EXPORT:="/export"}
: ${GANESHA_PSEUDO_PATH:="/"}
: ${GANESHA_NFS_PROTOCOLS:="3,4"}
: ${GANESHA_TRANSPORTS:="UDP,TCP"}
: ${GANESHA_ACCESS:="*"}
: ${GANESHA_ROOT_ACCESS:="*"}
: ${GANESHA_BOOTSTRAP_CONFIG:="yes"}
function ensure_mtab {
if ! [ -e "/etc/mtab" ]; then
ln -s /proc/mounts /etc/mtab
fi
}
function bootstrap_config {
echo "Bootstrapping Ganesha NFS config"
local squash="Root_Squash"
local global_access="RW";
if [ "$GANESHA_ACCESS" != "*" ]; then
if [ -n "$GANESHA_ACCESS" ]; then
local ganesha_client="$(echo -e "CLIENT {\n Clients = \"${GANESHA_ACCESS}\";\n Squash = Root_Squash;\n Access_Type = RW;\n }")"
fi
global_access="None"
fi
if [ "$GANESHA_ROOT_ACCESS" != "*" ] && [ -n "$GANESHA_ROOT_ACCESS" ]; then
local ganesha_root_client="$(echo -e "CLIENT {\n Clients = \"${GANESHA_ROOT_ACCESS}\";\n Squash = No_Root_Squash;\n Access_Type = RW;\n }")"
elif [ "$GANESHA_ROOT_ACCESS" == "*" ]; then
squash="No_Root_Squash"
fi
cat <<END >${GANESHA_CONFIGFILE}
# NFS protocol options
EXPORT
{
# Export Id (mandatory, each EXPORT must have a unique Export_Id)
Export_Id = ${GANESHA_EXPORT_ID};
# Exported path (mandatory)
Path = ${GANESHA_EXPORT};
# Pseudo Path (for NFS v4)
Pseudo = ${GANESHA_PSEUDO_PATH};
# Access control options
Access_Type = $global_access;
Squash = $squash;
# NFS protocol options
SecType = "sys";
Transports = ${GANESHA_TRANSPORTS};
Protocols = ${GANESHA_NFS_PROTOCOLS};
$ganesha_client
$ganesha_root_client
# Exporting FSAL
FSAL {
Name = VFS;
}
}
END
}
function bootstrap_export {
if [ ! -f ${GANESHA_EXPORT} ]; then
mkdir -p "${GANESHA_EXPORT}"
fi
}
function init_rpc {
echo "Starting rpcbind"
rpcbind || return 0
rpc.statd -L || return 0
rpc.idmapd || return 0
sleep 1
}
function init_dbus {
echo "Starting dbus"
# Ensure folder structure exists
mkdir -p /var/run/dbus
chown messagebus:messagebus /var/run/dbus
rm -f /var/run/dbus/system_bus_socket
rm -f /var/run/dbus/pid
dbus-uuidgen --ensure
dbus-daemon --system --fork
sleep 1
}
function startup_script {
if [ -f "${STARTUP_SCRIPT}" ]; then
/bin/sh "${STARTUP_SCRIPT}"
fi
}
if [[ "${GANESHA_BOOTSTRAP_CONFIG}" = "yes" ]]
then
bootstrap_config
fi
ensure_mtab
bootstrap_export
startup_script
init_rpc
init_dbus
echo "Starting Ganesha NFS"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib
exec /usr/bin/ganesha.nfsd -F -L ${GANESHA_LOGFILE} -f ${GANESHA_CONFIGFILE} ${GANESHA_OPTIONS}