-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheasy-install.sh
More file actions
executable file
·159 lines (142 loc) · 4.7 KB
/
Copy patheasy-install.sh
File metadata and controls
executable file
·159 lines (142 loc) · 4.7 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
158
#!/usr/bin/env bash
DESTDIR="massa_rmon"
# Check OS distro
hostnamectl | grep -i "ubuntu" > /dev/null
if [[ $? -ne 0 ]]
then
echo "Error: this installation uses Ubuntu-compatible commands and cannot be used in other OS distros."
echo "You can try to install service manually using this scenario: https://github.com/dex2code/massa_rmon/blob/main/README.md"
exit 1
else
cd ~
fi
echo
echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
echo "::'##::::'##::::'###:::::'######:::'######:::::'###:::::"
echo ":::###::'###:::'## ##:::'##... ##:'##... ##:::'## ##::::"
echo ":::####'####::'##:. ##:: ##:::..:: ##:::..:::'##:. ##:::"
echo ":::## ### ##:'##:::. ##:. ######::. ######::'##:::. ##::"
echo ":::##. #: ##: #########::..... ##::..... ##: #########::"
echo ":::##:.:: ##: ##.... ##:'##::: ##:'##::: ##: ##.... ##::"
echo ":::##:::: ##: ##:::: ##:. ######::. ######:: ##:::: ##::"
echo "::..:::::..::..:::::..:::......::::......:::..:::::..:::"
echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
echo
echo "[ MASSA remote monitoring service ] -- https://github.com/dex2code/massa_rmon.git"
echo
echo "This script will configure your system and install all neccessary software:"
echo " - python3-full"
echo " - python3-venv"
echo " - python3-pip"
echo " - git"
echo
echo "New Python virtual environment will be created in '$HOME/$DESTDIR' and new systemd unit will be created."
echo -n "If you are ok with this please hit Enter, otherwise Ctrl+C to quit the installation... "
read _
echo
echo -n "First we update your repository and install all packages. Press Enter to continue... "
read _
echo
sudo apt-get update
if [[ $? -eq 0 ]]
then
echo "*** Updating finished!"
echo
else
echo
echo "Some error occured during updating. Please check your settings."
exit 1
fi
sudo apt-get -y install git python3-full python3-venv python3-pip
if [[ $? -eq 0 ]]
then
echo "*** All dependecies installed!"
echo
else
echo
echo "Some error occured during installation. Please check your settings."
exit 1
fi
echo -n "Now we clone repo to download service software. Press Enter to continue... "
read _
echo
git clone https://github.com/dex2code/massa_rmon.git
if [[ $? -eq 0 ]]
then
echo "*** Repo cloned successfully!"
echo
else
echo
echo "Some error occured during repo cloning. Please check your settings."
exit 1
fi
echo -n "Now we are ready to create and configure Python virtual environment. Press Enter to continue... "
read _
echo
cd $DESTDIR && python3 -m venv .
if [[ $? -eq 0 ]]
then
echo "*** Virtual environment created successfully! Configureng venv..."
echo
else
echo
echo "Some error occured during venv creating. Please check your settings."
exit 1
fi
source ./bin/activate && ./bin/pip3 install pip --upgrade && ./bin/pip3 install -r ./requirements.txt
if [[ $? -eq 0 ]]
then
echo "*** Virtual environment configured successfully!"
echo
else
echo
echo "Some error occured during venv configuring. Please check your settings."
exit 1
fi
echo -n "It's time to create systemd unit. Press Enter to continue... "
read _
echo
echo -n "*** Generating service file... "
echo "
[Unit]
Description=MASSA Remote Monitoring service
Wants=network.target
After=network.target
[Service]
Type=idle
User=$USER
WorkingDirectory=$HOME/$DESTDIR
ExecStart=$HOME/$DESTDIR/bin/python3 main.py
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.target
" > ./massa_rmon.service && sudo cp ./massa_rmon.service /etc/systemd/system/massa_rmon.service && sudo systemctl daemon-reload
if [[ $? -eq 0 ]]
then
echo "Done!"
echo
else
echo
echo "Some error occured during systemd configuring. Please check your settings."
exit 1
fi
echo -n "*** Installation done! Press Enter to continue... "
read _
clear
echo
echo "Now you need to configure the service and start it."
echo
echo "Please note if you watch remote MASSA node you MUST open firewall on your node host."
echo "You can do it with command 'sudo ufw allow 33035/tcp'. If your firewall is closed for 33035/tcp port - your node will be unavailable for monitoring service."
echo "You don't need to open firewall if you watch local (127.0.0.1) host."
echo
echo "Service settings are located in '~/$DESTDIR/settings.json' file and you can edit it with 'nano ~/$DESTDIR/settings.json' command."
echo "After it you can start service with command 'sudo systemctl start massa_rmon.service'."
echo
echo "If something goes wrong please see logfile: 'tail ~/$DESTDIR/main.log'."
echo
echo "If everything is fine please enable service with command 'sudo systemctl enable massa_rmon.service' to restore it after server reboot."
echo
echo "More information here: https://github.com/dex2code/massa_rmon.git"
echo