chore: configurable deployment
This commit is contained in:
1 parent
caeb47be11
commit
6be745a6f4
6 files changed
+62
-30
No files matched your search
+50
-21
@@ -2,42 +2,71 @@
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
host="root@hub.hordelab.com"
|
||||
remote_path="/var/horde/hub/"
|
||||
if [ ! -f .env ]; then
|
||||
echo ".env file not found. You can create one by copying the provided example:"
|
||||
echo "cp $(dirname "$0")/example.env $(dirname "$0")/.env"
|
||||
exit 1
|
||||
fi
|
||||
source .env
|
||||
|
||||
# Required: crash if not set in .env
|
||||
: "${domain:?domain is not defined in .env}"
|
||||
: "${install_path:?install_path is not defined in .env}"
|
||||
|
||||
# Optional: fall back to defaults
|
||||
: "${data_path:=$install_path/local-data}"
|
||||
: "${launch_path:=$data_path/hub-launch.sh}"
|
||||
: "${service_name:=horde-hub}"
|
||||
: "${port:=17922}"
|
||||
: "${remote:=$domain}"
|
||||
|
||||
read_template() {
|
||||
sed \
|
||||
-e "s/\$DOMAIN/$domain/g" \
|
||||
-e "s|\$INSTALL_PATH|$install_path|g" \
|
||||
-e "s|\$LAUNCH_PATH|$launch_path|g" \
|
||||
-e "s|\$DATA_PATH|$data_path|g" \
|
||||
-e "s/\$SERVICE_NAME/$service_name/g" \
|
||||
-e "s/\$PORT/$port/g" \
|
||||
template/$1
|
||||
}
|
||||
|
||||
upload_template() {
|
||||
read_template $1 | ssh $remote "cat > \"$2\""
|
||||
}
|
||||
|
||||
run_nginx() {
|
||||
echo "Uploading nginx config file"
|
||||
scp template/nginx.conf "$host:/etc/nginx/sites-enabled/hub.hordelab.com"
|
||||
ssh "$host" -t "
|
||||
nginx -s reload
|
||||
|
||||
upload_template nginx.conf "/etc/nginx/sites-enabled/$domain"
|
||||
ssh $remote -t "
|
||||
# full process is currently broken
|
||||
#certbot --keep -d hub.hordelab.com
|
||||
#certbot --keep -d $domain
|
||||
|
||||
# uncomment if needed
|
||||
#certbot certonly -d hub.hordelab.com
|
||||
#certbot certonly -d $domain
|
||||
|
||||
#nginx -s reload
|
||||
nginx -s reload
|
||||
"
|
||||
}
|
||||
|
||||
run_service() {
|
||||
echo "Uploading Launcher and Service"
|
||||
scp template/launch-hub.sh "$host:/var/horde/launch-hub.sh"
|
||||
scp template/systemd.service "$host:/etc/systemd/system/horde-hub.service"
|
||||
ssh "$host" -t "
|
||||
upload_template launch-hub.sh $launch_path
|
||||
upload_template systemd.service "/etc/systemd/system/$service_name.service"
|
||||
|
||||
ssh $remote -t "
|
||||
systemctl daemon-reload
|
||||
systemctl enable horde-hub.service
|
||||
systemctl start horde-hub.service
|
||||
systemctl enable $service_name.service
|
||||
systemctl start $service_name.service
|
||||
"
|
||||
}
|
||||
|
||||
run_update() {
|
||||
echo "Updating repository"
|
||||
ssh "$host" -t "
|
||||
ssh $remote -t "
|
||||
source ~/.nvm/nvm.sh #?
|
||||
|
||||
cd /var/horde/hub
|
||||
cd $install_path
|
||||
git pull
|
||||
make install
|
||||
make web
|
||||
@@ -45,14 +74,14 @@ run_update() {
|
||||
}
|
||||
|
||||
run_dist() {
|
||||
echo "Uploading frontend/dist to $host:/var/frontend/dist"
|
||||
ssh "$host" "rm -rf $remote_path/frontend/dist && mkdir $remote_path/frontend/dist"
|
||||
scp -r ../frontend/dist "$host:$remote_path/frontend/"
|
||||
echo "Uploading frontend/dist to $remote:$install_path/frontend/dist"
|
||||
ssh $remote "rm -rf $install_path/frontend/dist && mkdir $install_path/frontend/dist"
|
||||
scp -r ../frontend/dist $remote:$install_path/frontend/
|
||||
}
|
||||
|
||||
restart_service() {
|
||||
echo "Restarting horde-hub.service"
|
||||
ssh "$host" -t "systemctl restart horde-hub.service"
|
||||
echo "Restarting $service_name.service"
|
||||
ssh $remote -t "systemctl restart $service_name.service"
|
||||
}
|
||||
|
||||
# Determine which stages to run
|
||||
|
||||
Reference in new issue
Block a user