%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/var/lib/dpkg/info/
Upload File :
Create Path :
Current File : //proc/thread-self/root/var/lib/dpkg/info/samba.postinst

#!/bin/sh

set -e

nmbd_error_handler() {
    if [ -d /sys/class/net/lo ] && ls /sys/class/net | grep -qv ^lo$; then
        # https://bugs.debian.org/893762
        echo 'WARNING: nmbd failed to start as there is no non-loopback interfaces available.'
        echo 'Either add an interface or set "disable netbios = yes" in smb.conf and run "systemctl mask nmbd"'
        return 0
    elif command -v ip > /dev/null && ip a show | grep '^[[:space:]]*inet ' | grep -vq ' lo$'; then
        # https://bugs.debian.org/859526
        echo 'WARNING: nmbd failed to start as there is no local IPv4 non-loopback interfaces available.'
        echo 'Either add an IPv4 address or set "disable netbios = yes" in smb.conf and run "systemctl mask nmbd"'
        return 0
    else
        echo 'ERROR: nmbd failed to start.'
        return 1 # caught by set -e
    fi
}

mask_services() {
    local reason="$1"
    shift
    local masked_count=0
    mkdir -p /etc/systemd/system
    echo "${reason}: Masking $*"
    echo "Please ignore the following error about deb-systemd-helper not finding those services."
    while true; do
        local service_name="$1"
        if [ -z "$service_name" ]; then
            break
        fi
        shift
        if [ ! -e "/etc/systemd/system/${service_name}" ]; then
            ln -s /dev/null "/etc/systemd/system/${service_name}"
            echo "(${service_name} masked)"
            masked_count=$((masked_count+1))
        elif [ -h "/etc/systemd/system/${service_name}" ] \
            && [ "$(realpath /etc/systemd/system/${service_name})" = /dev/null ] \
        ; then
            echo "(${service_name} already masked)"
        else
            echo "WARNING ${service_name} should be masked. The install may fail."
        fi
    done
    # In case this system is running systemd, we make systemd reload the unit files
    # to pick up changes.
    if [ "${masked_count}" -ge 1 -a -d /run/systemd/system ] ; then
        systemctl --system daemon-reload >/dev/null || true
    fi
}

# We generate several files during the postinst, and we don't want
#	them to be readable only by root.
umask 022

# add the sambashare group
if ! getent group sambashare > /dev/null 2>&1
then
	addgroup --system sambashare
fi

if [ ! -e /var/lib/samba/usershares ]
then
	install -d -m 1770 -g sambashare /var/lib/samba/usershares
fi

# mimic source4/smbd/server.c and mask service before it fails
# NB: server role = active directory domain controller is what we need to properly support
# NB: server services = smb is not compiled in
# NB: dcerpc endpoint servers = remote is for developpement
# NB: dcerpc endpoint servers = mapiproxy is for OpenChange which is dead
SERVER_ROLE=`samba-tool testparm --parameter-name="server role"  2>/dev/null | tail -1`
SERVER_SERVICES=`samba-tool testparm --parameter-name="server services"  2>/dev/null | tail -1`
DCERPC_ENDPOINT_SERVERS=`samba-tool testparm --parameter-name="dcerpc endpoint servers"  2>/dev/null | tail -1`
DISABLE_NETBIOS=`samba-tool testparm --parameter-name="disable netbios"  2>/dev/null | tail -1`

if [ "$SERVER_ROLE" != "active directory domain controller" ] \
        && ( echo "$SERVER_SERVICES" | grep -qv '\(^\|, \)smb\(,\|$\)' ) \
        && ( echo "$DCERPC_ENDPOINT_SERVERS" | grep -qv '\(^\|, \)remote\(,\|$\)' ) \
        && ( echo "$DCERPC_ENDPOINT_SERVERS" | grep -qv '\(^\|, \)mapiproxy\(,\|$\)' ) \
; then
    mask_services "Samba is not being run as an AD Domain Controller" samba-ad-dc.service
fi
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then
    mask_services "Samba is being run as an AD Domain Controller" smbd.service nmbd.service
elif [ "$DISABLE_NETBIOS" = Yes ]; then
    mask_services "NetBIOS is disabled" nmbd.service
fi

# Automatically added by dh_installdeb/13.6ubuntu1
dpkg-maintscript-helper rm_conffile /etc/init.d/samba 2:4.6.5\+dfsg-5\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/init/nmbd.conf 2:4.6.5\+dfsg-5\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/init/reload-smbd.conf 2:4.6.5\+dfsg-5\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/init/samba-ad-dc.conf 2:4.6.5\+dfsg-5\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/init/smbd.conf 2:4.6.5\+dfsg-5\~ -- "$@"
# End automatically added section
# Automatically added by dh_installinit/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/smbd" ]; then
		update-rc.d smbd defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d --skip-systemd-native smbd $_dh_action || exit 1
	fi
fi
# End automatically added section
# Automatically added by dh_installinit/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/nmbd" ]; then
		update-rc.d nmbd defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d --skip-systemd-native nmbd $_dh_action || nmbd_error_handler
	fi
fi
# End automatically added section
# Automatically added by dh_installinit/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/samba-ad-dc" ]; then
		update-rc.d samba-ad-dc defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d --skip-systemd-native samba-ad-dc $_dh_action || exit 1
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	# This will only remove masks created by d-s-h on package removal.
	deb-systemd-helper unmask 'nmbd.service' >/dev/null || true

	# was-enabled defaults to true, so new installations run enable.
	if deb-systemd-helper --quiet was-enabled 'nmbd.service'; then
		# Enables the unit on first installation, creates new
		# symlinks on upgrades if the unit file has changed.
		deb-systemd-helper enable 'nmbd.service' >/dev/null || true
	else
		# Update the statefile to add new symlinks (if any), which need to be
		# cleaned up on purge. Also remove old symlinks.
		deb-systemd-helper update-state 'nmbd.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	# This will only remove masks created by d-s-h on package removal.
	deb-systemd-helper unmask 'samba-ad-dc.service' >/dev/null || true

	# was-enabled defaults to true, so new installations run enable.
	if deb-systemd-helper --quiet was-enabled 'samba-ad-dc.service'; then
		# Enables the unit on first installation, creates new
		# symlinks on upgrades if the unit file has changed.
		deb-systemd-helper enable 'samba-ad-dc.service' >/dev/null || true
	else
		# Update the statefile to add new symlinks (if any), which need to be
		# cleaned up on purge. Also remove old symlinks.
		deb-systemd-helper update-state 'samba-ad-dc.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	# This will only remove masks created by d-s-h on package removal.
	deb-systemd-helper unmask 'smbd.service' >/dev/null || true

	# was-enabled defaults to true, so new installations run enable.
	if deb-systemd-helper --quiet was-enabled 'smbd.service'; then
		# Enables the unit on first installation, creates new
		# symlinks on upgrades if the unit file has changed.
		deb-systemd-helper enable 'smbd.service' >/dev/null || true
	else
		# Update the statefile to add new symlinks (if any), which need to be
		# cleaned up on purge. Also remove old symlinks.
		deb-systemd-helper update-state 'smbd.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -d /run/systemd/system ]; then
		systemctl --system daemon-reload >/dev/null || true
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		deb-systemd-invoke $_dh_action 'nmbd.service' 'samba-ad-dc.service' 'smbd.service' >/dev/null || true
	fi
fi
# End automatically added section


exit 0

Zerion Mini Shell 1.0