User:Rsepp: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Rsepp (talk | contribs)
No edit summary
Rsepp (talk | contribs)
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 IPga"
         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">

  1. !/bin/bash
  2. Autor: Rene Sepp A21
  3. Skript kontrollib, kas Ubuntu serveris on seadistatud etteantud IP alias

IP=$1

  1. Õiguste kontroll

if [ $UID -ne 0 ]; then echo "Käivita skript $(basename $0) rootkasutaja õigustega" exit 1

fi

  1. Kontrollib kas IP on parameetrina antud

if [ $# -ne 1 ]; then

       echo "Käivita skript $(basename $0) koos IP-ga"
       exit 1

fi

  1. 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