From 8a23276748bf379659db9c525f304493e50d0b03 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 30 Nov 2019 22:12:15 +0100 Subject: [PATCH] Add clean-all build script --- build/clean-all.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 build/clean-all.sh diff --git a/build/clean-all.sh b/build/clean-all.sh new file mode 100755 index 0000000..242888a --- /dev/null +++ b/build/clean-all.sh @@ -0,0 +1,58 @@ +#!/bin/sh +set -ev + +# Clean documentation +rm -rf /srv/build/doc/* + +# Clean basic tar +rm -f /srv/build/vm.tar + +# Clean native apps +rm -rf /srv/build/alpine/* + +# Clean built LXC packages +rm -rf /srv/build/lxc/apps/* +rm -rf /srv/build/lxc/images/* +rm -f /srv/build/lxc/packages.sig +echo '{"apps":{},"images":{}}' >/srv/build/lxc/packages + +# Stop running containers +for SERVICE in $(ls -1 /run/openrc/started/lxc-*); do + service ${SERVICE} stop +done + +# Remove services +rm -f /etc/init.d/lxc-* +rc-update -u + +# Remove containers +rm -rf /var/lib/lxc/* + +# Remove application data +for DIR in $(ls -1 /srv | grep -v ^build$); do + rm -rf /srv/${DIR} +done + +# Remove nginx configs +for FILE in $(ls -1 /etc/nginx/conf.d | grep -Ev ^(apkrepo|default).conf$); do + rm -f /etc/nginx/conf.d/${FILE} +done +service nginx reload + +# Reset /etc/hosts +cat </etc/hosts +127.0.0.1 localhost +::1 localhost +172.17.0.1 host +172.17.0.1 repo.spotter.cz +EOF + +# Reset vmmgr config +export ADMINPWD=$(python3 -c "import json; f = open('/etc/vmmgr/config.json'); j = json.load(f); print(j['host']['adminpwd'])") +envsubst /etc/vmmgr/config.json + +# Clean locally installed LXC packages +rm -rf /var/lib/lxcmgr/storage/* +rm -rf /var/lib/lxcmgr/cache/apps/* +rm -rf /var/lib/lxcmgr/cache/images/* +echo '{"apps":{},"images":{}}' >/var/lib/lxcmgr/packages