Change npd to use tmpfs for its working files

This commit is contained in:
Maniacikarus
2008-11-15 16:18:12 +01:00
parent 07400d4b2a
commit 9e44c671f9
4 changed files with 27 additions and 21 deletions

View File

@@ -127,10 +127,10 @@ ERROR:
system ('/usr/bin/touch', "${General::swroot}/time/enable");
system ('/usr/local/bin/timectrl enable >/dev/null 2>&1');
&General::log($Lang::tr{'ntp syncro enabled'});
unlink "${General::swroot}/time/counter";
unlink "/var/lock/time/counter";
if ($timesettings{'UPDATE_METHOD'} eq 'periodically')
{
open(FILE, ">/${General::swroot}/time/counter") or die "Unable to write counter file";
open(FILE, ">/var/lock/time/counter") or die "Unable to write counter file";
flock(FILE, 2);
print FILE "$updateperiod\n";
close FILE;
@@ -147,7 +147,7 @@ ERROR:
else
{
unlink "${General::swroot}/time/enable";
unlink "${General::swroot}/time/settimenow";
unlink "/var/lock/time/settimenow";
unlink "${General::swroot}/time/allowclients"; # DPC added to 1.3.1
system ('/usr/local/bin/timectrl disable >/dev/null 2>&1');
&General::log($Lang::tr{'ntp syncro disabled'})
@@ -162,7 +162,7 @@ ERROR:
$timesettings{'ACTION'} = &Header::cleanhtml ($timesettings{'ACTION'});
if ($timesettings{'ACTION'} eq $Lang::tr{'set time now'} && $timesettings{'ENABLENTP'} eq 'on')
{
system ('/usr/bin/touch', "${General::swroot}/time/settimenow");
system ('/usr/bin/touch', "/var/lock/time/settimenow");
}
&General::readhash("${General::swroot}/time/settings", \%timesettings);
@@ -210,7 +210,7 @@ $selected{'UPDATE_PERIOD'}{$timesettings{'UPDATE_PERIOD'}} = "selected='selected
# added to v0.0.4 to refresh screen if syncro event queued
my $refresh = '';
if ( -e "${General::swroot}/time/settimenow") {
if ( -e "/var/lock/time/settimenow") {
$refresh = "<meta http-equiv='refresh' content='60;' />";
}
@@ -240,10 +240,12 @@ print <<END
END
;
if ( -e "${General::swroot}/time/lastset")
if ( -e "/var/lock/time/lastset")
{
print "$Lang::tr{'clock last synchronized at'}\n";
my $output = `cat ${General::swroot}/time/lastset`;
open(FILE, "</var/lock/time/lastset") or die "Unable to read lastset";
my $output = <FILE>;
close FILE;
print $output;
}
else
@@ -292,7 +294,7 @@ print <<END
END
;
if ( -e "${General::swroot}/time/settimenow") {
if ( -e "/var/lock/time/settimenow") {
print "<tr>\n<td align='center'><img src='/images/clock.gif' alt='' /></td>\n";
print "<td colspan='2'><font color='red'>$Lang::tr{'waiting to synchronize clock'}...</font></td></tr>\n";
}

View File

@@ -25,6 +25,10 @@ case "$1" in
if [ ! -e /var/lock/subsys ]; then
mkdir -p /var/lock/subsys
fi
if [ ! -e /var/lock/time ]; then
mkdir -p /var/lock/time
chown nobody.root /var/lock/time
fi
if [ ! -e /var/run/clamav ]; then
mkdir -p /var/run/clamav
chown clamav:clamav /var/run/clamav

View File

@@ -44,18 +44,18 @@ if [ -n "$1" ]; then
if [ "$ntpdatetest" -eq 0 ]; then
case $tlanguage in
en ) date "+%X %Z on %d %B %Y" > /var/ipfire/time/lastset ;
en ) date "+%X %Z on %d %B %Y" > /var/lock/time/lastset ;
logger -t ipfire "NTP synchronisation event" ;;
de ) date "+%X Uhr am %d.%m.%Y" > /var/ipfire/time/lastset ;
de ) date "+%X Uhr am %d.%m.%Y" > /var/lock/time/lastset ;
logger -t ipfire "NTP Synchronisierung" ;;
* ) date "+%X %Z, %Y-%m-%d" > /var/ipfire/time/lastset ;
* ) date "+%X %Z, %Y-%m-%d" > /var/lock/time/lastset ;
logger -t ipfire "NTP synchronisation" ;;
esac
/sbin/hwclock --systohc
rm -f /var/ipfire/time/settimenow
rm -f /var/lock/time/settimenow
# reset counter variable
cp /var/ipfire/time/counter.conf /var/ipfire/time/counter
cp /var/ipfire/time/counter.conf /var/lock/time/counter
else
case $tlanguage in
de ) logger -t ipfire "ntpdate fehlerhaft" ;;

View File

@@ -11,23 +11,23 @@
# /usr/local/bin/timecheck
if [ -e /var/ipfire/time/enable ]; then
if [ $(cat /var/ipfire/time/settings | grep period) ] && [ -e /var/ipfire/time/counter ]; then
if [ $(cat /var/ipfire/time/counter) -gt 0 ]; then
echo $(($(cat /var/ipfire/time/counter)-5)) > /var/ipfire/time/counter
if [ $(cat /var/ipfire/time/settings | grep period) ] && [ -e /var/lock/time/counter ]; then
if [ $(cat /var/lock/time/counter) -gt 0 ]; then
echo $(($(cat /var/lock/time/counter)-5)) > /var/lock/time/counter
else
touch /var/ipfire/time/settimenow
rm -f /var/ipfire/time/counter
touch /var/lock/time/settimenow
rm -f /var/lock/time/counter
fi
else
# EAO added 2003-08-14 for v1.3.1
# if settings are restored from a backup
# /var/ipfire/time/counter will not exist
# /var/lock/time/counter will not exist
if [ $(cat /var/ipfire/time/settings | grep periodic) ]; then
touch /var/ipfire/time/settimenow
touch /var/lock/time/settimenow
fi
fi
if [ -e /var/ipfire/time/settimenow ]; then
if [ -e /var/lock/time/settimenow ]; then
if [ -e /var/ipfire/time/settime.conf ]; then
/usr/local/bin/settime $(cat /var/ipfire/time/settime.conf)
fi