-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·70 lines (55 loc) · 1.6 KB
/
install.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
#!/bin/bash
error() {
printf '[-] ' >&2
printf "$@" >&2
printf '\n' >&2
}
######
# configuration
######
export DEB_PACKAGES="python3 python3-pip sqlite3"
export BIN_PATH="/usr/local/bin/cryptobot"
export BIN_SIM_PATH="/usr/local/bin/cryptobot"
export SHARE_PATH="/usr/share/cryptobot"
export LOG_FILE_PATH="/var/log/cryptobot.log"
export SYSTEMD_PATH="/usr/lib/systemd/system"
######
# script
######
if [ "x$EUID" != "x0" ]; then
error 'This script must be run as root'
exit 2
fi
if [ ! -f "/usr/bin/apt-get" ]; then
error 'This script is intended to be ran on a Debian-based system'
exit 2
fi
cd "$(dirname "$0")"
set -e
# ensure packages are installed
for package in ${DEB_PACKAGES[@]}; do
if ! dpkg -s "$package" >/dev/null 2>&1; then
error 'Package "%s" is required, installing...' "$package"
apt-get install "$package"
fi
done
pip3 install --upgrade -r requirements.txt
./setup.py install
mkdir -p "$SHARE_PATH"
cp -n config.yml.example "${SHARE_PATH}/config.yml"
useradd cryptobot || true
chown -R cryptobot:cryptobot "$SHARE_PATH" "$LOG_FILE_PATH"
chmod -R 600 "$SHARE_PATH" "$LOG_FILE_PATH"
chmod 755 "$SHARE_PATH"
chown root:cryptobot "$BIN_PATH"
chmod 750 "$BIN_PATH"
chown root:cryptobot "$BIN_SIM_PATH"
chmod 750 "$BIN_SIM_PATH"
cp -u cryptobot.service cryptobot.timer "$SYSTEMD_PATH"
cp -u cryptobot-check-price.service cryptobot-check-price.timer "$SYSTEMD_PATH"
"$BIN_PATH" status
systemctl daemon-reload
systemctl enable cryptobot.timer
systemctl start cryptobot.timer
systemctl enable cryptobot-check-price.timer
systemctl start cryptobot-check-price.timer