Path : /var/lib/dpkg/info/
File Upload :
Current File : /var/lib/dpkg/info/ds-agent.postinst

#!/bin/sh

if [ -f /var/opt/ds_agent/dsa_core/ds_agent.crt ]; then
	echo "Running data migration script"
	# ds_agent should not be running at this point, but the 9.0 stop script isn't forceful enough
	# so make sure the agent is stopped
	agentPids=`pidof /opt/ds_agent/ds_agent`
	if [ $? -eq 0 ]; then
		# use the just-installed script to terminate any remaining ds_agent processes
		echo "Stopping any running ds_agent processes"
		/etc/init.d/ds_agent stop
	fi
	/opt/ds_agent/dsa -a dsa_9up -w /var/opt/ds_agent -z ""
fi

chmodUtil=`which chmod 2>/dev/null`
if [ ! -z "$chmodUtil" ] && [ -x "$chmodUtil" ] && [ -d "/var/opt/ds_agent" ]; then
    # assure the working directory has proper permission for modules
    $chmodUtil "0755" /var/opt/ds_agent 2>/dev/null
    if [ $? -eq 0 ]; then
        echo "Grant permission 0755 for the working directory"
    fi

    # grant permission for the directory "/var/opt" if only "ds_agent" exists
    # we should not change the permission of "/var/opt" if it's not created by DSA.
    if [ $(ls -a '/var/opt' | wc -l) -eq 3 ]; then
        $chmodUtil "0755" /var/opt 2>/dev/null
        if [ $? -eq 0 ]; then
            echo "Grant permission 0755 for the directory '/var/opt'"
        fi
    fi
fi

test -n "$DSA_NO_START" && exit 0

if [ -f "/usr/lib/systemd/system/ds_agent.service" ]; then
	echo "Enable ds_agent with systemd"
	/bin/systemctl enable ds_agent
	/bin/systemctl start ds_agent
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/ds_agent" ]; then
	echo "Automatically added by dh_installinit"
	update-rc.d ds_agent defaults >/dev/null

	if [ -x /bin/systemctl ]; then
		mkdir -p /etc/systemd/system/ds_agent.service.d
		printf "[Service]\nSuccessExitStatus=5 6 SIGKILL\n" > /etc/systemd/system/ds_agent.service.d/allow_exit.conf
		/bin/systemctl daemon-reload > /dev/null 2>&1
	fi

	if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
		invoke-rc.d ds_agent start || exit $?
	else
		/etc/init.d/ds_agent start || exit $?
	fi
fi
# End automatically added section