#!/bin/sh

SERVERNAME=$(hostname)
if [[ "$SERVERNAME" == "debian" ]]; then
    SERVERNAME="ps-$(tr -dc 'a-z0-9' < /dev/urandom | head -c8)"
    debconf-set netcfg/hostname "$SERVERNAME"
    debconf-set netcfg/get_hostname "$SERVERNAME"
    hostname "$SERVERNAME"
fi
echo "$SERVERNAME" > /tmp/servername
