-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·79 lines (63 loc) · 1.89 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
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
readonly DIRNAME=$(readlink -f $(dirname $0))
readonly URL=$1
# assert run as root, otherwise exit
if [ "$(id -u)" != "0" ]; then
echo "Please run `$0` as root." 1>&2
exit 1
fi
function arch_install {
local cmd=$1
local package=$2
if ! command -v $cmd &>/dev/null; then
echo "Installing $package for $cmd"
pacman -S $package
else
echo "$cmd already installed"
fi
}
function apt-get_install {
local cmd=$1
local package=$2
if ! command -v $cmd &>/dev/null; then
echo "Installing $package for $cmd"
apt-get install $package
else
echo "$cmd already installed"
fi
}
# install required programs
if command -v apt-get &>/dev/null; then
# install packages for apt-get based systems
apt-get_install python3 python3
apt-get_install pip3 python3-pip
# install requiired python modules
pip3 install -r requirements.txt
elif command -v pacman &>/dev/null; then
# install packages for pacman based systems
arch_install python3 python
arch_install pip python-pip
# install required python modules
pip install -r requirements.txt
else
echo "Sorry, we do not support automatic package installation for your package manager."
read -p "Do you want to continue anyway? " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn] ]]; then
exit 1
fi
fi
if [[ -z $URL ]]; then
# sed -i 's|replaceme|'$URL'|g' $DIRNAME/config.json
echo "webhook-url=$URL" >> $DIRNAME/crust.conf;
fi
ln -vis $DIRNAME/crust.py /opt/crust/crust.py
ln -vis $DIRNAME/crust.conf /opt/crust/crust.conf
# copy the actual service
cp $DIRNAME/crust.service /etc/systemd/system/crust.service
# make systemd aware of the new crust.service
systemctl daemon-reload
# enable the new crust.service to be run on boot
systemctl enable crust.service
# start service with new config
systemctl start crust.service