Carel plug-in Manuel d'utilisateur Page 75

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 80
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 74
pCOWeb +030220471 – rel. 1.0 – 02.05.2007 75
24
25 *)
26 echo $"Usage: $0 {start|stop|restart}"
27 exit 1
28 ;;
29 esac
DESCRIPTION OF THE LINES
1: Specifies the command executor, currently the only one featured on the pCOWeb is the bash shell (“Bourne Again SHell”), therefore “/bin/bash”.
3: Add the colouring function for the log messages (see the “highlight” script).
5-6: When the script is run, parameter “
$1” is equal to “start”.
7: showMsg (see lines 13-18 of the “highlight” script) displays the text “Starting Ntp script…” in the system log.
8: This line runs the “ntp.sh” script (see the previous section); note that the standard output is redirected to “/dev/null” to avoid unnecessary messages.
9:
showStatus displays the result with the related colouring (see lines 20-37 of the “highlight” script); note the variable “$?”, with the value returned by
the previously run statement.
12-17: As for the start section, the stop section is made up of the same parts, and is called when the pCOWeb is shutdown or when accessed by the user.
19-23: Runs the script again, first the stop section and then the start section, used to have the Plugin reread the new configuration files; it cannot be run from the
web page but only from a remote console.
24-28: This is the section of the script that is run in the event where “
$1” is not equal to start, stop or restart; a message is displayed to indicate that
the script has been run with an incorrect value of “$1”.
“Highlight” script
This script is used to define the standard display used in the various scripts on the pCOWeb.
1 export escGreen=`echo -e "\033[1m\033[32m"`
2 export escRed=`echo -e "\033[1m\033[31m"`
3 export escYell=`echo -e "\033[1m\033[33m"`
4 export escNorm=`echo -e "\033[m"`
5 export msgOk=`echo -e "[\033[1m\033[32mOK\033[m]"`
6 export msgDone=`echo -e "[\033[1m\033[32mDone\033[m]"`
7 export msgYes=`echo -e "[\033[1m\033[32mYes\033[m]"`
8 export msgNo=`echo -e "[\033[1m\033[32mNo\033[m]"`
9 export msgError=`echo -e "[\033[31mError\033[m]"`
10 export msgFail=`echo -e "[\033[31mFailed\033[m]"`
11 export msgBad=`echo -e "[\033[31mBad\033[m]"`
12
13 #
14 # Echo script message
15 #
16 function showMsg(){
17 printf "%-70s" "$1"
18 }
19
20 #
21 # Show status message
22 #
23 function showStatus(){
24 case "$1" in
25 0) echo "$msgOk";;
26 1) echo "$msgFail";;
27 ok) echo "$msgOk";;
28 error) echo "$msgError";;
29 bad) echo "$msgBad";;
30 yes) echo "$msgYes";;
31 no) echo "$msgNo";;
32 done) echo "$msgDone";;
33 failed) echo "msgFail";
34 kill*) test "$1" = "kill" && echo '[Not runn]' || echo $msgOk;;
35 *) echo "$1";;
36 esac
37 }
Vue de la page 74
1 2 ... 70 71 72 73 74 75 76 77 78 79 80

Commentaires sur ces manuels

Pas de commentaire