-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
setup.sh
84 lines (69 loc) · 2.59 KB
/
setup.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
#!/usr/bin/env bash
################################################################################
# Help #
################################################################################
Help()
{
# Display Help
echo "Displays some help for the Setupscript."
echo
echo "Syntax: [-c|h]"
echo "options:"
echo "c Configure mosquitto"
echo "h Print this Help."
echo
}
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
echo "-----------------------------------------------------------------------"
echo " _ _ _____ _____ _____ _____ ______ _____ _____ _____ _____"
echo "| | | || ___|/ __ \|_ _|| _ || ___ \ | _ || _ || _ || _ |"
echo "| |_| || |__ | / \/ | | | | | || |_/ / | |_| || |/' || |/' || |/' |"
echo "| _ || __| | | | | | | | || / \____ || /| || /| || /| |"
echo "| | | || |___ | \__/\ | | \ \_/ /| |\ \ .___/ /\ |_/ /\ |_/ /\ |_/ /"
echo "\_| |_/\____/ \____/ \_/ \___/ \_| \_| \____/ \___/ \___/ \___/"
echo "-----------------------------------------------------------------------"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
doconfig=0;
while getopts ":c" option; do
# shellcheck disable=SC2220
case $option in
c)
doconfig=1;
esac
done
echo "Upgrade System"
apt update
apt upgrade -y
echo "Install needed packages"
apt install python3 -y
apt install pip3 -y
apt install python3-pip -y
apt install python3-setuptools -y
apt install mosquitto -y
apt install nohup -y
# shellcheck disable=SC1073
if [ "$doconfig" = 1 ];
then
echo "Update mosquitto config"
systemctl stop mosquitto
cp /etc/mosquitto/mosquitto.conf /etc/mosquitto/mosquitto.conf.old
rm /etc/mosquitto/mosquitto.conf
touch /etc/mosquitto/mosquitto.conf
# shellcheck disable=SC2129
echo "listener 1883" >> /etc/mosquitto/mosquitto.conf
echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf
echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf
echo 'socket_domain ipv4' >> /etc/mosquitto/mosquitto.conf
echo 'allow_anonymous true' >> /etc/mosquitto/mosquitto.conf
systemctl start mosquitto
fi
echo "install Hector9000"
#pip install -e .
python setup.py develop