diff --git a/modules/services.sh b/modules/services.sh index 9b7e963417..3c703b8397 100644 --- a/modules/services.sh +++ b/modules/services.sh @@ -80,6 +80,7 @@ function services { up) case "$service_name" in planet) + check_space "treehouses/planet" if [ -f /srv/planet/pwd/credentials.yml ]; then docker-compose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -f /srv/planet/pwd/credentials.yml -p planet up -d else @@ -89,50 +90,50 @@ function services { check_tor "80" ;; kolibri) + check_space "treehouses/kolibri" bash $TEMPLATES/services/kolibri/kolibri_yml.sh echo "yml file created" - docker-compose -f /srv/kolibri/kolibri.yml -p kolibri up -d echo "kolibri built and started" check_tor "8080" ;; nextcloud) + check_space "library/nextcloud" bash $TEMPLATES/services/nextcloud/nextcloud_yml.sh echo "yml file created" - docker-compose -f /srv/nextcloud/nextcloud.yml -p nextcloud up -d echo "nextcloud built and started" check_tor "8081" ;; pihole) + check_space "pihole/pihole" bash $TEMPLATES/services/pihole/pihole_yml.sh echo "yml file created" - service dnsmasq stop docker-compose -f /srv/pihole/pihole.yml -p pihole up -d echo "pihole built and started" check_tor "8053" ;; moodle) + check_space "treehouses/moodle" bash $TEMPLATES/services/moodle/moodle_yml.sh echo "yml file created" - docker-compose -f /srv/moodle/moodle.yml -p moodle up -d echo "moodle built and started" check_tor "8082" ;; privatebin) + check_space "treehouses/privatebin" bash $TEMPLATES/services/privatebin/privatebin_yml.sh echo "yml file created" - docker-compose -f /srv/privatebin/privatebin.yml -p privatebin up -d echo "privatebin built and started" check_tor "8083" ;; portainer) + check_space "portainer/portainer" bash $TEMPLATES/services/portainer/portainer_yml.sh echo "yml file created" - docker-compose -f /srv/portainer/portainer.yml -p portainer up -d echo "portainer built and started" check_tor "9000" @@ -369,6 +370,18 @@ function find_available_services { echo "$service [$available_formats]" } +function check_space { + image_size=$(curl -s -H "Authorization: JWT " "https://hub.docker.com/v2/repositories/${1}/tags/?page_size=100" | jq -r '.results[] | select(.name == "latest") | .images[0].size') + free_space=$(df -Ph /var/lib/docker | awk 'END {print $4}' | numfmt --from=iec) + + if (( image_size > free_space )); then + echo "image size:" $image_size + echo "free space:" $free_space + echo "not enough free space" + exit 1 + fi +} + # tor status and port check function check_tor { port="$1" diff --git a/package.json b/package.json index f1c30ec4ca..e4702d30f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.13.9", + "version": "1.13.10", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh", "bin": {