Add options to reinstall and skip backup
This commit is contained in:
parent
0d1e12c6c9
commit
d841795ff0
1 changed files with 24 additions and 10 deletions
|
@ -2,6 +2,8 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
tag=latest
|
tag=latest
|
||||||
dummy=false
|
dummy=false
|
||||||
|
no_backup=false
|
||||||
|
reinstall=false
|
||||||
token=""
|
token=""
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
|
@ -12,6 +14,8 @@ function usage() {
|
||||||
echo " -t|--tag <TAG> Release tag or 'latest' (default)."
|
echo " -t|--tag <TAG> Release tag or 'latest' (default)."
|
||||||
echo " -T|--token <TOKEN> Github token with read access to public repositories."
|
echo " -T|--token <TOKEN> Github token with read access to public repositories."
|
||||||
echo " -D|--dummy|--dry-run Run in Dry-mode without actually updating but showing the commands to execute."
|
echo " -D|--dummy|--dry-run Run in Dry-mode without actually updating but showing the commands to execute."
|
||||||
|
echo " -r|--reinstall Allow to reinstall the same tag."
|
||||||
|
echo " -n|--no-backup Don't do a backup of the database before the upgrade."
|
||||||
}
|
}
|
||||||
|
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
|
@ -40,6 +44,14 @@ do
|
||||||
shift
|
shift
|
||||||
dummy=true
|
dummy=true
|
||||||
;;
|
;;
|
||||||
|
'-n'|'--no-backup')
|
||||||
|
shift
|
||||||
|
no_backup=true
|
||||||
|
;;
|
||||||
|
'-r'|'--reinstall')
|
||||||
|
shift
|
||||||
|
reinstall=true
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
message "Unknown parameter '$1'" p
|
message "Unknown parameter '$1'" p
|
||||||
shift
|
shift
|
||||||
|
@ -86,7 +98,7 @@ if [ "${DEBUG}" == "true" ]; then
|
||||||
fi
|
fi
|
||||||
cd "${mastodon_home}/live" || exit 3
|
cd "${mastodon_home}/live" || exit 3
|
||||||
current_tag=$(git name-rev --name-only HEAD | awk 'BEGIN {FS="/"} {print($2)}')
|
current_tag=$(git name-rev --name-only HEAD | awk 'BEGIN {FS="/"} {print($2)}')
|
||||||
if [ "${current_tag}" != "${tag}" ]; then
|
if [ "${current_tag}" != "${tag}" ] || [ "${reinstall}" ]; then
|
||||||
if [ "${DEBUG}" == "true" ]; then
|
if [ "${DEBUG}" == "true" ]; then
|
||||||
echo "Fetching from repository..."
|
echo "Fetching from repository..."
|
||||||
fi
|
fi
|
||||||
|
@ -103,6 +115,7 @@ if [ "${current_tag}" != "${tag}" ]; then
|
||||||
else
|
else
|
||||||
sudo -u mastodon git checkout "${tag}"
|
sudo -u mastodon git checkout "${tag}"
|
||||||
fi
|
fi
|
||||||
|
if [ "${no_backup}" == "false" ]; then
|
||||||
current_date=$(date +%Y-%m-%d-%H-%M-%S)
|
current_date=$(date +%Y-%m-%d-%H-%M-%S)
|
||||||
mkdir -p /var/backups/postgres
|
mkdir -p /var/backups/postgres
|
||||||
backup_file="/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz"
|
backup_file="/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz"
|
||||||
|
@ -114,6 +127,7 @@ if [ "${current_tag}" != "${tag}" ]; then
|
||||||
fi
|
fi
|
||||||
sudo -u postgres pg_dump mastodon | gzip -c > "${backup_file}"
|
sudo -u postgres pg_dump mastodon | gzip -c > "${backup_file}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if [ "${DEBUG}" == "true" ]; then
|
if [ "${DEBUG}" == "true" ]; then
|
||||||
echo "Running bundle install..."
|
echo "Running bundle install..."
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue