Commit 45fe5bb1 authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

Add deployment script


Signed-off-by: Adrian Schollmeyer's avatarAdrian 'nex' Schollmeyer <adrian.schollmeyer@fem.tu-ilmenau.de>
parent 72c8d36c
#!/bin/bash
set -e
cd "$(dirname ${0})"
: ${TMP_MOUNT:=/tmp/netbox-user-scripts.deploy.d}
: ${REMOTE:=web-1}
: ${REMOTE_BASEDIR:=fem.tu-ilmenau.de}
: ${SCRIPTS_SUBDIR:=pythonweb/netbox/scripts}
deploy_target="${1}"
print_usage() {
echo "Usage: $0 <staging|production>"
}
info() {
echo "INFO --> $*"
}
err() {
echo "ERR *** $*"
}
die() {
err "$*"
exit 1
}
if [[ "${deploy_target}" == "staging" ]]; then
target="stagebox"
elif [[ "${deploy_target}" == "production" ]]; then
target="netbox"
else
print_usage
exit 1
fi
which sshfs > /dev/null || die "Failed to locate sshfs executable"
which fusermount > /dev/null || die "Failed to locate fusermount executable"
which rsync > /dev/null || die "Failed to locate rsync executable"
remote_url="${REMOTE}:${REMOTE_BASEDIR}/${target}/${SCRIPTS_SUBDIR}"
info "Mounting remote..."
mkdir -p "${TMP_MOUNT}"
sshfs "${remote_url}" "${TMP_MOUNT}" \
|| die "Mounting remote... Failed!"
info "Mounting remote... done"
info "Syncing files using rsync..."
rsync -rq --progress --delete ./*.py "${TMP_MOUNT}" \
&& info "Syncing files using rsync... done" \
|| err "Syncing files using rsync... Failed!"
info "Unmounting temporary mount..."
fusermount -u "${TMP_MOUNT}" \
|| die "Umounting temporary mount... Failed!"
info "Unmounting temporary mount... done"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment