Carel plug-in Manuel d'utilisateur Page 74

  • 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 73
pCOWeb +030220471 – rel. 1.0 – 02.05.2007 74
The ntp.sh script file
This runs the “ntpdate” binary file, deletes any temporary files created by “ntpdate” and, if this is involved in the periodical updating of the time, manages the cycle of
updates.
1 #!/bin/sh
2 . /etc/profile > /dev/null
3 . $CONF_USERS/ntp_client.conf
4
5 while [ 1 ]; do
6 ntpdate ${NTP_URL} > /dev/null
7 date
8 rm /initrd/tmp/ntp
9 sleep 3600
10 done
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”.
2: Read the “/etc/profile” file that contains the definition of the $CONF_USERS, $RC_USERS, $BIN_USERS variables, to simplify the management of the paths
inside the Plugin.
3: Read the Plugin configuration file “ntp_client.conf” in the $CONF_USERS directory, so as to be able to use the variables set in the configuration (for example,
from the html page) in the script.
5: Infinite cycle to allow the script to continuously run the statements.
6: Update the time using “ntpdate”, requesting the data from the server defined in $NTP_URL, and redirect the standard output to “/dev/null” to eliminate any
unnecessary messages.
7: Display the time obtained above.
8: Delete a temporary file created by “ntpdate”, otherwise “ntpdate” cannot be run again.
9: Wait 3600 seconds before running the next statement (synchronisation); alternatively this could have been defined as a parameter in “ntp_client.conf” and
then easily recalled, for example, by the $SLEEP_TIME variable.
START-UP SCRIPTS
These are ALL the files in the Plugin “rc_users” directory on the Plugin being installed.
They are used to be able to run the Plugin functions automatically when the system is started.
During the installation the scripts are installed in the “/usr/local/root/flash/rc_users/” directory, the path string is also returned by the $RC_USERS system variable.
During installation, each of these files are attributed all the permissions required by the Linux operating system, in the same way as for the executable files seen above
(
Figure H.c on page 73).
NOTE The execution permissions are also used by the system to decide which scripts to run automatically; to prevent a Plugin from being run at start-up, reset the
execution bits (“Execute”) relating to the script.
Structure of the start-up scripts
For the start-up script to run correctly, it must have the following structure (the example refers to the NTP Plugin):
1 #!/bin/bash
2
3 . /etc/init.d/functions/highlight
4
5 case "$1" in
6 start)
7 showMsg "Starting Ntp script..."
8 (ntp.sh &) > /dev/null
9 showStatus "$?"
10 ;;
11
12 stop)
13 showMsg "Stopping Ntp Script..."
14 id=$(pidof -x ntp.sh)
15 kill $id
16 showStatus "kill$id"
17 ;;
18
19 restart)
20 showMsg "Restart ntp Script..."
21 $0 stop
22 $0 start
23 ;;
Vue de la page 73
1 2 ... 69 70 71 72 73 74 75 76 77 78 79 80

Commentaires sur ces manuels

Pas de commentaire