#! /bin/sh set -e . /usr/share/debconf/confmodule # Guess default hostname HOST=$( hostname -f || true ) if [ -z "$HOST" ]; then HOST=localhost fi db_get bacula-cn/hostname || true if [ -z "$RET" ]; then db_set bacula-cn/hostname "$HOST" fi # Guess default ip db_get bacula-cn/ip || true if [ -z "$RET" ]; then # default via 161.53.55.1 dev eth0 DEV=$( ip route show to exact 0/0 \ | awk '$1 == "default" && $4 == "dev" { print $5; nextfile }' ) if [ "$DEV" ]; then # inet 161.53.55.202/24 brd 161.53.55.255 scope global eth0 IP=$( ip address show dev $DEV scope global \ | awk '$1 == "inet" { sub("/[^ ]+", ""); print $2; nextfile }' ) if [ "$IP" ]; then db_set bacula-cn/ip "$IP" fi fi fi # Sample contact db_get bacula-cn/contact || true if [ -z "$RET" ]; then db_set bacula-cn/contact "Ime Prezime " fi # Check hostname while true; do ! db_input high bacula-cn/hostname && [ $? -eq 30 ] && break db_go || true db_get bacula-cn/hostname [ -z "$RET" ] && continue echo "$RET" | grep -Eqi '^[a-z0-9-]+(\.[a-z0-9.-]+)+$' || continue break done # Check ip while true; do ! db_input high bacula-cn/ip && [ $? -eq 30 ] && break db_go || true db_get bacula-cn/ip [ -z "$RET" ] && continue echo "$RET" | grep -Eqi '^[0-9]{1,3}(\.[0-9]{1,3}){3}$' || continue break done # Check contact while true; do ! db_input high bacula-cn/contact && [ $? -eq 30 ] && break db_go || true db_get bacula-cn/contact [ -z "$RET" ] && continue echo "$RET" | grep -Eqi '^([^@]*<)?[a-z0-9.+-]+@[a-z0-9-]+(\.[a-z0-9.-]+)+>?$' || continue break done exit 0