Upgrade the db addons using dumps when major version changes

This commit is contained in:
Girish Ramakrishnan
2018-10-15 14:31:35 -07:00
parent bbdafc6a2f
commit 816fa94555
5 changed files with 107 additions and 6 deletions

37
src/scripts/rmaddon.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -eu -o pipefail
if [[ ${EUID} -ne 0 ]]; then
echo "This script should be run as root." > /dev/stderr
exit 1
fi
if [[ $# -eq 0 ]]; then
echo "No arguments supplied"
exit 1
fi
if [[ "$1" == "--check" ]]; then
echo "OK"
exit 0
fi
addon="$1"
appid="${2:-}" # only valid for redis
if [[ "${addon}" != "postgresql" && "${addon}" != "mysql" && "${addon}" != "mongodb" && "${addon}" != "redis" ]]; then
echo "${addon} must be postgresql/mysql/mongodb/redis"
exit 1
fi
if [[ "${BOX_ENV}" == "cloudron" ]]; then
readonly addon_dir="${HOME}/platformdata/${addon}"
else
readonly addon_dir="${HOME}/.cloudron_test/platformdata/${addon}"
fi
rm -rf "${addon_dir}"
if [[ "${addon}" != "redis" ]]; then
mkdir "${addon_dir}"
fi