#!/bin/sh #------------------------------------------------------------------------------- # /etc/network/if-up.d/addhost-up - update configuration file on eisfair-2 # # Copyright (c) 2008-2022 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2008-09-19 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #------------------------------------------------------------------------------- # file names basefile=/etc/config.d/base configfile=/etc/config.d/addhost # don't bother to restart when lo is configured. if [ "${IFACE}" = lo ] then exit 0 fi # only run from ifup. if [ "${MODE}" != start ] then exit 0 fi if [ -f ${configfile} ] then . ${basefile} . ${configfile} if [ "${IP_NET_1_STATIC_IP}" = "no" ] then localhost_ipaddr="dhcp: `dnsip ${HOSTNAME}.${DOMAIN_NAME} | sed 's/ *//g'`" else localhost_ipaddr="${IP_NET_1_IPADDR}" fi localhost_name="${HOSTNAME}.${DOMAIN_NAME}" localhost_alias="${HOSTNAME}" # update static data if [ -n "${localhost_ipaddr}" -a -n "${localhost_name}" ] then cp ${configfile} ${configfile}.tmp { sed -e "/ADDHOST_LOCALHOST_IPADDR/s/=.*/=\"${localhost_ipaddr}\"/g" \ -e "/ADDHOST_LOCALHOST_NAME/s/=.*/=\"${localhost_name}\"/g" \ -e "/ADDHOST_LOCALHOST_ALIAS/s/=.*/=\"${localhost_alias}\"/g" ${configfile}.tmp } > ${configfile} chmod 600 ${configfile} rm -f ${configfile}.tmp fi fi exit 0