From 9776448c89316d125316db3f2660bafb28cf0e48 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Mon, 7 Sep 2020 03:16:55 +0200 Subject: [PATCH] added a cron mode. this will execute the script only once and then execute --- README.md | 3 ++- config.example.json | 1 + uplink | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b9d0241..018d7fd 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Edit config.json to your needs. { "interval": 60, "database": "./uplink.sqlite3", + "cron_mode": false, "uplinks": [ { "provider": "Cable Provider", "ip": "192.168.0.1", "password": "1234" }, { "provider": "DSL Provider", "ip": "192.168.1.1", "password": "1234" } @@ -68,7 +69,7 @@ can move fast-forward. - A lot... :) - SQL server backend - Gtk+ frontend - - A cron mode to not let uplink run in an endless loop to be scheduled and executed by cron. + - ~~A cron mode to not let uplink run in an endless loop to be scheduled and executed by cron.~~ - A daemon mode to be a real UNIX daemon. For now, it's just "sleep" based. - Platform independence \ No newline at end of file diff --git a/config.example.json b/config.example.json index 90aa986..df3de26 100644 --- a/config.example.json +++ b/config.example.json @@ -1,6 +1,7 @@ { "interval": 60, "database": "./uplink.sqlite3", + "cron_mode": false, "uplinks": [ { "provider": "Cable Provider", "ip": "192.168.0.1", "password": "1234" }, { "provider": "DSL Provider", "ip": "192.168.1.1", "password": "1234" } diff --git a/uplink b/uplink index 8008317..6d576b1 100755 --- a/uplink +++ b/uplink @@ -128,6 +128,8 @@ def run(config): # with daemon.DaemonContext(): while True: get_data(config) + if config["cron_mode"]: + exit(0) time.sleep(config["interval"])