ipfirereboot.c is able to force a file system check during reboot. This patch makes this function available in the shutdown GUI.
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de --- html/cgi-bin/shutdown.cgi | 79 +++++++++++++++++++++++++++++---------- langs/de/cgi-bin/de.pl | 2 + langs/en/cgi-bin/en.pl | 2 + 3 files changed, 63 insertions(+), 20 deletions(-)
diff --git a/html/cgi-bin/shutdown.cgi b/html/cgi-bin/shutdown.cgi index e0a2c9da0..1321e158b 100644 --- a/html/cgi-bin/shutdown.cgi +++ b/html/cgi-bin/shutdown.cgi @@ -1,11 +1,23 @@ #!/usr/bin/perl -# -# SmoothWall CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The SmoothWall Team -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +###############################################################################
use strict;
@@ -17,6 +29,27 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl";
+###--- HTML HEAD ---### +my $extraHead = <<END +<style> + table#controls { + width: 100%; + border: none; + table-layout: fixed; + } + #controls td { + text-align: center; + } + #controls button { + font-weight: bold; + padding: 0.7em; + min-width: 65%; + } +</style> +END +; +###--- END HTML HEAD ---### + my %cgiparams=(); my $death = 0; my $rebirth = 0; @@ -26,33 +59,39 @@ my $rebirth = 0; $cgiparams{'ACTION'} = ''; &Header::getcgihash(%cgiparams);
-if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) { +if ($cgiparams{'ACTION'} eq "SHUTDOWN") { $death = 1; &General::log($Lang::tr{'shutting down ipfire'}); &General::system('/usr/local/bin/ipfirereboot', 'down'); -} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { +} elsif ($cgiparams{'ACTION'} eq "REBOOT") { $rebirth = 1; &General::log($Lang::tr{'rebooting ipfire'}); &General::system('/usr/local/bin/ipfirereboot', 'boot'); +} elsif ($cgiparams{'ACTION'} eq "REBOOT_FSCK") { + $rebirth = 1; + &General::log($Lang::tr{'rebooting ipfire fsck'}); + &General::system('/usr/local/bin/ipfirereboot', 'bootfs'); } + if ($death == 0 && $rebirth == 0) {
- &Header::openpage($Lang::tr{'shutdown control'}, 1, ''); + &Header::openpage($Lang::tr{'shutdown control'}, 1, $extraHead);
&Header::openbigbox('100%', 'left'); + &Header::openbox('100%', 'left');
- print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; - - &Header::openbox('100%', 'left', ); print <<END -<table width='100%'> -<tr> - <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> - <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> -</tr> -</table> +<form method="post" action="$ENV{'SCRIPT_NAME'}"> + <table id="controls"> + <tr> + <td><button type="submit" name="ACTION" value="SHUTDOWN">$Lang::tr{'shutdown'}</button></td> + <td><button type="submit" name="ACTION" value="REBOOT">$Lang::tr{'reboot'}</button></td> + <td><button type="submit" name="ACTION" value="REBOOT_FSCK">$Lang::tr{'reboot fsck'}</button></td> + </tr> + </table> +</form> END - ; +; &Header::closebox();
} else { diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 0d2228ede..76bf0469d 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2085,11 +2085,13 @@ 'real address' => 'Reale Addresse', 'reboot' => 'Neustart', 'reboot ask' => 'Neustart?', +'reboot fsck' => 'Neustart & Dateisystem-Test', 'reboot question' => 'Extra Abfrage bei neustart und herunterfahren einschalten', 'reboot schedule' => 'Zeitsteuerung für IPFire Neustarts', 'reboot sure' => 'Sind Sie sicher, dass Sie neustarten wollen?', 'rebooting' => 'Starte neu ...', 'rebooting ipfire' => 'Starte IPFire neu', +'rebooting ipfire fsck' => 'Starte IPFire neu, Dateisystem-Test erzwingen', 'received' => 'Empfangen', 'reconnect' => 'Neu Verbinden', 'reconnection' => 'Wiederverbindung', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 2ba6961f3..181dc80b0 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2120,11 +2120,13 @@ 'real address' => 'Real Address', 'reboot' => 'Reboot', 'reboot ask' => 'Reboot?', +'reboot fsck' => 'Reboot & check filesystem', 'reboot question' => 'Extra query for restart and shutdown', 'reboot schedule' => 'Schedule IPFire reboots', 'reboot sure' => 'Are you sure that you want to reboot?', 'rebooting' => 'Rebooting', 'rebooting ipfire' => 'Rebooting IPFire', +'rebooting ipfire fsck' => 'Rebooting IPFire, forcing filesystem check', 'received' => 'Received', 'reconnect' => 'Reconnect', 'reconnection' => 'Reconnection',
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de --- doc/language_issues.en | 2 ++ doc/language_issues.es | 2 ++ doc/language_issues.fr | 2 ++ doc/language_issues.it | 2 ++ doc/language_issues.nl | 2 ++ doc/language_issues.pl | 2 ++ doc/language_issues.ru | 2 ++ doc/language_issues.tr | 2 ++ doc/language_missings | 14 ++++++++++++++ 9 files changed, 30 insertions(+)
diff --git a/doc/language_issues.en b/doc/language_issues.en index 0c9b88777..ee8321a32 100644 --- a/doc/language_issues.en +++ b/doc/language_issues.en @@ -1501,8 +1501,10 @@ WARNING: untranslated string: rdns = rDNS WARNING: untranslated string: read bytes = Bytes Read WARNING: untranslated string: real address = Real Address WARNING: untranslated string: reboot = Reboot +WARNING: untranslated string: reboot fsck = Reboot & check filesystem WARNING: untranslated string: rebooting = Rebooting WARNING: untranslated string: rebooting ipfire = Rebooting IPFire +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: reconnect = Reconnect WARNING: untranslated string: reconnection = Reconnection diff --git a/doc/language_issues.es b/doc/language_issues.es index 626eec21a..2e58b5b02 100644 --- a/doc/language_issues.es +++ b/doc/language_issues.es @@ -1344,6 +1344,8 @@ WARNING: untranslated string: ptr = PTR WARNING: untranslated string: qos enter bandwidths = You will need to enter your downstream and upstream bandwidth! WARNING: untranslated string: random number generator daemon = Random Number Generator Daemon WARNING: untranslated string: rdns = rDNS +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: red1 = RED WARNING: untranslated string: required = Required diff --git a/doc/language_issues.fr b/doc/language_issues.fr index 42f8160b7..72826274b 100644 --- a/doc/language_issues.fr +++ b/doc/language_issues.fr @@ -924,6 +924,8 @@ WARNING: untranslated string: guardian logtarget_syslog = unknown string WARNING: untranslated string: guardian no entries = unknown string WARNING: untranslated string: guardian service = unknown string WARNING: untranslated string: pakfire ago = ago. +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: route config changed = unknown string WARNING: untranslated string: routing config added = unknown string WARNING: untranslated string: routing config changed = unknown string diff --git a/doc/language_issues.it b/doc/language_issues.it index 9c0b62c15..4538461c6 100644 --- a/doc/language_issues.it +++ b/doc/language_issues.it @@ -1128,6 +1128,8 @@ WARNING: untranslated string: pptp route = PPTP Route WARNING: untranslated string: processor vulnerability mitigations = Processor Vulnerability Mitigations WARNING: untranslated string: ptr = PTR WARNING: untranslated string: rdns = rDNS +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: required = Required WARNING: untranslated string: required field = Required field diff --git a/doc/language_issues.nl b/doc/language_issues.nl index 5db088b66..eb41b59ed 100644 --- a/doc/language_issues.nl +++ b/doc/language_issues.nl @@ -1161,6 +1161,8 @@ WARNING: untranslated string: processor vulnerability mitigations = Processor Vu WARNING: untranslated string: ptr = PTR WARNING: untranslated string: random number generator daemon = Random Number Generator Daemon WARNING: untranslated string: rdns = rDNS +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: required = Required WARNING: untranslated string: required field = Required field diff --git a/doc/language_issues.pl b/doc/language_issues.pl index 95e68faaf..a023bdbee 100644 --- a/doc/language_issues.pl +++ b/doc/language_issues.pl @@ -1353,6 +1353,8 @@ WARNING: untranslated string: ptr = PTR WARNING: untranslated string: qos enter bandwidths = You will need to enter your downstream and upstream bandwidth! WARNING: untranslated string: random number generator daemon = Random Number Generator Daemon WARNING: untranslated string: rdns = rDNS +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: red1 = RED WARNING: untranslated string: required = Required diff --git a/doc/language_issues.ru b/doc/language_issues.ru index cfaeed5b5..d1abbc4a8 100644 --- a/doc/language_issues.ru +++ b/doc/language_issues.ru @@ -1348,6 +1348,8 @@ WARNING: untranslated string: ptr = PTR WARNING: untranslated string: qos enter bandwidths = You will need to enter your downstream and upstream bandwidth! WARNING: untranslated string: random number generator daemon = Random Number Generator Daemon WARNING: untranslated string: rdns = rDNS +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: red1 = RED WARNING: untranslated string: required = Required diff --git a/doc/language_issues.tr b/doc/language_issues.tr index e89ce0601..a882db069 100644 --- a/doc/language_issues.tr +++ b/doc/language_issues.tr @@ -1036,6 +1036,8 @@ WARNING: untranslated string: pakfire tree unstable = Unstable WARNING: untranslated string: please reboot to apply your changes = Please reboot to apply your changes WARNING: untranslated string: processor vulnerability mitigations = Processor Vulnerability Mitigations WARNING: untranslated string: ptr = PTR +WARNING: untranslated string: reboot fsck = Reboot & check filesystem +WARNING: untranslated string: rebooting ipfire fsck = Rebooting IPFire, forcing filesystem check WARNING: untranslated string: received = Received WARNING: untranslated string: required = Required WARNING: untranslated string: route config changed = unknown string diff --git a/doc/language_missings b/doc/language_missings index fc74274bd..344406ebc 100644 --- a/doc/language_missings +++ b/doc/language_missings @@ -691,6 +691,8 @@ < qos enter bandwidths < random number generator daemon < rdns +< reboot fsck +< rebooting ipfire fsck < received < red1 < required @@ -930,6 +932,8 @@ < bewan adsl usb < g.dtm < g.lite +< reboot fsck +< rebooting ipfire fsck < upload fcdsl.o ############################################################################ # Checking cgi-bin translations for language: it # @@ -1209,6 +1213,8 @@ < processor vulnerability mitigations < ptr < rdns +< reboot fsck +< rebooting ipfire fsck < received < required < required field @@ -1650,6 +1656,8 @@ < ptr < random number generator daemon < rdns +< reboot fsck +< rebooting ipfire fsck < received < required < required field @@ -2437,6 +2445,8 @@ < qos enter bandwidths < random number generator daemon < rdns +< reboot fsck +< rebooting ipfire fsck < received < red1 < required @@ -3333,6 +3343,8 @@ < qos enter bandwidths < random number generator daemon < rdns +< reboot fsck +< rebooting ipfire fsck < received < red1 < required @@ -3692,6 +3704,8 @@ < please reboot to apply your changes < processor vulnerability mitigations < ptr +< reboot fsck +< rebooting ipfire fsck < received < required < runmode
Hello,
Does the -r switch in shutdown(8) actually work?
I have never used it.
Best, -Michael
On 13 Jul 2021, at 20:06, Leo-Andres Hofmann hofmann@leo-andres.de wrote:
ipfirereboot.c is able to force a file system check during reboot. This patch makes this function available in the shutdown GUI.
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de
html/cgi-bin/shutdown.cgi | 79 +++++++++++++++++++++++++++++---------- langs/de/cgi-bin/de.pl | 2 + langs/en/cgi-bin/en.pl | 2 + 3 files changed, 63 insertions(+), 20 deletions(-)
diff --git a/html/cgi-bin/shutdown.cgi b/html/cgi-bin/shutdown.cgi index e0a2c9da0..1321e158b 100644 --- a/html/cgi-bin/shutdown.cgi +++ b/html/cgi-bin/shutdown.cgi @@ -1,11 +1,23 @@ #!/usr/bin/perl -# -# SmoothWall CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The SmoothWall Team -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +###############################################################################
use strict;
@@ -17,6 +29,27 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl";
+###--- HTML HEAD ---### +my $extraHead = <<END +<style>
- table#controls {
width: 100%;
border: none;
table-layout: fixed;
- }
- #controls td {
text-align: center;
- }
- #controls button {
font-weight: bold;
padding: 0.7em;
min-width: 65%;
- }
+</style> +END +; +###--- END HTML HEAD ---###
my %cgiparams=(); my $death = 0; my $rebirth = 0; @@ -26,33 +59,39 @@ my $rebirth = 0; $cgiparams{'ACTION'} = ''; &Header::getcgihash(%cgiparams);
-if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) { +if ($cgiparams{'ACTION'} eq "SHUTDOWN") { $death = 1; &General::log($Lang::tr{'shutting down ipfire'}); &General::system('/usr/local/bin/ipfirereboot', 'down'); -} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { +} elsif ($cgiparams{'ACTION'} eq "REBOOT") { $rebirth = 1; &General::log($Lang::tr{'rebooting ipfire'}); &General::system('/usr/local/bin/ipfirereboot', 'boot'); +} elsif ($cgiparams{'ACTION'} eq "REBOOT_FSCK") {
- $rebirth = 1;
- &General::log($Lang::tr{'rebooting ipfire fsck'});
- &General::system('/usr/local/bin/ipfirereboot', 'bootfs');
}
if ($death == 0 && $rebirth == 0) {
- &Header::openpage($Lang::tr{'shutdown control'}, 1, '');
&Header::openpage($Lang::tr{'shutdown control'}, 1, $extraHead);
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left');
- print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
- &Header::openbox('100%', 'left', ); print <<END
-<table width='100%'> -<tr>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td>
<td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td>
-</tr> -</table> +<form method="post" action="$ENV{'SCRIPT_NAME'}">
<table id="controls">
<tr>
<td><button type="submit" name="ACTION" value="SHUTDOWN">$Lang::tr{'shutdown'}</button></td>
<td><button type="submit" name="ACTION" value="REBOOT">$Lang::tr{'reboot'}</button></td>
<td><button type="submit" name="ACTION" value="REBOOT_FSCK">$Lang::tr{'reboot fsck'}</button></td>
</tr>
</table>
+</form> END
- ;
+; &Header::closebox();
} else { diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 0d2228ede..76bf0469d 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2085,11 +2085,13 @@ 'real address' => 'Reale Addresse', 'reboot' => 'Neustart', 'reboot ask' => 'Neustart?', +'reboot fsck' => 'Neustart & Dateisystem-Test', 'reboot question' => 'Extra Abfrage bei neustart und herunterfahren einschalten', 'reboot schedule' => 'Zeitsteuerung für IPFire Neustarts', 'reboot sure' => 'Sind Sie sicher, dass Sie neustarten wollen?', 'rebooting' => 'Starte neu ...', 'rebooting ipfire' => 'Starte IPFire neu', +'rebooting ipfire fsck' => 'Starte IPFire neu, Dateisystem-Test erzwingen', 'received' => 'Empfangen', 'reconnect' => 'Neu Verbinden', 'reconnection' => 'Wiederverbindung', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 2ba6961f3..181dc80b0 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2120,11 +2120,13 @@ 'real address' => 'Real Address', 'reboot' => 'Reboot', 'reboot ask' => 'Reboot?', +'reboot fsck' => 'Reboot & check filesystem', 'reboot question' => 'Extra query for restart and shutdown', 'reboot schedule' => 'Schedule IPFire reboots', 'reboot sure' => 'Are you sure that you want to reboot?', 'rebooting' => 'Rebooting', 'rebooting ipfire' => 'Rebooting IPFire', +'rebooting ipfire fsck' => 'Rebooting IPFire, forcing filesystem check', 'received' => 'Received', 'reconnect' => 'Reconnect', 'reconnection' => 'Reconnection', -- 2.27.0.windows.1
On Wed, Jul 14, 2021 at 05:12:27PM +0100, Michael Tremer (michael.tremer@ipfire.org) wrote:
Does the -r switch in shutdown(8) actually work?
Yes. It has worked in all Linux systems I've used for years (and several non-Linux Unix-based systems like HP-UX).
In the past "shutdown -r now" and "reboot" differed, e.g., reboot didn't sync or run shutdown scripts (and thus shutdown was sometimes recommended as the "safe" or "clean" way to reboot), but nowadays they're identical apart from some different options (notably, reboot has the "-f" option for "dirty" reboot, but it's not default anymore). People generally use whichever they're used to.
Today shutdown, reboot, halt and poweroff are all symlinks to systemctl in Debian and Ubuntu at least, but options and defaults differ depending on which name it is called with.
E.g., Debian Buster:
$ ls -l /sbin/{shutdown,reboot,halt,poweroff} lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/halt -> /bin/systemctl lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/poweroff -> /bin/systemctl lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/reboot -> /bin/systemctl lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/shutdown -> /bin/systemctl
Am 14.07.2021 um 19:41 schrieb Tapani Tarvainen:
On Wed, Jul 14, 2021 at 05:12:27PM +0100, Michael Tremer (michael.tremer@ipfire.org) wrote:
Does the -r switch in shutdown(8) actually work?
Yes. It has worked in all Linux systems I've used for years (and several non-Linux Unix-based systems like HP-UX).
I also tried this on my IPFire test system before submitting the patch and can confirm that -r (and -F) work as expected :)
In the past "shutdown -r now" and "reboot" differed, e.g., reboot didn't sync or run shutdown scripts (and thus shutdown was sometimes recommended as the "safe" or "clean" way to reboot), but nowadays they're identical apart from some different options (notably, reboot has the "-f" option for "dirty" reboot, but it's not default anymore). People generally use whichever they're used to.
Today shutdown, reboot, halt and poweroff are all symlinks to systemctl in Debian and Ubuntu at least, but options and defaults differ depending on which name it is called with.
E.g., Debian Buster:
$ ls -l /sbin/{shutdown,reboot,halt,poweroff} lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/halt -> /bin/systemctl lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/poweroff -> /bin/systemctl lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/reboot -> /bin/systemctl lrwxrwxrwx 1 root root 14 Mar 18 21:59 /sbin/shutdown -> /bin/systemctl
Thanks for the detailed explanation!