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
|
||||
tag=latest
|
||||
dummy=false
|
||||
no_backup=false
|
||||
reinstall=false
|
||||
token=""
|
||||
|
||||
function usage() {
|
||||
|
@ -12,6 +14,8 @@ function usage() {
|
|||
echo " -t|--tag <TAG> Release tag or 'latest' (default)."
|
||||
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 " -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 ]
|
||||
|
@ -40,6 +44,14 @@ do
|
|||
shift
|
||||
dummy=true
|
||||
;;
|
||||
'-n'|'--no-backup')
|
||||
shift
|
||||
no_backup=true
|
||||
;;
|
||||
'-r'|'--reinstall')
|
||||
shift
|
||||
reinstall=true
|
||||
;;
|
||||
*)
|
||||
message "Unknown parameter '$1'" p
|
||||
shift
|
||||
|
@ -86,7 +98,7 @@ if [ "${DEBUG}" == "true" ]; then
|
|||
fi
|
||||
cd "${mastodon_home}/live" || exit 3
|
||||
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
|
||||
echo "Fetching from repository..."
|
||||
fi
|
||||
|
@ -103,16 +115,18 @@ if [ "${current_tag}" != "${tag}" ]; then
|
|||
else
|
||||
sudo -u mastodon git checkout "${tag}"
|
||||
fi
|
||||
current_date=$(date +%Y-%m-%d-%H-%M-%S)
|
||||
mkdir -p /var/backups/postgres
|
||||
backup_file="/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz"
|
||||
if [ "${dummy}" == "true" ]; then
|
||||
echo "sudo -u postgres pg_dump mastodon | gzip -c > \"${backup_file}\""
|
||||
else
|
||||
if [ "${DEBUG}" == "true" ]; then
|
||||
echo "Creating a backup of the database in '${backup_file}'..."
|
||||
if [ "${no_backup}" == "false" ]; then
|
||||
current_date=$(date +%Y-%m-%d-%H-%M-%S)
|
||||
mkdir -p /var/backups/postgres
|
||||
backup_file="/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz"
|
||||
if [ "${dummy}" == "true" ]; then
|
||||
echo "sudo -u postgres pg_dump mastodon | gzip -c > \"${backup_file}\""
|
||||
else
|
||||
if [ "${DEBUG}" == "true" ]; then
|
||||
echo "Creating a backup of the database in '${backup_file}'..."
|
||||
fi
|
||||
sudo -u postgres pg_dump mastodon | gzip -c > "${backup_file}"
|
||||
fi
|
||||
sudo -u postgres pg_dump mastodon | gzip -c > "${backup_file}"
|
||||
fi
|
||||
if [ "${DEBUG}" == "true" ]; then
|
||||
echo "Running bundle install..."
|
||||
|
|
Loading…
Reference in a new issue