User:Trohumet: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 40: | Line 40: | ||
/etc/init.d/networking restart | /etc/init.d/networking restart | ||
#Tulemus | |||
echo "Loodi alias IPga $IP" | |||
fi | fi |
Revision as of 14:13, 11 May 2011
Quest14
<source lang="bash">
- !/bin/bash
- Autor: Toomas Rohumets A21
- Skript, mis loob Ubuntu serverile IP aliase
- Versioon 0.2
- Õiguste kontroll
if [ $UID -ne 0 ]; then echo "Käivita skript $(basename $0) juurkasutaja õigustega" exit 1
fi
- Kontroll kas IP on parameetrina antud
if [ $# -ne 1 ]; then
echo "Käivita skript $(basename $0) koos IPga" exit 1
fi
IP=$1
- Ping, kontrollimaks kas IP on kasutuses
ping -c 3 $IP
if [ $? -eq 0 ]; then
echo "IP on olemas" exit 1
else
echo "IP on vaba"
- IP ja võrgumaski sisestus /etc/network/interfaces faili
cat >> /etc/network/interfaces <<EOF
auto eth0:0 iface eth0:0 inet static
address $IP netmask $(ifconfig eth0:0 $IP | grep Mask | cut -d ':' -f 4)
EOF
- Võrgule restart
/etc/init.d/networking restart
- Tulemus
echo "Loodi alias IPga $IP" fi