blob: 98daa727f86887995f028a8c773f3c3e5dc60617 (
plain)
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
|
#!/bin/sh
source /root/.profile # Get Environment Variables from Root Profile
if ! type mono 2>/dev/null; then
for d in /volume/*/@appstore/mono; do
if [ -x "$d/bin/mono" ]; then
PATH="$PATH:$d/bin"
export PATH
break
fi
done
fi
# Package Varables
PACKAGE_NAME_SIMPLE="$(echo "$SYNOPKG_PKGNAME" | awk '{print tolower($0)}' | sed -e 's/ /_/g')"
PACKAGE_DIR="${SYNOPKG_PKGDEST}"
PACKAGE_UPGRADE_FLAG="/tmp/${PACKAGE_NAME_SIMPLE}.upgrade"
# We need more space than what /tmp holds
PACKAGE_TEMP_DIR="${PACKAGE_DIR}/temp"
# These control how the authentication is integrated
SYNO_LOGIN_CGI=/usr/syno/synoman/webman/login.cgi
SYNO_AUTHENTICATE_CGI=/usr/syno/synoman/webman/modules/authenticate.cgi
# If all users should have access, set to "1"
SYNO_ALL_USERS=0
# If we should disable verification of Synology's XSRF tokens, set to "1"
SYNO_SKIP_XSRF=0
# If we should disable Synology auth completely, set to "0"
SYNO_DSM_AUTH=1
# Start & Stop Varables
PID_FILE="/var/run/${PACKAGE_NAME_SIMPLE}.pid"
DaemonStart() {
DaemonStatus
if [ $? == 0 ]; then
echo "Starting ${PACKAGE_NAME_SIMPLE}."
mkdir -p "${PACKAGE_TEMP_DIR}"
SYNO_DSM_AUTH=${SYNO_DSM_AUTH} \
SYNO_SKIP_XSRF=${SYNO_SKIP_XSRF} \
SYNO_ALL_USERS=${SYNO_ALL_USERS} \
SYNO_AUTHENTICATE_CGI="${SYNO_AUTHENTICATE_CGI}" \
SYNO_LOGIN_CGI="${SYNO_LOGIN_CGI}" \
TMP_DIR="${PACKAGE_TEMP_DIR}" \
TEMP="${PACKAGE_TEMP_DIR}" \
mono "${PACKAGE_DIR}/Duplicati.Server.exe" &
echo $! > "$PID_FILE"
cp -f ${PACKAGE_DIR}/dsm.duplicati.conf /usr/local/etc/nginx/conf.d/
else
echo "${PACKAGE_NAME_SIMPLE} already running."
fi
}
DaemonDebug() {
DaemonStatus
}
DaemonStop() {
DaemonStatus
if [ $? == 1 ]; then
echo "Stopping ${PACKAGE_NAME_SIMPLE}."
kill $(cat "$PID_FILE");
rm -f "$PID_FILE"
rm -f /usr/local/etc/nginx/conf.d/dsm.duplicati.conf
sleep 3
else
echo "Nothing to stop for ${PACKAGE_NAME_SIMPLE}."
fi
}
DaemonStatus() {
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if [ -n "$(ps | grep $PID | grep -vn "grep $PID")" ]; then
echo "${PACKAGE_NAME_SIMPLE} is running ..."
return 1 # is running
else
echo "${PACKAGE_NAME_SIMPLE} is NOT running ..."
rm -f ${PID_FILE} # Remove Invalid PID
return 0 # is NOT running
fi
else
echo "${PACKAGE_NAME_SIMPLE} is NOT running ...."
return 0 # is NOT running
fi
}
case $1 in
start)
DaemonStart
sleep 1
DaemonStatus
exit $(( ! $? )) # [ $? == 1 ] && exit 0 || exit 1 # this if statement flips the boolean outcome.
;;
stop)
DaemonStop
sleep 1
DaemonStatus
exit $?
;;
restart)
DaemonStop
sleep 10
DaemonStart
sleep 1
DaemonStatus
exit $(( ! $? )) # this if statement flips the boolean outcome.
;;
status)
DaemonStatus
exit $(( ! $? )) # this if statement flips the boolean outcome.
;;
debug)
DaemonDebug
exit 0
;;
log-show)
exit 0
;;
log-clear)
exit 0
;;
log)
exit 0
;;
*)
echo "Usage: $0 {start|stop|restart|status|debug|log|log-show|log-clear}"
exit 1
;;
esac
|