-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinstall.sh
More file actions
157 lines (145 loc) · 4.62 KB
/
install.sh
File metadata and controls
157 lines (145 loc) · 4.62 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
# Install script for My Free Farm Bash Bot on GNU/Linux
# Tested on Debian 8 - 13, Ubuntu 16.04.1 LTS, Linux Mint 19 & 21, Devuan 5
# and Bash on Windows 10 x64 Version 1703 Build 15063.0
set -e
echo "Running apt-get update..."
sudo apt-get -q update
if ! command -v jq &>/dev/null; then
echo "Installing jq..."
sudo apt-get -qq install jq
if ! command -v jq &>/dev/null; then
echo -e "jq could not be found. Cannot continue.\njq konnte nicht gefunden werden. Fortfahren nicht möglich."
sleep 5
exit 1
fi
fi
JQBIN="$(command -v jq) -r"
if ! $JQBIN -nj . 2>/dev/null 1>&2; then
echo -e "This version of jq seems to be too old. Make sure to include jessie-backports\nin your sources.list if you're using Debian Jessie. Cannot continue.\n"
echo -e "Die jq Version scheint veraltet zu sein. Falls Du Debian Jessie benutzt, füge\nin der sources.list jessie-backports hinzu. Fortfahren nicht möglich."
sleep 5
exit 1
fi
if [ -f /etc/debian_version ]; then
DVER=$(cat /etc/debian_version)
else
echo "Sorry, only Debian 8 - 13 are supported for the time being. Bailing out."
exit 1
fi
case $DVER in
8.*|*essie*)
PHPV=php5-cgi
;;
9.*|10.*|11.*|12.*|13.*|*tretch*|*uster*|*ookworm*|*rixie*|*sid*)
PHPV=php-cgi
;;
esac
LCONF=/etc/lighttpd/lighttpd.conf
BOTGUIROOT=/var/www/html/mffbashbot
echo "Installing needed packages..."
sudo apt-get -qq install lighttpd $PHPV screen logrotate cron unzip nano
cd
echo "Downloading My Free Farm Bash Bot..."
# just in case...
rm -f master.zip
rm -rf mffbashbot-master
wget -nv "https://github.com/HackerHarry/mffbashbot/archive/master.zip"
echo "Unpacking the archive..."
unzip -q master.zip
# make sure to preserve an existing directory at least once
if [ -d "mffbashbot" ]; then
rm -rf mffbashbot.old
mv mffbashbot mffbashbot.old
fi
mv mffbashbot-master mffbashbot
chmod 775 mffbashbot
cd ~/mffbashbot
echo "Setting permissions..."
find . -type d -exec chmod 775 {} +
find . -type f -exec chmod 664 {} +
chmod +x *.sh
case $DVER in
12.*|13.*|*ookworm*|*rixie*|*sid*)
chmod g+rx ~
;;
esac
echo "Configuring lighttpd..."
if grep -q 'server\.document-root\s\+=\s\+"/var/www"' $LCONF; then
sudo sed -i 's/server\.document-root\s\+=\s\+\"\/var\/www\"/server\.document-root = \"\/var\/www\/html\"/' $LCONF
sudo mkdir -p /var/www/html
fi
HTTPUSER=$(grep server.username $LCONF | sed -e 's/.*= \"\(.*\)\"/\1/')
if [ -z "$HTTPUSER" ]; then
echo "Webserver user could not be determined. Cannot continue."
sleep 5
exit 1
fi
sudo usermod -a -G $USER $HTTPUSER 2>/dev/null
if ! grep -q 'fastcgi\.server\s\+=\s\+(\s\+"\.php"' $LCONF; then
echo '
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/'$PHPV'",
"socket" => "/tmp/php.socket"
)))' | sudo tee --append $LCONF > /dev/null
fi
cd /etc/lighttpd/conf-enabled/
if [ ! -h 10-accesslog.conf ]; then
sudo ln -s ../conf-available/10-accesslog.conf 10-accesslog.conf
fi
if [ ! -h 10-fastcgi.conf ]; then
sudo ln -s ../conf-available/10-fastcgi.conf 10-fastcgi.conf
fi
if ! grep -q 'server\.stream-response-body\s\+=\s\+1' $LCONF; then
echo "server.stream-response-body = 1" | sudo tee --append $LCONF > /dev/null
fi
case $DVER in
13.*|*rixie*|*sid*)
sudo mkdir -p /etc/systemd/system/lighttpd.service.d
echo '[Service]
ProtectHome=no
NoNewPrivileges=no
PrivateTmp=no
ProtectProc=default' | sudo tee /etc/systemd/system/lighttpd.service.d/systemd-sucks.conf > /dev/null
sudo systemctl daemon-reload
;;
esac
sudo /etc/init.d/lighttpd restart
echo "Setting up GUI files..."
cd ~/mffbashbot
if [ -d "$BOTGUIROOT" ]; then
rm -rf ${BOTGUIROOT}.old
mv $BOTGUIROOT ${BOTGUIROOT}.old
fi
sudo mv mffbashbot-GUI $BOTGUIROOT
sudo chmod +x $BOTGUIROOT/script/*.sh
sudo sed -i 's/\/pi\//\/'$USER'\//' $BOTGUIROOT/config.php
echo $HTTPUSER' ALL=(ALL) NOPASSWD: /bin/kill' | sudo tee /etc/sudoers.d/www-data-kill-cmd > /dev/null
echo "Setting up logrotate..."
echo '/home/'$USER'/mffbashbot/*/mffbot.log
{
rotate 6
daily
su '$USER' '$USER'
missingok
notifempty
delaycompress
compress
} ' | sudo tee /etc/logrotate.d/mffbashbot > /dev/null
cd
echo
echo "Creating bot start script..."
echo '#!/usr/bin/env bash
cd
sudo /etc/init.d/lighttpd start' >startallbots.sh
chmod 775 startallbots.sh
# create .screenrc
if [ ! -f ~/.screenrc ]; then
echo 'hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y}"
defscrollback 5000' >~/.screenrc
fi
echo
echo "Done! Start the bot with ./startallbots.sh after adding farms using your browser."
echo "Fertig! Starte den Bot mit ./startallbots.sh nachdem Hinzufuegen von Farmen ueber den Browser."
sleep 5