File tree Expand file tree Collapse file tree 1 file changed +89
-0
lines changed Expand file tree Collapse file tree 1 file changed +89
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ #
3+ # Run ChatScript
4+ #
5+
6+ BASEDIR=$( dirname $( readlink -f ${BASH_SOURCE[0]} ) )
7+
8+ show_help () {
9+ cat << EOF
10+ Usage: $0 [--local] [--port|-p <Server PORT>] [--users|-u <USERS DIR>] [--logs|-l <LOGS DIR>] [--topic|-t <TOPIC DIR>] [--tmp <TMP DIR>]
11+ --local Run in local mode.
12+ -p, --port Server port
13+ -u, --users Users directory
14+ -l, --logs Logs directory
15+ -t, --topic Topic directory
16+ --tmp TMP directory
17+ -h, --help Show help
18+ EOF
19+ }
20+
21+ abs_path () {
22+ if [[ ! " $1 " = /* ]]; then
23+ dir=$( pwd) /$1
24+ else
25+ dir=$1
26+ fi
27+ [[ $dir != ' /' ]] && dir=${dir%/ }
28+ echo $dir
29+ }
30+
31+ param=' '
32+ while [[ $# > 0 ]]; do
33+ case " $1 " in
34+ --local)
35+ param=" ${param} local"
36+ shift
37+ ;;
38+ --port|-p)
39+ param=" $param port=$2 "
40+ shift
41+ shift
42+ ;;
43+ --users|-u)
44+ dir=$( abs_path $2 )
45+ param=" $param users=$dir "
46+ [[ ! -d $dir ]] && echo " mkdir $dir " && mkdir -p $dir
47+ shift
48+ shift
49+ ;;
50+ --logs|-l)
51+ dir=$( abs_path $2 )
52+ param=" $param logs=$dir "
53+ [[ ! -d $dir ]] && echo " mkdir $dir " && mkdir -p $dir
54+ shift
55+ shift
56+ ;;
57+ --topic|-t)
58+ dir=$( abs_path $2 )
59+ param=" $param topic=$dir "
60+ [[ ! -d $dir ]] && echo " mkdir $dir " && mkdir -p $dir
61+ shift
62+ shift
63+ ;;
64+ --tmp)
65+ dir=$( abs_path $2 )
66+ param=" $param tmp=$dir "
67+ shift
68+ shift
69+ ;;
70+ --help|-h)
71+ show_help
72+ exit 0
73+ ;;
74+ * )
75+ echo " Unknown argument $1 "
76+ show_help
77+ exit 1
78+ ;;
79+ esac
80+ done
81+
82+ cd $BASEDIR
83+ while true ;
84+ do
85+ echo " Start at $( date) "
86+ BINARIES/LinuxChatScript64 $param
87+ echo " ChatScript is crashed. Restarting"
88+ sleep 1
89+ done
You can’t perform that action at this time.
0 commit comments