User:Trohumet: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Blanked the page |
No edit summary |
||
Line 1: | Line 1: | ||
==Quest14== | |||
<source lang="bash"> | |||
#!/bin/bash | |||
#Autor: Toomas Rohumets A21 | |||
#Skript, mis loob Ubuntu serverile IP aliase | |||
#Versioon 0.1 | |||
#!/bin/bash | |||
if [ $# -ne 1 ]; then | |||
echo "Käivita skript $(basename $0) koos IPga" | |||
exit 1 | |||
fi | |||
IP=$1 | |||
ping -c 3 $IP | |||
if [ $? -eq 0 ]; then | |||
echo "IP on olemas" | |||
exit 1 | |||
else | |||
echo "IP on vaba" | |||
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 | |||
/etc/init.d/networking restart | |||
fi |
Revision as of 13:56, 11 May 2011
Quest14
<source lang="bash">
- !/bin/bash
- Autor: Toomas Rohumets A21
- Skript, mis loob Ubuntu serverile IP aliase
- Versioon 0.1
- !/bin/bash
if [ $# -ne 1 ]; then
echo "Käivita skript $(basename $0) koos IPga" exit 1
fi
IP=$1 ping -c 3 $IP
if [ $? -eq 0 ]; then
echo "IP on olemas" exit 1
else
echo "IP on vaba" 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
/etc/init.d/networking restart
fi