Skip to content
Snippets Groups Projects
cc-node.postinst 950 B
Newer Older
#!/bin/sh
set -e
CONF="/etc/cc-node.conf"

if [ -f "$CONF" ]; then
    # secure the config file
    chmod 0640 "$CONF"
    # replace login by hostname if unset
    if grep '\$\$LOGIN\$\$' "$CONF" >/dev/null; then
        login=$(hostname)
        echo "*** CC-Node login : ${login}"
        sed -e "s/\\\$\\\$LOGIN\\\$\\\$/${login}/g" -i "$CONF"
    fi
    # generate a random password if unset
    if grep '\$\$PASSWORD\$\$' "$CONF" >/dev/null; then
        password=$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 12)
        echo "*** CC-Node password : ${password}"
        sed -e "s/\\\$\\\$PASSWORD\\\$\\\$/${password}/g"\
            -i "$CONF"
    fi
fi

Anael Beutot's avatar
Anael Beutot committed
#DEBHELPER#

# Workaround to restart node after pycentral
if [ -x "/etc/init.d/cc-node" ]; then
	update-rc.d cc-node defaults >/dev/null
	if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
		invoke-rc.d cc-node start || exit $?
	else
		/etc/init.d/cc-node start || exit $?
	fi
fi
Anael Beutot's avatar
Anael Beutot committed

exit 0