I'm trying to create a kickstart to automate the installation procedure but when the installation ends and I check to see the result nothing happened. I'm trying to debug it by putting read statements in different places to see if everything runs. It seems the all the variables are there but when the setMask function executes it restarts. Any help would be greatly appreciated.
%pre
#!/bin/sh
curTTY=`tty`
exec < $curTTY > $curTTY 2> $curTTY
echo 'Specify the hostname to assign: '; read hostname
echo -n "Enter ip of ips (separated by spaces): "; read ip
echo -n "Enter ipv6 address: "; read ipv6
#Saving data
echo $hostname > /tmp/hostname
echo $ip > /tmp/ip
echo $ipv6 > /tmp/ipv6
%end
%post --nochroot
#!/bin/sh
curTTY=`tty`
exec < $curTTY > $curTTY 2> $curTTY
#Transfering data to be used in the post phase
ip=$(cat /tmp/ip)
ipv6=$(cat /tmp/ipv6)
hostname=$(cat /tmp/hostname)
numips=$(echo $ip | wc -w)
numberOfIpAddresses () {
if [ numips > 1 ]; then
ips=$(echo $ip | awk '{$1=""; print}' | cut -c 2-)
ip=$(echo $ip | awk '{print $1}')
fi
}
ipv6GW () {
echo $ipv6 | awk -F":" '{$(NF--); print}' | while read $output
do
do
gwv6="$gwv6:$output"
done
gwv6="$gwv6:1"
}
numberOfIpAddresses
ipv6GW
setGateway () {
case prefix in
22|23|24)
gateway=$(echo $ip | cut -d. -f1-3)".1"
;;
25)
if [ firstOcted -ne 65 ] || [ thirdOcted -eq 161 ]; then
gateway=$(echo $ip | cut -d. -f1-3)".129"
elif [ thirdOcted -eq 162 ]; then
gateway=$(echo $ip | cut -d. -f1-3)".129"
elif [ thirdOcted -eq 162 ]; then
gateway=$(echo $ip | cut -d. -f1-3)".1"
fi
;;
26)
if [ firstOcted -ne 64 ]; then
gateway=$(echo $ip | cut -d. -f1-3)".65"
elif [ firstOcted -ne 69 ]; then
gateway=$(echo $ip | cut -d. -f1-3)".129"
fi
;;
esac
}
setMask () {
#Extracting necesery octeds
firstOcted=$(echo $ip | cut -d. -f1)
thirdOcted=$(echo $ip | cut -d. -f3)
case firstOcted in
8)
prefix=24
setGateway
64)
echo "Aqui en setMask opcion 64"
read algo
if [ thirdOcted -ne 7 ] && [ thirdOcted -ne 19 ] && [ thirdOcted -ne 26 ] && [ thirdOcted -ne 30 ] && [ thirdOcted -ne 31 ]; then
prefix=24
setGateway
elif [ thirdOcted -ne 7 ] || [ thirdOcted -ne 19 ]; then
prefix=25
setGateway
elif [ thirdOcted -ne 30 ] || [ thirdOcted -ne 31 ]; then
prefix=26
setGateway
fi
setGateway
fi
;;
65)
if [ thirdOcted -ge 164 ] && [ thirdOcted -le 175 ]; then
prefix=22
setGateway
elif [ thirdOcted -ge 176 ] && [ thirdOcted -le 185 ]; then
prefix=23
setGateway
elif [ thirdOcted -ge 161 ] && [ thirdOcted -le 162 ]; then
prefix=25
setGateway
elif [ thirdOcted -ge 187 ] && [ thirdOcted -le 190 ]; then
prefix=24
setGateway
fi
;;
69)
if [ thirdOcted -ge 116 ] && [ thirdOcted -le 123 ]; then
prefix=22
setGateway
elif [ thirdOcted -ge 110 ] && [ thirdOcted -le 115 ]; then
prefix=24
setGateway
elif [ thirdOcted -ge 98 ] && [ thirdOcted -le 109 ]; then
prefix=24
setGateway
fi
;;
*)
echo "The ip was wrongly typed" read ip
echo -n "Type the prefix to use: "
read prefix
echo -n "Type the gateway: "
read gateway
numberOfIpAddresses
ipv6GW
;;
esac
}
setMask
counter=0
ls /sys/class/net/ | grep ^e | while read output;
do
echo 'SUBSYSTEM=="net", ACTION=="add", KERNEL=="'$output'", NAME="eth'$counter'"' \
>> /etc/udev/rules.d/70-persistent-net.rules;
((counter++));
done
if [ -f /etc/debian_version ]; then
else
echo DEVICE=eth0 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo PREFIX=$prefix >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPADDR=$ip >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo GATEWAY=$gateway >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo DNS1=69.60.123.201 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo DNS2=69.60.125.254 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo #IPv6 Conf >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6INIT=yes >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6ADDR=$ipv6 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6_DEFAULTGW=$gwv6 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6ADDR=$ipv6 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6_DEFAULTGW=$gwv6 >> /etc/sysconfig/network-scripts/ifcfg-eth0
if [ -n ips ]; then
counter=0
for subip in ips; do
cat ifcfg-eth0 | sed 's/DEVICE=eth0/DEVICE=eth0:$counter/' | sed 's/IPADDR=$ip/IPADDR=$subip/' >> ifcfg-eth0:$counter
done
%end