Add clean-all build script

This commit is contained in:
Disassembler 2019-11-30 22:12:15 +01:00
parent a7a4004f53
commit 8a23276748
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

58
build/clean-all.sh Executable file
View File

@ -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 <<EOF >/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.default.json >/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