JCai commited on
Commit
58c8e18
1 Parent(s): 70356da

modify script names

Browse files
automated_deployment.sh CHANGED
@@ -1,6 +1,5 @@
1
  #! /bin/bash
2
 
3
- # Load environment variables from .env file
4
  if [ -f .env ]; then
5
  source .env # loads the variables into current shell session
6
  else
@@ -8,17 +7,45 @@ else
8
  exit 1
9
  fi
10
 
11
- # ssh into the vm
12
- # check that the code in installed and start up the product
13
- COMMAND="ssh -i ${CS2_KEY_PATH} -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}"
14
 
15
- # clone the repo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ${COMMAND} "git clone https://github.com/jcai0o0/cs553-case-study-1.git"
17
- # install python3-venv
18
  ${COMMAND} "sudo apt install -qq -y python3-venv"
19
  # use the COMMAND to the repo folder and create virtual environment named cs2_venv
20
  ${COMMAND} "cd cs553-case-study-1 && python3 -m venv cs2_venv"
21
- # use the COMMAND to cd to the repo folder, activate the cs2_venv virtual environment, and install all required packages
22
  ${COMMAND} "cd cs553-case-study-1 && source cs2_venv/bin/activate && pip install -r requirements.txt"
23
  # make the product up and run in the background, put running log in file log.txt
24
- ${COMMAND} "nohup cs553-case-study-1/cs2_venv/bin/python3 cs553-case-study-1/app.py > log.txt 2>&1 &"
 
1
  #! /bin/bash
2
 
 
3
  if [ -f .env ]; then
4
  source .env # loads the variables into current shell session
5
  else
 
7
  exit 1
8
  fi
9
 
 
 
 
10
 
11
+ # Check if connection works with student-admin_key
12
+ ssh -i ${STUDENT-ADMIN_KEY} -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE} "echo 'SSH connection with student-admin_key successfully'"
13
+
14
+ # Create a unique key
15
+ ssh-keygen -f cs2_key -t ed25519 -N ${KEY_PASSWORD}
16
+
17
+ # Insert the key into the authorized_keys file on the server
18
+ # One > creates
19
+ cat mykey.pub > authorized_keys
20
+
21
+ chmod 600 authorized_keys
22
+
23
+ echo "checking that the authorized_keys file is correct"
24
+ ls -l authorized_keys
25
+ cat authorized_keys
26
+
27
+ # Copy the authorized_keys file to the server
28
+ scp -i ${STUDENT-ADMIN_KEY} -P ${PORT} -o StrictHostKeyChecking=no authorized_keys student-admin@${MACHINE}:~/.ssh/
29
+
30
+ # Add the key to the ssh-agent
31
+ eval "$(ssh-agent -s)"
32
+ ssh-add cs2_key
33
+
34
+ # Check the key file on the server
35
+ echo "checking that the authorized_keys file is correct"
36
+ ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE} "cat ~/.ssh/authorized_keys"
37
+
38
+ # make the prefix command
39
+ COMMAND="ssh -i ${CS2_KEY} -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}"
40
+ # COMMAND="ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}" # not including key is also okay
41
+
42
+ # use the COMMAND to run git clone to clone the repo to VM
43
  ${COMMAND} "git clone https://github.com/jcai0o0/cs553-case-study-1.git"
44
+ # use the COMMAND to install python3-venv
45
  ${COMMAND} "sudo apt install -qq -y python3-venv"
46
  # use the COMMAND to the repo folder and create virtual environment named cs2_venv
47
  ${COMMAND} "cd cs553-case-study-1 && python3 -m venv cs2_venv"
48
+ # use the COMMAND to cd to the repo folder, activate the cs2_venv virtual environemt, and install all required packages
49
  ${COMMAND} "cd cs553-case-study-1 && source cs2_venv/bin/activate && pip install -r requirements.txt"
50
  # make the product up and run in the background, put running log in file log.txt
51
+ ${COMMAND} "nohup cs553-case-study-1/venv/bin/python3 CS553_example/app.py > log.txt 2>&1 &"
auto_first_deploy.sh → recovery-deployment.sh RENAMED
@@ -1,5 +1,6 @@
1
  #! /bin/bash
2
 
 
3
  if [ -f .env ]; then
4
  source .env # loads the variables into current shell session
5
  else
@@ -7,45 +8,17 @@ else
7
  exit 1
8
  fi
9
 
 
 
 
10
 
