bash – skript – Správa služeb

#/bin/sh

B=`tput smso`
E=`tput rmso`
DNES=`date`

APACHE=“/etc/init.d/apache2″
MYSQL=“/etc/init.d/mysql“

while true
   do

     clear
     echo „${B} VPADMIN – ${DNES} ${E}“
     tput bold; echo „*** SLUZBY ******************“; tput sgr0
     echo „99 – sysv-rc-conf“
     echo „98 – stav Apache a MxSQL“
     tput bold; echo -e „\n*** APACHE ******************“; tput sgr0
     echo „1 – restart“
     echo „2 – stop“
     echo „3 – start“
     echo „4 – editace vp-local.conf“
     tput bold; echo -e „\n*** MYSQL *******************“; tput sgr0
     echo „5 – start“
     echo „6 – stop“
     tput bold
     echo -e „\n—————————–„
     read -p „Zadej (q – konec): “ OPERACE
     echo „“
     tput sgr0

     clear

   if [[ $OPERACE -eq „99“ ]]
   then
     sysv-rc-conf
   elif [[ $OPERACE -eq „98“ ]]
   then
     echo -e „\n${B} Apache ${E}“
     ps -ef | grep apache
     echo -e „\n${B} MySQL ${E}“
     ps -ef | grep mysql
   elif [[ $OPERACE -eq „1“ ]]
   then
     $APACHE restart
     echo „“
     ps -ef | grep apache
   elif [[ $OPERACE -eq „2“ ]]
   then
     $APACHE stop
     echo „“
     ps -ef | grep apache
   elif [[ $OPERACE -eq „3“ ]]
   then
     $APACHE start
     echo „“
     ps -ef | grep apache
   elif [[ $OPERACE -eq „4“ ]]
   then
     vi /etc/apache2/conf-enabled/vp-local.conf
     $APACHE restart
     echo „“
     ps -ef | grep apache
   elif [[ $OPERACE -eq „5“ ]]
   then
     $MYSQL start
     echo „“
     ps -ef | grep mysql
   elif [[ $OPERACE -eq „6“ ]]
   then
     $MYSQL stop
     echo „“
     ps -ef | grep mysql
   elif [[ $OPERACE -eq „q“ ]]
   then
     echo „Skript $0 byl ukoncen.“
   exit
else
   echo „Neznama operace. Bylo zadano ${OPERACE}.“
fi


tput bold

echo „“
read -p „Stiskni klavesu <ENTER> pro pokracovani…“
tput sgr0


done