#!/bin/bash

# Déinstallation de scodoc
# Ne touche pas aux données (/opt/scodoc-data)
# N'enlève complètement /opt/scodoc qui si --purge

systemctl stop scodoc9 || echo "scodoc9 non lancé"
systemctl disable scodoc9 || echo "scodoc9 systemd non configuré"

if [ "$#" == 1 ] && [ "$1" == "purge" ]
then
    /bin/rm -rf /opt/scodoc
    /bin/rm -f /etc/systemd/system/scodoc9.service
    /bin/rm -f /etc/systemd/system/scodoc-updater.service 
    /bin/rm -f /etc/systemd/system/scodoc-updater.timer 
    /bin/rm -f /etc/nginx/sites-enabled/scodoc9.nginx
    systemctl daemon-reload
fi

systemctl reload nginx || echo 'nginx non fonctionnel'