Add debug

This commit is contained in:
Antonio J. Delgado 2024-02-16 15:19:29 +02:00
parent 8e316ef798
commit 4bcc226c4b

View file

@ -53,6 +53,9 @@ if [ -z "${token}" ]; then
fi fi
if [ "${tag}" == "latest" ]; then if [ "${tag}" == "latest" ]; then
tag=$(curl -L -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${token}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/mastodon/mastodon/releases/latest | jq '.tag_name') tag=$(curl -L -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${token}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/mastodon/mastodon/releases/latest | jq '.tag_name')
if [ "${DEBUG}" == "true" ]; then
echo "Latest tag is '${tag}'"
fi
else else
if [ "${DEBUG}" == "true" ]; then if [ "${DEBUG}" == "true" ]; then
echo "Looking for tag '${tag}'..." echo "Looking for tag '${tag}'..."
@ -67,7 +70,7 @@ else
next_page=$(grep '< link: ' "${tmpfile}" | sed 's/< link: //g' | sed 's/, /\n/g' | grep 'rel="next"' | grep -o 'https://[^>]*') next_page=$(grep '< link: ' "${tmpfile}" | sed 's/< link: //g' | sed 's/, /\n/g' | grep 'rel="next"' | grep -o 'https://[^>]*')
done done
if ! pgrep "${tag}" "${releases_file}"; then if ! pgrep "${tag}" "${releases_file}"; then
echo "The tag '%s' is not part of the releases:\n%s" "${tag}" "${releases}" printf "The tag '%s' is not part of the releases:\n%s" "${tag}" "${releases}"
exit 1 exit 1
fi fi
fi fi
@ -84,16 +87,38 @@ if [ ! -d "${mastodon_home}" ]; then
exit 2 exit 2
fi fi
if [ "${DEBUG}" == "true" ]; then
echo "Changing to Mastodon's home directory '${mastodon_home}'..."
fi
cd "${mastodon_home}" || exit 3 cd "${mastodon_home}" || exit 3
if [ "${DEBUG}" == "true" ]; then
echo "Fetching from repository..."
fi
"${pre_command}"sudo -u mastodon git fetch "${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}" "${pre_command}"sudo -u mastodon git checkout "${tag}"
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"
if [ "${dummy}" == "true" ]; then if [ "${dummy}" == "true" ]; then
echo "sudo -u postgres pg_dump mastodon | gzip -c > \"/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz\"" echo "sudo -u postgres pg_dump mastodon | gzip -c > \"${backup_file}\""
else else
sudo -u postgres pg_dump mastodon | gzip -c > "/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz" 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
echo "Running bundle install..."
fi fi
"${pre_command}"sudo -u mastodon bundle install "${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 "${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 "${pre_command}"sudo systemctl restart mastodon-sidekiq.service mastodon-web.service mastodon-streaming mastodon-streaming@4000.service