Add check for current tag

This commit is contained in:
Antonio J. Delgado 2024-02-16 17:59:39 +02:00
parent d1f54072d4
commit f23f051c0d

View file

@ -91,34 +91,40 @@ if [ "${DEBUG}" == "true" ]; then
echo "Changing to Mastodon's home directory '${mastodon_home}'..."
fi
cd "${mastodon_home}" || exit 3
if [ "${DEBUG}" == "true" ]; then
current_tag=$(git name-rev --name-only HEAD | awk 'BEGIN {FS="/"} {print($2)}')
if [ "${current_tag}" != "${tag}" ]; then
if [ "${DEBUG}" == "true" ]; then
echo "Fetching from repository..."
fi
"${pre_command}"sudo -u mastodon git fetch
if [ "${DEBUG}" == "true" ]; then
fi
"${pre_command}"sudo -u mastodon git fetch
if [ "${DEBUG}" == "true" ]; then
echo "Changing to reference '${tag}'..."
fi
"${pre_command}"sudo -u mastodon git checkout "${tag}"
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
fi
"${pre_command}"sudo -u mastodon git checkout "${tag}"
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
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
if [ "${DEBUG}" == "true" ]; then
fi
if [ "${DEBUG}" == "true" ]; then
echo "Running bundle install..."
fi
"${pre_command}"sudo -u mastodon bundle install
if [ "${DEBUG}" == "true" ]; then
fi
"${pre_command}"sudo -u mastodon bundle install
if [ "${DEBUG}" == "true" ]; then
echo "Running yarm install..."
fi
"${pre_command}"sudo -u mastodon yarn install --frozen-lockfile
if [ "${DEBUG}" == "true" ]; then
fi
"${pre_command}"sudo -u mastodon yarn install --frozen-lockfile
if [ "${DEBUG}" == "true" ]; then
echo "Restarting Mastodon services..."
fi
"${pre_command}"sudo systemctl restart mastodon-sidekiq.service mastodon-web.service mastodon-streaming mastodon-streaming@4000.service
else
echo "Current branch is already '${tag}'"
exit 0
fi
"${pre_command}"sudo systemctl restart mastodon-sidekiq.service mastodon-web.service mastodon-streaming mastodon-streaming@4000.service