pCOWeb
+030220966 – rel. 1.1 – 12.12.2017
80
DESCRIPTION OF THE LINES
(also see APPENDIX G on page 68)
1:
Syntax that defines the text shown on the link on the “Configuration/Plugins” HTML page (
Figure 9.m
on page 47); if not present, the text shown on
the link is the name of the HTML file.
IMPORTANT This should not be confused with the pluginname file, located in the Plugin installation directory, which is only used during the
installation and uninstallation phase.
4: Syntax
telling
the
pCOWeb
to process the page and replace the CAREL tags with the corresponding values; this is required to be able to write and
read the configuration files.
23: The
HTML
form
statement is used to send information from the html page to the
pCOWeb
; note that the
method
must always be
POST
.
30: The
getdb
tag is used to display the value of a setting in the configuration file specified. The example refers to the value associated with NTP_URL in
the ntp_client.conf file located in “/usr/local/root/flash/etc/sysconfig/conf_users/”; the full path does not need to be specified if the file is located in a
subdirectory of “/usr/local/root/flash/etc/sysconfig /”; another directory can be specified by correctly indicating the full path, starting from the root (“/”),
nonetheless it is recommended to use the suggested directory so as to maintain coherence in the structure of all the Plugins developed.
32: This HTML statement defines an input field used to display and modify the value associated with a parameter in a configuration file. The
setdb
statement can be used to modify the value associated with the variable when the “Submit” button is selected on the form.
36: Closing the page, the “Submit” button is displayed.
39: Link that, selecting the “Submit” button, refreshes the display of the
pCOWeb
Plugin configuration page; Administrator authentication (see 9.2.1 on
page 42) is required to display the page.
The field displayed to change the value of the NTP_URL parameter is as
shown in
Figure I.b
.
Figure I.b - Field used to set the address of the NTP server
EXECUTABLE FILES
These are ALL the files in the Plugin “bin_users” directory of the Plugin being installed. They represent the executable files (binary files or bash scripts) that manage
the functions of the Plugin.
During installation the executable files are installed in the “/usr/local/root/flash/bin_users/” directory, which corresponds to the
$BIN_USERS system variable; the path is included in the $PATH system variable. During installation, each of these files are attributed the permission to be
executed as envisaged by the Linux operating system, shown in Figure I.c.
The following executable files are included in the NTP Plugin:
•
“ntpdate” (this handles communication with the NTP server and writes the time to the system clock);
•
“ntp.sh” (this handles the management); the latter is described in detail below.
Figure I.c - Linux permission for executing the “ntpdate” files
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.