-
Notifications
You must be signed in to change notification settings - Fork 3
/
nocrash.sh
69 lines (63 loc) · 1.38 KB
/
nocrash.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
#!/bin/bash
#Mostly copied from the nocrash.sh (https://github.com/Charcoal-SE/SmokeDetector/blob/master/nocrash.sh)
#on Smoke Detector made by Charcoal (https://github.com/Charcoal-SE/SmokeDetector)
read -p "Username: " u
export ChatExchangeU=$u
export CEU="h"
stty -echo
read -p "Password: " p
export ChatExchangeP=$p
stty echo
echo
echo "Welcome Bot Host Site Options (select 1, 2, or 3)"
echo " 1. chat.stackexchange.com"
echo " 2. chat.meta.stackexchange.com"
echo " 3. chat.stackoverflow.com"
read -p "What will be your Welcome Bot's host site? " h
export HostSite=$h
read -p "What is the room's ID? " i
export RoomID=$i
read -p "What is the welcome message? " m
export WelcomeMessage=$m
count=0
crashcount=0
stoprunning=0
while [ "$stoprunning" -eq "0" ]
do
if [ "$count" -eq "0" ]
then
python2 welcomebot.py first_start
else
python2 welcomebot.py
fi
ecode=$?
if [ "$ecode" -eq "3" ]
then
git checkout master
git pull
git submodule update
count=0
crashcount=0
elif [ "$ecode" -eq "4" ]
then
count=$((count+1))
sleep 5
if [ "$crashcount" -eq "2" ]
then
git checkout HEAD~1
count=0
crashcount=0
else
crashcount=$((crashcount+1))
fi
elif [ "$ecode" -eq "5" ]
then
count=0
elif [ "$ecode" -eq "6" ]
then
stoprunning=1
else
sleep 5
count=$((count+1))
fi
done