ogclone-engine/debian/ogclient.postrm

27 lines
635 B
Bash

#!/bin/sh -e
set -e
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
# Create a temporary file with the configuration without our share
OLD_FILE="/etc/samba/smb.conf"
NEW_FILE=$(mktemp)
# Remove our share section from the file
grep -v "include = /etc/samba/smb-ogclient.conf" "$OLD_FILE" > "$NEW_FILE"
# Use ucf to update the file
ucf --debconf-ok "$NEW_FILE" "$OLD_FILE"
ucf --purge "$OLD_FILE"
# Clean up
rm -f "$NEW_FILE"
# Reload Samba
if command -v systemctl >/dev/null 2>&1; then
systemctl reload smbd.service
else
service smbd reload || true
fi
fi