forked from friguzzi/swish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·92 lines (82 loc) · 1.89 KB
/
run.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
#!/usr/bin/env bash
#
# run.sh
#
# Copyright (C) 2016 frnmst (Franco Masotti) <[email protected]>
#
# This file is part of swish-installer.
#
# swish-installer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# swish-installer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with swish-installer. If not, see <http://www.gnu.org/licenses/>.
#
#
# This is the file called from the /usr/bin/trill-on-swish symlink
pkg_dir="/home/mlunife/trill-on-swish"
pid_file="/home/mlunife/trill-on-swish/swish.pid"
output_file="/home/mlunife/trill-on-swish/output.txt"
user="mlunife"
group="mlunife"
help()
{
cat<<-EOF
swish [OPTION]
SWI-Prolog for SHaring: a SWI-Prolog web IDE
Only a single option is permitted.
-h print this help
-k kill swish
-s start swish
Exit status:
0 if OK,
1 some error occurred.
Full documentation at: <https://github.com/SWI-Prolog/swish>
EOF
}
killd()
{
# kill action only if process exists.
if [ -f "$pid_file" ]; then
pid=$(cat "$pid_file")
ps -p $pid > /dev/null
if [ $? -eq 0 ]; then
kill -s TERM $pid
fi
fi
}
init()
{
:
}
remove()
{
:
}
startd()
{
local pid=""
{
(
cd "$pkg_dir"
./daemon.pl --port=3020 --pidfile="$pid_file" --output="$output_file"
)
}
}
case "$1" in
-s)
startd
;;
-k)
killd
;;
*)
help
esac