Alysha Creelman commited on
Commit
4c0b29a
·
unverified ·
1 Parent(s): 46211e7

Create testing_key_setup_groupkey.sh

Browse files
Files changed (1) hide show
  1. testing_key_setup_groupkey.sh +56 -0
testing_key_setup_groupkey.sh ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ PORT=22003
4
+ MACHINE=paffenroth-23.dyn.wpi.edu
5
+
6
+ # Clean up from previous runs
7
+ ssh-keygen -f "/home/amcreelman/.ssh/known_hosts" -R "[${MACHINE}]:${PORT}"
8
+ rm -rf tmp2
9
+
10
+ # Create a temporary directory
11
+ mkdir tmp2
12
+ cp wormington_keys/group_key* tmp2
13
+ cd tmp2
14
+
15
+ # Set permissions of the key and prepare the authorized_keys file
16
+ chmod 600 group_key*
17
+ cat group_key.pub > authorized_keys
18
+ chmod 600 authorized_keys
19
+
20
+ # Copy the authorized_keys file to the server
21
+ scp -i group_key -P ${PORT} -o StrictHostKeyChecking=no authorized_keys student-admin@${MACHINE}:~/.ssh/
22
+
23
+ # Add the key to the ssh-agent
24
+ eval "$(ssh-agent -s)"
25
+ ssh-add group_key
26
+
27
+ # Check the key file on the server
28
+ ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE} "cat ~/.ssh/authorized_keys"
29
+
30
+ # Clone or pull the latest code
31
+ git clone https://github.com/alyshacreelman/Wormington-Scholar || (cd Wormington-Scholar && git pull)
32
+
33
+ # Copy the files to the server
34
+ scp -P ${PORT} -o StrictHostKeyChecking=no -r Wormington-Scholar student-admin@${MACHINE}:~/
35
+
36
+ COMMAND="ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}"
37
+
38
+ # Stop the current chatbot instance
39
+ ${COMMAND} "pkill -f app.py"
40
+
41
+ # Check that the code is updated
42
+ ${COMMAND} "cat Wormington-Scholar/app.py | head -n 10"
43
+
44
+ # Setup and activate virtual environment
45
+ ${COMMAND} "sudo apt install -qq -y python3-venv"
46
+ ${COMMAND} "cd Wormington-Scholar && python3 -m venv venv"
47
+ ${COMMAND} "cd Wormington-Scholar && source venv/bin/activate && pip install -r requirements.txt"
48
+
49
+ # Clear cache
50
+ ${COMMAND} "find Wormington-Scholar/ -name '*.pyc' -delete"
51
+
52
+ # Start the chatbot
53
+ ${COMMAND} "nohup Wormington-Scholar/venv/bin/python3 Wormington-Scholar/app.py > log.txt 2>&1 &"
54
+
55
+ # Check the last lines of the log
56
+ ${COMMAND} "tail -n 20 log.txt"