11
- # Check if connection works with student-admin_key
12
- ssh -i ${STUDENT-ADMIN_KEY} -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE} "echo 'SSH connection with student-admin_key successfully'"
13
-
14
- # Create a unique key
15
- ssh-keygen -f cs2_key -t ed25519 -N ${KEY_PASSWORD}
16
-
17
- # Insert the key into the authorized_keys file on the server
18
- # One > creates
19
- cat mykey.pub > authorized_keys
20
-
21
- chmod 600 authorized_keys
22
-
23
- echo "checking that the authorized_keys file is correct"
24
- ls -l authorized_keys
25
- cat authorized_keys
26
-
27
- # Copy the authorized_keys file to the server
28
- scp -i ${STUDENT-ADMIN_KEY} -P ${PORT} -o StrictHostKeyChecking=no authorized_keys student-admin@${MACHINE}:~/.ssh/
29
-
30
- # Add the key to the ssh-agent
31
- eval "$(ssh-agent -s)"
32
- ssh-add cs2_key
33
-
34
- # Check the key file on the server
35
- echo "checking that the authorized_keys file is correct"
36
- ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE} "cat ~/.ssh/authorized_keys"
37
-
38
- # make the prefix command
39
- COMMAND="ssh -i ${CS2_KEY} -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}"
40
- # COMMAND="ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}" # not including key is also okay
41
-
42
- # use the COMMAND to run git clone to clone the repo to VM
43
  ${COMMAND} "git clone https://github.com/jcai0o0/cs553-case-study-1.git"
44
- # use the COMMAND to install python3-venv
45
  ${COMMAND} "sudo apt install -qq -y python3-venv"
46
  # use the COMMAND to the repo folder and create virtual environment named cs2_venv
47
  ${COMMAND} "cd cs553-case-study-1 && python3 -m venv cs2_venv"
48
- # use the COMMAND to cd to the repo folder, activate the cs2_venv virtual environemt, and install all required packages
49
  ${COMMAND} "cd cs553-case-study-1 && source cs2_venv/bin/activate && pip install -r requirements.txt"
50
  # make the product up and run in the background, put running log in file log.txt
51
- ${COMMAND} "nohup cs553-case-study-1/venv/bin/python3 CS553_example/app.py > log.txt 2>&1 &"
 
1
  #! /bin/bash
2
 
3
+ # Load environment variables from .env file
4
  if [ -f .env ]; then
5
  source .env # loads the variables into current shell session
6
  else
 
8
  exit 1
9
  fi
10
 
11
+ # ssh into the vm
12
+ # check that the code in installed and start up the product
13
+ COMMAND="ssh -i ${CS2_KEY_PATH} -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}"
14
 
15
+ # clone the repo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ${COMMAND} "git clone https://github.com/jcai0o0/cs553-case-study-1.git"
17
+ # install python3-venv
18
  ${COMMAND} "sudo apt install -qq -y python3-venv"
19
  # use the COMMAND to the repo folder and create virtual environment named cs2_venv
20
  ${COMMAND} "cd cs553-case-study-1 && python3 -m venv cs2_venv"
21
+ # use the COMMAND to cd to the repo folder, activate the cs2_venv virtual environment, and install all required packages
22
  ${COMMAND} "cd cs553-case-study-1 && source cs2_venv/bin/activate && pip install -r requirements.txt"
23
  # make the product up and run in the background, put running log in file log.txt
24
+ ${COMMAND} "nohup cs553-case-study-1/cs2_venv/bin/python3 cs553-case-study-1/app.py > log.txt 2>&1 &"
watcher.py CHANGED
@@ -13,7 +13,7 @@ load_dotenv()
13
  VM_IP = os.getenv("MACHINE")
14
  GRADIO_UI_URL = "http://paffenroth-23.dyn.wpi.edu:8005/"
15
  CHECK_INTERVAL = 60 # 60 seconds
16
- RECOVERY_SCRIPT_PATH = 'automated_deployment.sh'
17
 
18
 
19
  # Email settings (if EMAIL_ALERT is True)
 
13
  VM_IP = os.getenv("MACHINE")
14
  GRADIO_UI_URL = "http://paffenroth-23.dyn.wpi.edu:8005/"
15
  CHECK_INTERVAL = 60 # 60 seconds
16
+ RECOVERY_SCRIPT_PATH = 'recovery-deployment.sh'
17
 
18
 
19
  # Email settings (if EMAIL_ALERT is True)