-
Notifications
You must be signed in to change notification settings - Fork 1
/
server-run
66 lines (54 loc) · 1.73 KB
/
server-run
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
#!/bin/bash
#/usr/sbin/init
logfile="/var/log/run_server.log"
if [[ "$1" == "restart" ]]; then
if [[ "${NFS_SERVER}" -eq "1" ]]; then
echo "[`date`] Restart NFS server." | tee -a ${logfile}
systemctl stop nfs.service
systemctl start nfs.service
fi
if [[ "${SMB_SERVER}" -eq "1" ]]; then
echo "[`date`] Restart SMB server." | tee -a ${logfile}
systemctl stop smb.service nmb.service
systemctl start smb.service nmb.service
fi
exit 0
elif [[ "$1" == "status" ]]; then
systemctl status nfs.service
systemctl status smb.service nmb.service
exit 0
elif [[ "$1" == "stop" ]]; then
if [[ "${NFS_SERVER}" -eq "1" ]]; then
echo "[`date`] Stop NFS server." | tee -a ${logfile}
systemctl stop nfs.service
fi
if [[ "${SMB_SERVER}" -eq "1" ]]; then
echo "[`date`] Stop SMB server." | tee -a ${logfile}
systemctl stop smb.service nmb.service
fi
exit 0
fi
# ------------------------------------------------------------
if [[ "${NFS_SERVER}" -eq "1" ]]; then
echo "[`date`] Enable NFS server." | tee -a ${logfile}
systemctl enable nfs.service
systemctl start nfs.service
else
echo "[`date`] Disable NFS server." | tee -a ${logfile}
systemctl stop nfs.service
systemctl disable nfs.service
fi
if [[ "${SMB_SERVER}" -eq "1" ]]; then
echo "[`date`] Enable SMB server." | tee -a ${logfile}
systemctl enable smb.service nmb.service
systemctl start smb.service nmb.service
else
echo "[`date`] Disable SMB server."| tee -a ${logfile}
systemctl stop smb.service nmb.service
systemctl disable smb.service nmb.service
fi
# keep this script running
#while true; do
# date
# sleep 3600
#done