diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ccdcffd1083de289690885964bc7534be5bbe5ca..dea17eef098ac53182c94457e5445e0eabb04f86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ stages: - deploy - cleanup - db + - github set-pypirc: @@ -80,3 +81,13 @@ update_db: - python3 update-db.py tags: - storjapi + +update_github: + stage: github + only: + - master + script: + - git remote add github git@github.com:JAC2703/storjstatus-client.git + - git push github master + tags: + - storjapi diff --git a/storjstatus/storjstatus_register.py b/storjstatus/storjstatus_register.py index cb66564d7dea480ef9c02c8afcfdedaf7ab378ba..4f6ba0d65300fda2c09e8a17aacb5413738a0400 100644 --- a/storjstatus/storjstatus_register.py +++ b/storjstatus/storjstatus_register.py @@ -4,7 +4,7 @@ import argparse import getpass import json import os -from os.path import expanduser +import os.path import requests import socket import ctypes @@ -256,12 +256,21 @@ def cron_job(): cron_job_linux() def cron_job_linux(): + tmp_cron = '/tmp/storjstatus.cron' + result = storjstatus_common.subprocess_result(['which', 'storjstatus-send']) if 'storjstatus-send' in result[0].decode('utf-8'): send_command = result[0].decode('utf-8').replace('\n', '') + ' >> /var/log/storjstatus.log 2>&1' - cron = CronTab(tabfile='/etc/crontab', user=False) + if os.path.isfile('/etc/crontab'): + cron_path = '/etc/crontab' + elif os.path.isfile('/etc/anacrontab'): + cron_path = '/etc/anacrontab' + else: + cron_path = tmp_cron + + cron = CronTab(tabfile=cron_path, user=False) # Check for existing cronjob and remove cron.remove_all(comment='storjstatus') @@ -279,12 +288,11 @@ def cron_job_linux(): minute = cron_minute(minute) job.minute.also.on(minute) - try: - cron.write() - storjstatus_common.subprocess_result(['service', 'cron', 'reload']) - print("Cron set for: " + job.render()) - except PermissionError: - print_error('Unable to create cron job. Exiting.') + if cron_path = tmp_cron: + print('*************************WARNING************************************') + print('Could not find your system cronfile, please add a cron manually for:') + print(' ' + job.render()) + print('*************************WARNING************************************') else: print_error('There was an error finding the storjstatus-send command. Check your storjstatus installation.') diff --git a/storjstatus/version.py b/storjstatus/version.py index 80eb7f98f4cb71200c816fc60695b1028924b01b..bfeb9e74abec8f5d7e6608ce1315d7d679763dfe 100644 --- a/storjstatus/version.py +++ b/storjstatus/version.py @@ -1 +1 @@ -__version__ = '0.3.3' +__version__ = '0.3.4'