User:Trohumet: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
#Autor: Toomas Rohumets A21 | #Autor: Toomas Rohumets A21 | ||
#Skript, mis loob Ubuntu serverile IP aliase | #Skript, mis loob Ubuntu serverile IP aliase | ||
#Versioon 0.1 | #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 | if [ $# -ne 1 ]; then | ||
echo "Käivita skript $(basename $0) koos IPga" | echo "Käivita skript $(basename $0) koos IPga" | ||
Line 13: | Line 21: | ||
IP=$1 | IP=$1 | ||
#Ping, kontrollimaks kas IP on kasutuses | |||
ping -c 3 $IP | ping -c 3 $IP | ||
Line 20: | Line 30: | ||
else | else | ||
echo "IP on vaba" | echo "IP on vaba" | ||
#IP ja võrgumaski sisestus /etc/network/interfaces faili | |||
cat >> /etc/network/interfaces <<EOF | cat >> /etc/network/interfaces <<EOF | ||
auto eth0:0 | auto eth0:0 | ||
Line 26: | Line 37: | ||
netmask $(ifconfig eth0:0 $IP | grep Mask | cut -d ':' -f 4) | netmask $(ifconfig eth0:0 $IP | grep Mask | cut -d ':' -f 4) | ||
EOF | EOF | ||
#Võrgule restart | |||
/etc/init.d/networking restart | /etc/init.d/networking restart | ||
fi | fi |
Revision as of 14:09, 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
fi