blob: b344bb5cb6cb8e9cf1f0f52260197535860bdfaa (
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
|
#!/bin/sh
# start/stop script adapted from cloudstation client 3.2-3487
INSTALL_PATH="/opt/Synology/CloudStation"
LIB_PATH="$INSTALL_PATH/lib"
BIN_PATH="$INSTALL_PATH/bin/syno-cloud-linux"
check_process()
{
pid=$1
kill -0 $pid > /dev/null 2>&1
if [ $? -eq 0 ]; then
return 1
else
return 0
fi
}
stop_process()
{
counter=0
pid=$1
kill $pid
while [ 1 ] ; do
check_process $pid
if [ $? -eq 0 ]; then
# already stop
break;
fi
if [ $counter -eq 10 ]; then
# force kill
kill -9 $pid
break;
fi
sleep 1
counter=$((counter+1))
done
}
gracefull_stop_service()
{
user_name=$1
home_path=`eval echo ~"$user_name"`
app_path="$home_path/.CloudStation"
pid_file="$app_path/ui.pid"
if [ ! -f "$pid_file" ]; then
#not running
return 0
fi
pid=`grep pid "$pid_file" | sed 's/pid=//g' | sed 's/"//g'`
stop_process $pid
}
start()
{
env "LD_LIBRARY_PATH=$LIB_PATH" "$BIN_PATH" &
}
stop()
{
gracefull_stop_service $USER
}
restart()
{
stop
start
}
autostart()
{
sleep 10
start
}
case $1 in
start)
start
exit $?
;;
autostart)
autostart
exit $?
;;
stop)
stop
exit $?
;;
restart)
restart
exit $?
;;
*)
start
exit $?
;;
esac
|