#!/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 # hardcode debhelpers to start the daemon after pycentral # Automatically added by dh_pycentral rm -f /var/lib/pycentral/cc-node.pkgremove if which pycentral >/dev/null 2>&1; then pycentral pkginstall cc-node if grep -qs '^cc-node$' /var/lib/pycentral/delayed-pkgs; then sed -i '/^cc-node$/d' /var/lib/pycentral/delayed-pkgs fi fi # End automatically added section # 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 exit 0