-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·61 lines (53 loc) · 1.86 KB
/
install.sh
File metadata and controls
executable file
·61 lines (53 loc) · 1.86 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
#!/bin/bash
# Installation script for current web server
src_path=$(dirname $(realpath $0))
server_name=$(basename $src_path)
read -p "Target ip address (default: 10.3.141.1) " TARGET_IP
read -p "Target user (default: ubuntu):" TARGET_USER
if [ -z "$TARGET_IP" ]
then
TARGET_IP=10.3.141.1
fi
if [ -z "$TARGET_USER" ]
then
TARGET_USER=ubuntu
fi
echo "Using target: $TARGET_USER@$TARGET_IP"
echo "$TARGET_USER@$TARGET_IP's password: "
read -s PASSWORD
# Build client and send to target machine
cd $src_path/client
npm install --legacy-peer-deps
npm run build
cd $src_path
scp -pr server/. $TARGET_USER@$TARGET_IP:~/$server_name/
# Install required python packages
read -r -p "Update required Python packages? [Y/n] " response
case "$response" in
[nN][oO]|[nN])
;;
*)
requirements=`cat $src_path/requirements.txt | tr '\n' ' '`
echo $PASSWORD | ssh -tt $TARGET_USER@$TARGET_IP "sudo python3 -m pip install $requirements"
;;
esac
# Set up supervisorctl
read -r -p "Reconfigure Supervisor [Y/n] " response
case "$response" in
[nN][oO]|[nN]) ;;
*)
read -p "Enter slackbot token, if any, otherwise leave empty: " SLACK_TOKEN
read -p "Password for the NAO robot that will be controlled: " NAO_PASSWORD
echo
supervisor_conf="[program:${server_name}]
stopsignal=INT
command=/usr/bin/python3 /home/$TARGET_USER/$server_name/run.py
autostart=true
autorestart=true
stderr_logfile=/logs/${server_name}.err.log
stdout_logfile=/logs/${server_name}.out.log
environment=SLACK_TOKEN=\\\"${SLACK_TOKEN}\\\",NAO_PASSWORD=\\\"${NAO_PASSWORD}\\\"
"
echo $PASSWORD | ssh -tt $TARGET_USER@$TARGET_IP "echo \"$supervisor_conf\" | sudo tee /etc/supervisor/conf.d/$server_name.conf >/dev/null && sudo supervisorctl reread && sudo supervisorctl update"
;;
esac