server-scripts/destroy-php-container

43 lines
759 B
Plaintext
Raw Normal View History

2014-10-19 15:27:33 +00:00
#!/bin/sh
bold=`tput bold`
normal=`tput sgr0`
if ! [ $EUID -eq 0 ]
then
echo "Must be root!" >&2
exit 1
fi
if [ $# -lt 2 ]
then
echo "Usage: $0 <name> <domain> [<features>]" >&2
exit 1
fi
NAME="$1"
DOMAIN="$2"
ROOTFS="/data/containers/$NAME/rootfs"
WEBFS="/data/containers/web/rootfs"
WEBPATH="/srv/http/$DOMAIN"
NGINX="$WEBFS/etc/nginx"
# destroy container
lxc-stop -n "$NAME"
/usr/bin/lxc-destroy -n "$NAME"
# unconfigure nginx
chroot "$WEBFS" nginx_dissite "$DOMAIN"
rmdir "$WEBFS$WEBPATH"
rm -f "$WEBFS/etc/nginx/sites-available/$DOMAIN"
# restart nginx
lxc-attach -n web -- systemctl restart nginx
# unconfigure firewall
rm -f "/etc/ferm.d/services/45-$NAME"
fw-apply
# clean up container.json
/etc/lxc/scripts/cleanup-container-file.rb