-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathett
executable file
·42 lines (37 loc) · 1.21 KB
/
ett
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
#!/usr/bin/env zsh
flags=(-x -kill-other-sessions -v --logtostdout --silent -N --no-terminal -f --forward-ssh-agent)
et $@ && exit
if [[ $? -eq 1 ]]
then
echo "Failed to connect to EternalTerminal server. Attempting to start it remotely."
skiparg=0
for argument in $@
do
if [[ $skiparg -eq 0 ]]
then
# check if argument is a flag (with no parameter)
if [[ ${flags[(r)$argument]} == $argument ]]
then
skiparg=0
# assume the other arguments starting with '-' take a parameter
elif [[ $argument = $'-'* ]]
then
skiparg=1
else
host=$argument
break
fi
else
skiparg=0
fi
done
fi
echo "starting server on $host"
ssh $host -- 'nohup nice etserver -daemon > et.out 2> et.err < /dev/null &'
sleep 1
if [[ $? -eq 0 ]]
then
et $@
else
echo "Server failed to start. Giving up."
fi