Add deploy.sh

This commit is contained in:
Nico Schottelius 2021-01-17 15:47:37 +01:00
parent 48ce21f833
commit 6b9b15e663
1 changed files with 38 additions and 0 deletions

38
bin/deploy.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
# Nico Schottelius, 2021-01-17
set -e
if [ $# -ne 1 ]; then
echo "$0 target-host"
exit 1
fi
target_host=$1; shift
user=app
dir=${0%/*}
uncloud_base=$(cd ${dir}/.. && pwd -P)
conf_name=local_settings-${target_host}.py
conf_file=${uncloud_base}/uncloud/${conf_name}
if [ ! -e ${conf_file} ]; then
echo "No settings for ${target_host}."
echo "Create ${conf_file} before using this script."
exit 1
fi
# Deploy
rsync -av \
--exclude venv/ \
--exclude '*.pyc' \
--delete \
${uncloud_base}/ ${user}@${target_host}:app/
ssh "${user}@${target_host}" ". ~/pyvenv/bin/activate; cd ~/app; pip install -r requirements.txt"
# Config
ssh "${user}@${target_host}" "cd ~/app/uncloud; ln -sf ${conf_name} local_settings.py"
# Restart / Apply
ssh "${user}@${target_host}" "sudo /etc/init.d/uwsgi restart"