#!/bin/sh
# /etc/init.d/kx_hostname.sh
set $(cat /tmp/ipsub_intern.txt | tr "/" " ")
IP_INT=$1
SUB_INT=$2
set $(cat /tmp/ipsub_extern.txt | tr "/" " ")
IP_EXT=$1
SUB_EXT=$2
set $(echo $IP_INT | tr "." " ")
IP_INT_LAST=$4
IP_INT_LAST_P=`expr $4 + 1` IP_PARTNER=$1.$2.$3.$IP_INT_LAST_P
if [ $IP_INT_LAST -eq 1 ];then
hostname pcsec1
rm -f /etc/hostname /etc/hosts
echo "pcsec1" > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "$IP_INT pcsec1" >> /etc/hosts
elif [ $IP_INT_LAST -eq 23 ];then
hostname pcsec3
rm -f /etc/hostname /etc/hosts
echo "pcsec3" > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "$IP_INT pcsec3" >> /etc/hosts
elif [ $IP_INT_LAST -eq 45 ];then
hostname pcsec5
rm -f /etc/hostname /etc/hosts
echo "pcsec5" > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "$IP_INT pcsec5" >> /etc/hosts
elif [ $IP_INT_LAST -eq 67 ];then
hostname pcsec7
rm -f /etc/hostname /etc/hosts
echo "pcsec7" > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "$IP_INT pcsec7" >> /etc/hosts
elif [ $IP_INT_LAST -eq 109 ];then
hostname pcsec9
rm -f /etc/hostname /etc/hosts
echo "pcsec9" > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "$IP_INT pcsec9" >> /etc/hosts
fi