forked from ChatScript/ChatScript
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrun.sh
executable file
·89 lines (84 loc) · 1.92 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
#!/usr/bin/env bash
#
# Run ChatScript
#
BASEDIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
show_help() {
cat << EOF
Usage: $0 [--local] [--port|-p <Server PORT>] [--users|-u <USERS DIR>] [--logs|-l <LOGS DIR>] [--topic|-t <TOPIC DIR>] [--tmp <TMP DIR>]
--local Run in local mode.
-p, --port Server port
-u, --users Users directory
-l, --logs Logs directory
-t, --topic Topic directory
--tmp TMP directory
-h, --help Show help
EOF
}
abs_path() {
if [[ ! "$1" = /* ]]; then
dir=$(pwd)/$1
else
dir=$1
fi
[[ $dir != '/' ]] && dir=${dir%/}
echo $dir
}
param=''
while [[ $# > 0 ]]; do
case "$1" in
--local)
param="${param} local"
shift
;;
--port|-p)
param="$param port=$2"
shift
shift
;;
--users|-u)
dir=$(abs_path $2)
param="$param users=$dir"
[[ ! -d $dir ]] && echo "mkdir $dir" && mkdir -p $dir
shift
shift
;;
--logs|-l)
dir=$(abs_path $2)
param="$param logs=$dir"
[[ ! -d $dir ]] && echo "mkdir $dir" && mkdir -p $dir
shift
shift
;;
--topic|-t)
dir=$(abs_path $2)
param="$param topic=$dir"
[[ ! -d $dir ]] && echo "mkdir $dir" && mkdir -p $dir
shift
shift
;;
--tmp)
dir=$(abs_path $2)
param="$param tmp=$dir"
shift
shift
;;
--help|-h)
show_help
exit 0
;;
*)
echo "Unknown argument $1"
show_help
exit 1
;;
esac
done
cd $BASEDIR
while true;
do
echo "Start at $(date)"
BINARIES/LinuxChatScript64 $param
echo "ChatScript is crashed. Restarting"
sleep 1
done