cloudron-setup: wait for apt setup
This commit is contained in:
+26
-4
@@ -13,6 +13,28 @@ vergte() {
|
||||
[[ "$1" == "${greater_version}" ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
# on many vps, apt runs on start up. cloudron-setup fails if it is run immediately on boot
|
||||
run_apt_get() {
|
||||
local success=false
|
||||
|
||||
for count in {1..5}; do
|
||||
# we used to check for locks, but there are many locks it seems
|
||||
while pgrep -x "apt-get|apt|dpkg" >/dev/null; do
|
||||
echo -n "=> Waiting for existing apt/dpkg processes to finish..."
|
||||
sleep 30
|
||||
done
|
||||
echo ""
|
||||
|
||||
if DEBIAN_FRONTEND=noninteractive apt-get "$@" &>> "${LOG_FILE}"; then
|
||||
success=true
|
||||
break
|
||||
fi
|
||||
echo "=> apt-get failed (attempt $count/5), retrying..."
|
||||
done
|
||||
|
||||
[[ "${success}" == "true" ]]
|
||||
}
|
||||
|
||||
# change this to a hash when we make a upgrade release
|
||||
readonly LOG_FILE="/var/log/cloudron-setup.log"
|
||||
readonly MINIMUM_DISK_SIZE_GB="18" # this is the size of "/" and required to fit in docker images 18 is a safe bet for different reporting on 20GB min
|
||||
@@ -167,18 +189,18 @@ echo " Join us at https://forum.cloudron.io for any questions."
|
||||
echo ""
|
||||
|
||||
echo "=> Updating apt and installing script dependencies"
|
||||
if ! apt-get update &>> "${LOG_FILE}"; then
|
||||
if ! run_apt_get update; then
|
||||
echo "Could not update package repositories. See ${LOG_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y install --no-install-recommends curl python3 ubuntu-standard software-properties-common -y &>> "${LOG_FILE}"; then
|
||||
echo "Could not install setup dependencies (curl). See ${LOG_FILE}"
|
||||
if ! run_apt_get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y install --no-install-recommends curl python3 ubuntu-standard software-properties-common; then
|
||||
echo "Could not install setup dependencies. See ${LOG_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=> Validating setup token"
|
||||
if [[ -n "${appstoreSetupToken}" ]]; then
|
||||
echo "=> Validating setup token"
|
||||
if ! httpCode=$(curl -sX POST -H "Content-type: application/json" -o /tmp/response.json -w "%{http_code}" --data "{\"setupToken\": \"${appstoreSetupToken}\"}" "${apiServerOrigin}/api/v1/cloudron_setup_done"); then
|
||||
echo "Could not reach ${apiServerOrigin} to complete setup"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user