From 36ae1964ad83ec4227bf7ef6aecb00bd125100d9 Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Sun, 12 Jun 2022 21:09:06 -0500 Subject: [PATCH] Added removetimestamp flag This is useful for logging programs such as systemd to run the program without having double timestamps. It also remove the GPL license information Updated the Systemd service to use this --- src/rhosts.go | 13 ++++++++++--- src/systemd/rhosts.service | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/rhosts.go b/src/rhosts.go index e8edcda..662d64d 100644 --- a/src/rhosts.go +++ b/src/rhosts.go @@ -69,15 +69,14 @@ func main() { var daemon bool=false var interval int=1440 var versionflag bool=false + var removetimestamp bool=false var siteBuff []siteList - // GPL information - fmt.Println(GPL) - // Parsing Flags flag.BoolVar(&daemon, "d", false, "Should this be run in daemon mode") flag.IntVar(&interval, "t", 1440, "Minutes until next run of daemon") flag.BoolVar(&versionflag, "version", false, "show version information") + flag.BoolVar(&removetimestamp, "removetimestamp", false, "Removes the timestamp, used with logging programs to prevent a double timestamp") flag.Parse() // Display version information @@ -86,6 +85,14 @@ func main() { return } + // Check if timestamp should be removed + if removetimestamp { + log.SetFlags(0) + }else{ + // GPL information + fmt.Println(GPL) + } + if daemon { log.Print("daemon:" , daemon) log.Print("interval:",interval) diff --git a/src/systemd/rhosts.service b/src/systemd/rhosts.service index 50794f8..34a131d 100644 --- a/src/systemd/rhosts.service +++ b/src/systemd/rhosts.service @@ -1,11 +1,11 @@ [Unit] -Description=update the hosts file to remove ads +Description=rhosts updating the hosts file to remove ads Wants=network-online.target After=network.target network-online.target [Service] Type=oneshot -ExecStart=/usr/local/bin/rhosts +ExecStart=/usr/local/bin/rhosts --removetimestamp [Install] WantedBy=multi-user.target