Commit ab91a878 authored by James Coyle's avatar James Coyle

Merge branch 'james-dev' into 'master'

Bug fix

See merge request !17
parents 123c36a7 1dee8419
Pipeline #1264 failed with stages
in 47 minutes and 59 seconds
......@@ -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 [email protected]:JAC2703/storjstatus-client.git
- git push github master
tags:
- storjapi
......@@ -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.')
......
__version__ = '0.3.3'
__version__ = '0.3.5'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment