50 lines
1.3 KiB
Bash
50 lines
1.3 KiB
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
case "$1" in
|
|
configure)
|
|
# Create a temporary file with the modified configuration
|
|
SMB_CONF="/etc/samba/smb-ogclient.conf"
|
|
OLD_FILE="/etc/samba/smb.conf"
|
|
NEW_FILE=$(mktemp)
|
|
|
|
# Ensure the template file exists
|
|
if [ ! -f "$SMB_CONF" ]; then
|
|
echo "Config file missing!"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if our share section already exists
|
|
if grep -q "include = /etc/samba/smb-ogclient.conf" "$OLD_FILE"; then
|
|
# Section already exists, do nothing
|
|
rm -f "$NEW_FILE"
|
|
else
|
|
# Copy the original file
|
|
cp -a "$OLD_FILE" "$NEW_FILE"
|
|
|
|
# Append our configuration
|
|
echo "include = /etc/samba/smb-ogclient.conf" >> "$OLD_FILE"
|
|
|
|
# Reload Samba
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
systemctl reload smbd.service
|
|
else
|
|
service smbd reload || true
|
|
fi
|
|
fi
|
|
;;
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
;;
|
|
|
|
*)
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
chown -R opengnsys:opengnsys /opt/opengnsys/ogclient
|
|
chown -R opengnsys:opengnsys /opt/opengnsys/ogclient_log
|
|
#DEBHELPER#
|
|
|
|
exit 0
|