packages/net/htpdate/patches/101-daemon-run-in-foreground.patch
Marcin Jurkowski 73dbc6cf92 htpdate: modify init scripts to use procd and uci configuration
Modify init script to use standard uci configuration and procd for
process management. We benefit from:
- use of standard LEDE configuration with its ability to revert and
  commit changes
- validation of configuration variables
- procd taking care of restarting daemon when config changes and user
  wants to reload it
- automatic respawning of daemon process in case it dies

The source is patched to make it possible to run as a daemon in
foreground.

Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com>
2017-09-15 10:51:31 +02:00

40 lines
1.2 KiB
Diff

--- a/htpdate.c
+++ b/htpdate.c
@@ -395,6 +395,7 @@ Usage: htpdate [-046abdhlqstxD] [-i pid
-b burst mode\n\
-d debug mode\n\
-D daemon mode\n\
+ -f run in foreground\n\
-h help\n\
-i pid file\n\
-l use syslog for output\n\
@@ -510,7 +511,7 @@ int main( int argc, char *argv[] ) {
/* Parse the command line switches and arguments */
- while ( (param = getopt(argc, argv, "046abdhi:lm:p:qstu:xDM:P:") ) != -1)
+ while ( (param = getopt(argc, argv, "046abdhi:lm:p:qstu:xDfM:P:") ) != -1)
switch( param ) {
case '0': /* HTTP/1.0 */
@@ -593,6 +594,9 @@ int main( int argc, char *argv[] ) {
daemonize = 1;
logmode = 1;
break;
+ case 'f': /* run in foreground */
+ daemonize = 2;
+ break;
case 'M': /* maximum poll interval */
if ( ( maxsleep = atoi(optarg) ) <= 0 ) {
fputs( "Invalid sleep time\n", stderr );
@@ -631,7 +635,9 @@ int main( int argc, char *argv[] ) {
/* Run as a daemonize when -D is set */
if ( daemonize ) {
- runasdaemon( pidfile );
+ if ( daemonize == 1 ) {
+ runasdaemon( pidfile );
+ }
/* Query only mode doesn't exist in daemon mode */
if ( !setmode )
setmode = 1;