Spotter-VM/build/clean-all.sh

60 lines
1.4 KiB
Bash
Raw Normal View History

2019-11-30 22:12:15 +01:00
#!/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
2019-12-07 16:29:41 +01:00
for SERVICE in $(find /run/openrc/started -name 'lxc-*'); do
service $(basename ${SERVICE}) stop
2019-11-30 22:12:15 +01:00
done
# Remove services
rm -f /etc/init.d/lxc-*
rc-update -u
# Remove containers
rm -rf /var/lib/lxc/*
2019-12-18 10:13:32 +01:00
rm -f /var/log/lxc/*
2019-11-30 22:12:15 +01:00
# Remove application data
2019-12-07 16:29:41 +01:00
for DIR in $(find /srv ! -path /srv/build -maxdepth 1 -mindepth 1); do
rm -rf ${DIR}
2019-11-30 22:12:15 +01:00
done
# Remove nginx configs
2019-12-08 14:54:00 +01:00
for CONF in $(find /etc/nginx/conf.d -name '*.conf' -a ! -name repo.conf -a ! -name default.conf); do
2019-12-07 16:29:41 +01:00
rm -f ${CONF}
2019-11-30 22:12:15 +01:00
done
service nginx reload
# Reset /etc/hosts
cat <<EOF >/etc/hosts
127.0.0.1 localhost
::1 localhost
172.17.0.1 host
2019-12-09 21:41:04 +01:00
172.17.0.1 repo.build.vm
2019-11-30 22:12:15 +01:00
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