59 lines
1.3 KiB
Bash
59 lines
1.3 KiB
Bash
|
#!/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
|