par joebar » 25 Mars 2003 11:21
J'ai intégré le NTPD sur mon IPCOP, ca marche nickel !!! Merci Wann.
<BR>
<BR>Pour l'interface :
<BR>
<BR>Dans le fichier header.pl, rajouter ceci :
<BR>
<BR>sub showsystemsection
<BR>{
<BR> &subsectionstart();
<BR>....
<BR> &subsectiontab('/cgi-bin/ntpd.cgi', $tr{'time server'}, 0);
<BR>.....
<BR> &subsectionend();
<BR>
<BR>Dans le fichier en.pl, rajouter ceci :
<BR>
<BR># ntpd.cgi
<BR>'ntpd is enabled' => 'NTPD is enable. Restarting.',
<BR>'ntpd is disabled' => 'NTPD is disable. Stopping.',
<BR>'time server' => 'Time Server',
<BR>'time server2' => 'Time Server:',
<BR>
<BR>Dans le fichier fr.pl, rajouter ceci :
<BR>
<BR># ntpd.cgi
<BR>'ntpd is enabled' => 'Serveur de Temps est activé. Redémarrage.',
<BR>'ntpd is disabled' => 'Serveur de Temps est désactivé. Arrêt.',
<BR>'time server' => 'Serveur de Temps',
<BR>'time server2' => 'Serveur de Temps:',
<BR>
<BR>Créer le fichier ntpd.cgi dans /home/http/cgi-bin :
<BR>
<BR>#!/usr/bin/perl
<BR>#
<BR># IPCOP CGIs
<BR>#
<BR># This code is distributed under the terms of the GPL
<BR>#
<BR># (c) The IPCop Team
<BR>#
<BR># $Id: ntpd.cgi,v 1.0 2003/25/03 12:32:08 riddles Exp $
<BR>#
<BR>
<BR>require '/var/ipcop/header.pl';
<BR>
<BR>my (%ntpdsettings, %checked, $errormessage);
<BR>
<BR>&showhttpheaders();
<BR>
<BR>$ntpdsettings{'ENABLE_NTPD'} = 'off';
<BR>$ntpdsettings{'ACTION'} = '';
<BR>&getcgihash(%ntpdsettings);
<BR>
<BR>$errormessage = '';
<BR>if ($ntpdsettings{'ACTION'} eq $tr{'save'})
<BR>{
<BR> &writehash("${swroot}/ntpd/settings", %ntpdsettings);
<BR> if ($ntpdsettings{'ENABLE_NTPD'} eq 'on')
<BR> {
<BR> &log($tr{'ntpd is enabled'});
<BR> system ('/bin/touch', "${swroot}/ntpd/enablentpd");
<BR> }
<BR> else
<BR> {
<BR> &log($tr{'ntpd is disabled'});
<BR> unlink "${swroot}/ntpd/enablentpd";
<BR> }
<BR>
<BR> system('/usr/sbin/ntpd', '-A', '-p', '/var/run/ntpd.pid');
<BR>}
<BR>
<BR>&readhash("${swroot}/ntpd/settings", %ntpdsettings);
<BR>
<BR>$checked{'ENABLE_NTPD'}{'off'} = '';
<BR>$checked{'ENABLE_NTPD'}{'on'} = '';
<BR>$checked{'ENABLE_NTPD'}{$ntpdsettings{'ENABLE_NTPD'}} = 'CHECKED';
<BR>
<BR>&openpage($tr{'time server'}, 1, '');
<BR>
<BR>&showsystemsection();
<BR>
<BR>&openbigbox('100%', 'LEFT');
<BR>
<BR>print "<FORM METHOD='POST'>n";
<BR>
<BR>&openbox('100%', 'LEFT', $tr{'time server2'});
<BR>print <<END
<BR><TABLE WIDTH='100%'>
<BR><TR>
<BR> <TD WIDTH='25%' CLASS='base'>NTPD:</TD>
<BR> <TD WIDTH='25%'><INPUT TYPE='checkbox' NAME='ENABLE_NTPD' $checked{'ENABLE_NTPD'}{'on'}></TD>
<BR> <TD WIDTH='25%' ALIGN='CENTER'><INPUT TYPE='submit' NAME='ACTION' VALUE='$tr{'save'}'></TD>
<BR> <TD WIDTH='25%'> </TD>
<BR></TR>
<BR></TABLE>
<BR>END
<BR>;
<BR>&closebox();
<BR>
<BR>&openbox('100%', 'LEFT', $tr{'error messages'});
<BR>print "<CLASS NAME='base'>$errormessage";
<BR>print " </CLASS>";
<BR>&closebox();
<BR>
<BR>print "</FORM>n";
<BR>
<BR>&closebigbox();
<BR>
<BR>&closepage();
<BR>
<BR>Pensez à mettre les droits comme sur les autres fichiers.
<BR>
<BR>Ensuite il faut créer le dossier ntpd dans /var/ipcop, et y ajouter les 2 fichiers suivants :
<BR>
<BR>settings :
<BR>ENABLE_NTPD=on
<BR>
<BR>et enablentpd (vide)
<BR>
<BR>les droits pour ces 2 fichiers sont :
<BR>-rw-r--r-- 1 nobody nobody 0 Mar 25 09:34 enablentpd
<BR>-rw-r--r-- 1 nobody nobody 16 Mar 25 09:35 settings
<BR>
<BR>et pour l'exe ntdp :
<BR>
<BR>-rwxr-x--- 1 root nobody 252024 Sep 25 00:14 /usr/sbin/ntpd
<BR>
<BR>
<BR>Après tout ca, l'interface et visible dans le menu SYSTEM, il est possible de cocher l'option et de démarrer le démon NTDP, mais l'arrêt n'est pas encore possible, il faudrait trouver un executable comme restartssh qui regarde si le demon tourne ou non pour le démarrer ou l'arreter.
<BR>
<BR>Voila @+
<BR>
<BR>Si quelqu'un peux faire l'exe restartntpd, ce serait cool.
<BR>