Add ability for filesystem check and restart network through GUI
mbox

Message ID CAM7c+bm_o8mzOKRYLYZb9gr5A+xzPDLfHqcd+ZRU2ScTjdCLRQ@mail.gmail.com
State New
Headers show

Message

Osmar Gonzalez Aug. 20, 2015, 11:54 p.m. UTC
Just on the side note I added the function of restarting the network stack
through the GUI only because I find useful at times when the DNS might be
stall or when in DHCP mode the IP address wasn't renewed, simply restarting
the network stack helps in fixing minor problems here in there without the
need to login through SSH or CLI to restart


 #define OP_SCHEDULE_REM   "cron-"
@@ -66,6 +67,13 @@ int main(int argc, char**argv)
     return 0;
  }

+   if (argc==2 && strcmp(argv[1], OP_REBOOT_NETWORK)==0)
+ {
+    safe_system("/etc/rc.d/init.d/network stop");
+    safe_system("/etc/rc.d/init.d/network start");
+    return 0;
+ }
+
  // output schedule to stdout
  if (argc==2 && strcmp(argv[1], OP_SCHEDULE_GET)==0)
  {

Comments

Michael Tremer Aug. 21, 2015, 7:34 a.m. UTC | #1
Hi,

thank you for submitting this patch.

On Thu, 2015-08-20 at 06:54 -0700, Osmar Gonzalez wrote:
> Just on the side note I added the function of restarting the network
> stack through the GUI only because I find useful at times when the
> DNS might be stall or when in DHCP mode the IP address wasn't
> renewed, simply restarting the network stack helps in fixing minor
> problems here in there without the need to login through SSH or CLI
> to restart 

I think that this should rather not happen and if so we should look for
fixing any issues that are causing this, but I have no objections to
the change if you need it.

What is the reason for the FS check? The system should perform them
when ever needed. Other than that there is really no reason to why the
user should trigger that.

Best,
-Michael

> diff --git a/html/cgi-bin/shutdown.cgi b/html/cgi-bin/shutdown.cgi
> index 998f9f8..fa66962 100644
> --- a/html/cgi-bin/shutdown.cgi
> +++ b/html/cgi-bin/shutdown.cgi
> @@ -34,6 +34,13 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'})
> {
>  	$rebirth = 1;
>  	&General::log($Lang::tr{'rebooting ipfire'});
>  	system '/usr/local/bin/ipfirereboot boot';
> +} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot_net'}) {
> +	&General::log($Lang::tr{'rebooting network'});
> +	system '/usr/local/bin/ipfirereboot network &> /dev/null';
> +} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot_fs'}) {
> +	$rebirth = 1;
> +	&General::log($Lang::tr{'rebooting fs'});
> +	system '/usr/local/bin/ipfirereboot bootfs';
>  }
>  if ($death == 0 && $rebirth == 0) {
>  
> @@ -51,6 +58,12 @@ if ($death == 0 && $rebirth == 0) {
>  	<td width='50%' align='center'><input type='submit'
> name='ACTION' value='$Lang::tr{'shutdown'}' /></td>
>  </tr>
>  </table>
> +<table width='100%'>
> +<tr>
> +	<td width='50%' align='center'><input type='submit'
> name='ACTION' value='$Lang::tr{'reboot_net'}' /></td>
> +	<td width='50%' align='center'><input type='submit'
> name='ACTION' value='$Lang::tr{'reboot_fs'}' /></td>
> +</tr>
> +</table>
>  END
>  	;
>  	&Header::closebox();
> @@ -85,4 +98,3 @@ END
>  
>  &Header::closebigbox();
>  &Header::closepage();
> -
> diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
> index af7fda9..a2ba697 100644
> --- a/langs/en/cgi-bin/en.pl
> +++ b/langs/en/cgi-bin/en.pl
> @@ -1917,8 +1917,12 @@
>  'reboot question' => 'Extra query for restart and shutdown',
>  'reboot schedule' => 'Schedule IPFire reboots',
>  'reboot sure' => 'Are you sure that you want to reboot?',
> +'reboot_fs' => 'File Systemcheck',

This is spelled "Filesystem check". A verb would also help, like
"Perform a filesystem check".

> +'reboot_net' => 'Reboot Network',

This should better be called "Restart network" because the system is
not rebooted.

>  'rebooting' => 'Rebooting',
> +'rebooting fs' => 'Rebooting with filesystem check.',
>  'rebooting ipfire' => 'Rebooting IPFire',
> +'rebooting network' => 'Rebooting Network',
>  'reconnect' => 'Reconnect',
>  'reconnection' => 'Reconnection',
>  'red' => 'Internet',
> diff --git a/src/misc-progs/ipfirereboot.c b/src/misc
> -progs/ipfirereboot.c
> index 5e75879..5f11ba3 100644
> --- a/src/misc-progs/ipfirereboot.c
> +++ b/src/misc-progs/ipfirereboot.c
> @@ -29,7 +29,8 @@
>  
>  /* define operations */
>  #define OP_REBOOT    	  "boot"
> -#define OP_REBOOT_FS 	  "bootfs" // add filesystem check
> option (not yet in GUI)
> +#define OP_REBOOT_FS 	  "bootfs"
> +#define OP_REBOOT_NETWORK "network"
>  #define OP_SHUTDOWN  	  "down"
>  #define OP_SCHEDULE_ADD   "cron+"
>  #define OP_SCHEDULE_REM   "cron-"
> @@ -66,6 +67,13 @@ int main(int argc, char**argv)
>  	    return 0;
>  	}
>  
> +   if (argc==2 && strcmp(argv[1], OP_REBOOT_NETWORK)==0)
> +	{
> +	    safe_system("/etc/rc.d/init.d/network stop");
> +	    safe_system("/etc/rc.d/init.d/network start");
> +	    return 0;
> +	}
> +
>  	// output schedule to stdout
>  	if (argc==2 && strcmp(argv[1], OP_SCHEDULE_GET)==0)
>  	{
>