diff --git a/scripts/cloudron-support b/scripts/cloudron-support index 390294e7b..6dc731e8a 100755 --- a/scripts/cloudron-support +++ b/scripts/cloudron-support @@ -476,7 +476,6 @@ function do_recreate_containers() { echo -n "This takes a while ." line_count=$(cat "${logfile}" | wc -l) sed -e 's/"version": ".*",/"version":"48.0.0",/' -i /home/yellowtent/platformdata/INFRA_VERSION - systemctl enable -q box systemctl restart -q box # will re-create docker network while ! tail -n "+${line_count}" "${logfile}" | grep -q "platform is ready"; do @@ -516,31 +515,29 @@ function ask_reboot() { [[ ! $choice =~ ^[Yy]$ ]] && exit 1 reboot + exit } function recreate_docker() { readonly logfile="/home/yellowtent/platformdata/logs/box.log" readonly stagefile="/home/yellowtent/platformdata/recreate-docker-stage" - docker_root=/var/lib/docker - if ! docker_root=$(docker info -f '{{ .DockerRootDir }}'); then + if ! docker_root=$(docker info -f '{{ .DockerRootDir }}' 2>/dev/null); then warning "Unable to detect docker root. Assuming /var/lib/docker" fi + [[ -z "${docker_root}" ]] && docker_root="/var/lib/docker" if [[ ! -e "${stagefile}" ]]; then echo -e "Use this command when docker storage (at $docker_root) is corrupt. It will delete the docker storage, re-download docker images and re-create containers. Dashboard and apps will be unreachable for a while. No data will be lost.\n" - echo -e "The server will have to be rebooted twice for this process.\n" + echo -e "The server may have to be rebooted twice for this process. If so, re-run this command after every reboot.\n" read -p "Do you want to proceed? (y/N) " -n 1 -r choice echo -e "\n" [[ ! $choice =~ ^[Yy]$ ]] && exit 1 - info "Stopping box" - systemctl disable -q box || true - systemctl stop -q box || true - info "Stopping docker" - systemctl disable -q docker || true # for the reboot situation, we don't want it start again - systemctl stop -q docker || true + info "Stopping box and docker" + systemctl stop -q box docker containerd docker.socket || true + systemctl disable -q box docker containerd docker.socket || true echo -e "clearing_storage" > "${stagefile}" # init fi @@ -548,24 +545,24 @@ function recreate_docker() { if grep -q "clearing_storage" "${stagefile}"; then info "Clearing docker storage at ${docker_root}" if ! rm -rf "${docker_root}/"*; then - echo -e "\nThe server has to be rebooted to clear the docker storage. After reboot, run this command again.\n" + echo -e "\nThe server has to be rebooted to clear the docker storage. After reboot, run 'cloudron-support --recreate-docker' again.\n" ask_reboot fi echo -e "cleared_storage" > "${stagefile}" fi if grep -q "cleared_storage" "${stagefile}"; then - info "Starting docker afresh" - systemctl enable -q docker - systemctl start -q docker + info "Starting docker afresh at ${docker_root}" + systemctl enable --now -q docker.socket docker containerd sleep 5 # give docker some time to initialize the storage directory download_docker_images echo -e "downloaded_images" > "${stagefile}" - echo -e "\nThe server has to be rebooted again for docker to initialize properly. After reboot, run this command again.\n" # else docker network is not completely functional + echo -e "\nThe server has to be rebooted again for docker to initialize properly. After reboot, run 'cloudron-support --recreate-docker' again.\n" # else docker network is not completely functional ask_reboot fi if grep -q "downloaded_images" "${stagefile}"; then + systemctl enable -q box do_recreate_containers fi