Fix dummy message and token check and compress backup
This commit is contained in:
parent
6bf4d90fbe
commit
8e316ef798
1 changed files with 15 additions and 3 deletions
|
@ -47,9 +47,16 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -z "${token}" ]; then
|
||||||
|
echo "You must provide a Github token"
|
||||||
|
exit 4
|
||||||
|
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')
|
||||||
else
|
else
|
||||||
|
if [ "${DEBUG}" == "true" ]; then
|
||||||
|
echo "Looking for tag '${tag}'..."
|
||||||
|
fi
|
||||||
next_page=https://api.github.com/repos/mastodon/mastodon/releases
|
next_page=https://api.github.com/repos/mastodon/mastodon/releases
|
||||||
releases_file=$(mktemp /tmp/tmp.XXXX)
|
releases_file=$(mktemp /tmp/tmp.XXXX)
|
||||||
while [ -z "${next_page}" ]
|
while [ -z "${next_page}" ]
|
||||||
|
@ -60,7 +67,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
|
||||||
printf "The tag '%s' is not part of the releases:\n%s" "${tag}" "${releases}"
|
echo "The tag '%s' is not part of the releases:\n%s" "${tag}" "${releases}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -71,7 +78,7 @@ else
|
||||||
pre_command=""
|
pre_command=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mastodon_home=$(grep "^mastodon:" /etc/passwd | awk 'BEGIN {FS=":"} {print($7)}')
|
mastodon_home=$(grep "^mastodon:" /etc/passwd | awk 'BEGIN {FS=":"} {print($6)}')
|
||||||
if [ ! -d "${mastodon_home}" ]; then
|
if [ ! -d "${mastodon_home}" ]; then
|
||||||
printf "The home for the user mastodon '%s', doesn't exist." "${mastodon_home}"
|
printf "The home for the user mastodon '%s', doesn't exist." "${mastodon_home}"
|
||||||
exit 2
|
exit 2
|
||||||
|
@ -81,7 +88,12 @@ cd "${mastodon_home}" || exit 3
|
||||||
"${pre_command}" sudo -u mastodon git fetch
|
"${pre_command}" sudo -u mastodon git fetch
|
||||||
"${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)
|
||||||
"${pre_command}" sudo -u postgres pg_dump mastodon > "/var/backup/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql"
|
mkdir -p /var/backups/postgres
|
||||||
|
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\""
|
||||||
|
else
|
||||||
|
sudo -u postgres pg_dump mastodon | gzip -c > "/var/backups/postgres/pgdump_pre_update_mastodon_to_${tag}_${current_date}.sql.gz"
|
||||||
|
fi
|
||||||
"${pre_command}" sudo -u mastodon bundle install
|
"${pre_command}" sudo -u mastodon bundle install
|
||||||
"${pre_command}" sudo -u mastodon yarn install --frozen-lockfile
|
"${pre_command}" sudo -u mastodon yarn install --frozen-lockfile
|
||||||
"${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
|
||||||
|
|
Loading…
Reference in a new issue