#!/bin/sh # piston's script for dhcp-probe # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package PACKAGE="dhcp-probe" CONF_DIR="/etc/$PACKAGE" CONF_FILE="/etc/dhcp_probe.cf" MSG="dhcp-probe: IP not configured on host, please see template file" MSG="$MSG /usr/share/doc/dhcp-probe/dhcp_probe.tpl.eth0 to configure !" # # Dynamic configuration procedure # if test -f /lib/lsb/init-functions then . /lib/lsb/init-functions fi # # postinst script main # case "$1" in configure) DEST="/etc/$PACKAGE/$PACKAGE" if [ -z "$(ls "$CONF_DIR")" ] then # Configuration doesn't exist ip address | awk ' /^[0-9]*:/ { iface=$2 sub(/:/, "", iface) ether="" inet=0 } /link\/ether/ { ether=$2 } /inet / && !inet { inet=$2 sub(/\/.*/, "", inet) if(iface && ether && inet) { print iface print ether print inet } } ' | while read -r i && read -r ether && read -r inet; do TMPDEST=$(mktemp -t "$PACKAGE.$i.XXXXXXXX") { echo "#" echo "# Automaticaly generated file during dhcp-probe package install procedure" echo "#" echo "INTERFACE=\"$i\"" echo "MAC=\"$ether\"" echo "IPV4=\"$inet\"" } > "$TMPDEST" ucf "$TMPDEST" "$DEST.$i" logger -i -p daemon.crit "$TMPDEST installed." rm -f "$TMPDEST" done fi if test ! -f "$CONF_FILE"; then DHCP_PROBE_CF=$(mktemp -t $PACKAGE.XXXXXXXX) ucf "$DHCP_PROBE_CF" "$CONF_FILE" rm -f "$DHCP_PROBE_CF" fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac #DEBHELPER# exit 0