User:Rsepp: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
#Kontrollib kas IP on parameetrina antud | #Kontrollib kas IP on parameetrina antud | ||
if [ $# -ne 1 ]; then | if [ $# -ne 1 ]; then | ||
echo "Käivita skript $(basename $0) koos | echo "Käivita skript $(basename $0) koos IP-ga" | ||
exit 1 | exit 1 | ||
fi | fi |
Revision as of 17:34, 11 May 2011
<source lang="bash">
- !/bin/bash
- Autor: Rene Sepp A21
- Skript kontrollib, kas Ubuntu serveris on seadistatud etteantud IP alias
IP=$1
- Õiguste kontroll
if [ $UID -ne 0 ]; then echo "Käivita skript $(basename $0) rootkasutaja õigustega" exit 1
fi
- Kontrollib kas IP on parameetrina antud
if [ $# -ne 1 ]; then
echo "Käivita skript $(basename $0) koos IP-ga" exit 1
fi
- Otsib failist '/etc/network/interfaces' argumendis antud IP vastet ja võrdleb seda argumendis antud IP-ga
if [ $IP = $(grep $IP '/etc/network/interfaces' | cut -d"s" -f3 | cut -d" " -f2 | sort -u) ]; then
echo "alias olemas" exit 0
else
echo "aliast pole" exit 1
fi