User:Rsepp

From ICO wiki
Revision as of 17:34, 11 May 2011 by Rsepp (talk | contribs)
Jump to navigationJump to search

<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