diff options
-rw-r--r-- | 0tdns_crontab | 2 | ||||
-rwxr-xr-x | install.sh | 4 | ||||
-rwxr-xr-x | src/hourly.py | 6 | ||||
-rwxr-xr-x | src/hourly.sh | 3 | ||||
-rwxr-xr-x | uninstall.sh | 2 |
5 files changed, 8 insertions, 9 deletions
diff --git a/0tdns_crontab b/0tdns_crontab index 306d439..a6b9274 100644 --- a/0tdns_crontab +++ b/0tdns_crontab @@ -1 +1 @@ -0 * * * * /usr/sbin/hourly.sh # <AUTO_GENERATED_0TDNS_ENTRY> do not remove this '<>' tag +0 * * * * /usr/sbin/hourly.py # <AUTO_GENERATED_0TDNS_ENTRY> do not remove this '<>' tag @@ -20,12 +20,10 @@ install -D -m755 src/perform_queries.py "$INSTALL_ROOT"/var/lib/0tdns/perform_qu install -D -m644 db_connection_config.yml "$INSTALL_ROOT"/etc/0tdns/db_connection_config.yml # This one would make sense to be executed directly, so it'll go to sbin +# This happens to also be the script, that gets called by cron install -D -m744 src/hourly.py "$INSTALL_ROOT"/usr/sbin/hourly.py # This one shall be imported from other scripts install -D -m644 src/ztdns_db_connectivity.py "$INSTALL_ROOT"/usr/lib/python3/dist-packages/ztdns_db_connectivity.py -# This is the script, that will get called by cron -install -D -m744 src/hourly.sh "$INSTALL_ROOT"/usr/sbin/hourly.sh - # simillar approach will be used to install other files diff --git a/src/hourly.py b/src/hourly.py index 34097a3..5306a85 100755 --- a/src/hourly.py +++ b/src/hourly.py @@ -3,6 +3,7 @@ from sys import argv import subprocess from os import path +from time import gmtime, strftime # our own module used by several scripts in the project from ztdns_db_connectivity import start_db_connection @@ -38,7 +39,10 @@ def get_vpn_connections(cursor, hour): connection = start_db_connection() cursor = connection.cursor() -hour = argv[1] +# round down to an hour - this datetime format is one +# of the formats accepted by postgres +hour = strftime('%Y-%m-%d %H:00', gmtime()) + vpns = get_vpn_connections(cursor, hour) for vpn_id, config_hash in vpns: diff --git a/src/hourly.sh b/src/hourly.sh deleted file mode 100755 index be1c52a..0000000 --- a/src/hourly.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -hourly.py "`date '+%Y-%m-%d %H:00'`" diff --git a/uninstall.sh b/uninstall.sh index fee17b2..a176e5b 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -22,7 +22,7 @@ crontab -l 2> /dev/null | if [ "x$1" = "x--delete-files" ]; then rm -r /var/lib/0tdns/ rm -r /etc/netns/0tdns* - rm /usr/sbin/hourly.sh /usr/sbin/hourly.py + rm /usr/sbin/hourly.py rm -r /etc/0tdns rm /usr/lib/python3/dist-packages/ztdns_db_connectivity.py fi |