cloudron-support: implement --recreate-docker
This commit is contained in:
@@ -470,7 +470,7 @@ function check_disk_space() {
|
||||
function recreate_containers() {
|
||||
readonly logfile="/home/yellowtent/platformdata/logs/box.log"
|
||||
|
||||
echo "This will re-create all the containers. Services will go down for a bit."
|
||||
echo "This will re-create all the containers. Apps will go down for a while. No data will be lost."
|
||||
read -p "Do you want to proceed? (y/N) " -n 1 -r choice
|
||||
echo
|
||||
|
||||
@@ -479,8 +479,8 @@ function recreate_containers() {
|
||||
fi
|
||||
|
||||
echo ""
|
||||
info " Follow re-create logs in a second terminal with:"
|
||||
info " $ tail -f ${logfile}"
|
||||
info "Follow re-create logs in a second terminal with:"
|
||||
info "$ tail -f ${logfile}"
|
||||
echo ""
|
||||
|
||||
echo -n "Re-creating addon containers (this takes a while) ."
|
||||
@@ -494,11 +494,62 @@ function recreate_containers() {
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Addon containers successfully re-created. The apps in the dashboard will say 'Configuring (Queued)'. They will come up in a short while."
|
||||
echo "Done! Addon containers successfully re-created. The apps in the dashboard will say 'Configuring (Queued)'. They will come up in a short while."
|
||||
}
|
||||
|
||||
function recreate_docker() {
|
||||
echo "ok"
|
||||
readonly logfile="/home/yellowtent/platformdata/logs/box.log"
|
||||
|
||||
docker_root=/var/lib/docker
|
||||
if ! docker_root=$(docker info -f '{{ .DockerRootDir }}'); then
|
||||
warning "Unable to detect docker root. Assuming /var/lib/docker"
|
||||
fi
|
||||
|
||||
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"
|
||||
read -p "Do you want to proceed? (y/N) " -n 1 -r choice
|
||||
echo -e "\n"
|
||||
|
||||
if [[ ! $choice =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
info "Stopping box"
|
||||
systemctl disable 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 "Clearing docker storage at ${docker_root}"
|
||||
if ! rm -rf "${docker_root}/"*; then
|
||||
fail "Could not delete storage directory. This can happen because of stray containers that docker has lost track of. To fix this, reboot the server and run this command again"
|
||||
exit 1
|
||||
fi
|
||||
info "Cleared docker storage"
|
||||
|
||||
info "Starting docker afresh"
|
||||
systemctl enable -q docker
|
||||
systemctl start -q docker
|
||||
|
||||
echo ""
|
||||
info "Follow re-create logs in a second terminal with:"
|
||||
info "$ tail -f ${logfile}"
|
||||
echo ""
|
||||
|
||||
echo -n "Re-downloading images and re-creating addon containers (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 box
|
||||
systemctl restart box # this will create docker network as well
|
||||
|
||||
while ! tail -n "+${line_count}" "${logfile}" | grep -q "platform is ready"; do
|
||||
echo -n "."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Done! Addon containers successfully re-created. The apps in the dashboard will say 'Configuring (Queued)'. They will come up in a short while."
|
||||
}
|
||||
|
||||
check_disk_space
|
||||
|
||||
Reference in New Issue
Block a user