Skip to content

Commit

Permalink
Restart service unit after deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
mepley1 committed Jan 12, 2025
1 parent a6847bb commit 448156f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
#!/bin/sh
# Copy necessary application files to directory on prod server via SCP.
# Intended to be used after editing files, to easily update existing files on prod.
# Copy necessary application files to test server via SCP.
# Intended to be used after editing files, to save time updating existing files on live instance.
# Be very careful! Backup prod directory before using.
# The following will not be copied: user database, requests database, config.py, readme, license etc.

# Configure IP + auth
PROD_HOST=example.com
APP_PATH=/path/to/honeypot/honeypot
USERNAME=user
KEYFILE=~/.ssh/id_rsa

echo "Copying files..."
echo "Production host: $PROD_HOST"
echo "Copying files to $PROD_HOST"
echo "${USERNAME}@${PROD_HOST}:${APP_PATH}/project/"

scp -i $KEYFILE db_initialize.py create-user.py wsgi.py requirements.txt reset-password.py $USERNAME@$PROD_HOST:/root/honeypot/honeypot/
scp -i $KEYFILE -r ./project/static/ $USERNAME@$PROD_HOST:/root/honeypot/honeypot/project/
scp -i $KEYFILE -r ./project/templates/ $USERNAME@$PROD_HOST:/root/honeypot/honeypot/project/
scp -i $KEYFILE ./project/__init__.py ./project/auth.py ./project/main.py ./project/analysis.py ./project/models.py ./project/auto_report.py $USERNAME@$PROD_HOST:/root/honeypot/honeypot/project/
scp -i ${KEYFILE} db_initialize.py create-user.py wsgi.py requirements.txt reset-password.py ${USERNAME}@${PROD_HOST}:${APP_PATH}/
scp -i ${KEYFILE} -r ./project/static/ ${USERNAME}@${PROD_HOST}:${APP_PATH}/project/
scp -i ${KEYFILE} -r ./project/templates/ ${USERNAME}@${PROD_HOST}:${APP_PATH}/project/
scp -i ${KEYFILE} ./project/__init__.py ./project/auth.py ./project/main.py ./project/analysis.py ./project/models.py ./project/auto_report.py ${USERNAME}@${PROD_HOST}:${APP_PATH}/project/

# Don't overwrite current config on prod.
# Un-comment the following line ONLY if changing config.
#scp -i $KEYFILE ./project/config.py $USERNAME@$PROD_HOST:/root/honeypot/honeypot/project/
#scp -i ${KEYFILE} ./project/config.py ${USERNAME}@${PROD_HOST}:${APP_PATH}/project/

# Restart app to prevent any issues after files changed
echo "Restarting service..."
ssh -i ${KEYFILE} ${USERNAME}@${PROD_HOST} "sudo systemctl restart honeypot.service"

echo "Finished."

0 comments on commit 448156f

Please sign in to comment.