This repository has been archived by the owner on May 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 603
/
run_linuxmac.sh
executable file
·138 lines (130 loc) · 3.93 KB
/
run_linuxmac.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
cd "$(dirname "$0")"
if [ $? -eq 0 ]; then
echo ""
else
echo "Unable to set script's directory as the current working directory. You will need to make sure you run the script from it's directory."
fi
branch=$(git rev-parse --abbrev-ref HEAD)
updater () {
echo "Starting auto-update"
if hash git 2>/dev/null; then
echo "Fetching origin"
git init >/dev/null 2>&1
git remote add origin https://github.com/appu1232/Discord-Selfbot.git >/dev/null 2>&1
git fetch origin $branch
if [ -d "settings" ]; then
cp -r settings settings_backup
fi
new=$(git remote show origin)
if [[ "${new}" =~ "up" ]] || [[ "${new}" =~ "fast-forwardable" ]] ; then
echo "The bot is up to date."
sleep 1
else
read -t 10 -n 1 -p "There is an update available. Download now? (y/n):" input
if [[ "$input" =~ "y" ]] ; then
echo ""
echo "Installing update"
echo "Updating to latest stable build."
if git pull origin master ; then
echo "Update succeeded"
sleep 2
else
echo "Pull failed, attempting to hard reset to origin $branch (settings are still saved)"
git fetch --all
git reset --hard origin/$branch
echo "Update succeeded"
sleep 2
fi
else
echo ""
echo "Cancelled update"
fi
fi
sleep 1
else
echo "You do not have git installed. Auto-update is not currently supported" # TODO HTTP update
echo "Git is almost certainly available from your package manager. Install with:"
echo "sudo apt-get install git-all"
fi
}
min_updater() {
if hash git 2>/dev/null; then
if [ -d "settings" ]; then
cp -r settings settings_backup
fi
git fetch origin $branch
echo ""
echo "Installing update"
echo "Updating to latest stable build."
if git pull origin $branch ; then
echo "Update succeeded"
sleep 2
else
echo "Pull failed, attempting to hard reset to origin $nranch (settings are still saved)"
git fetch --all
git reset --hard origin/$branch
echo "Update succeeded"
sleep 2
fi
sleep 1
else
echo "You do not have git installed. Auto-update is not currently supported" # TODO HTTP update
echo "Git is almost certainly available from your package manager. Install with:"
echo "sudo apt-get install git-all"
fi
}
run_bot() {
echo "Checking requirements..."
if hash python3 2>/dev/null; then # TODO abstracify all this which mirrors above an also look up boolean operators in sh
echo "Using pip as a python3 module"
echo "Upgrading requirements"
if python3 -m pip install --user --upgrade -r requirements.txt; then
echo "Starting bot..."
python3 loopself.py
ret=$?
if [ $ret == "15" ]; then
min_updater
run_bot
else
echo "Shutting down"
fi
else
echo "Requirements installation failed"
exit 254
fi
elif hash python 2>/dev/null; then # TODO abstracify all this which mirrors above an also look up boolean operators in sh
case "$(python --version 2>&1)" in
*" 3."*)
echo ""
;;
*)
echo "Wrong Python version!"
echo "You need python 3.5.2 or up to use this bot!"
exit
;;
esac
echo "Using pip as a python3 module"
echo "Upgrading requirements"
if python -m pip install --user -r requirements.txt; then
echo "Starting bot..."
python loopself.py
ret=$?
if [ $ret == "15" ]; then
min_updater
run_bot
else
echo "Shutting down"
fi
else
echo "Requirements installation failed"
exit 254
fi
else
echo "You do not appear to have Python 3 installed"
echo "Python 3 is almost certainly available from your package manager or just google how to get it"
echo "However if you are, for instance, using Linux from Scratch, you likely do not need instruction"
fi
}
updater
run_bot