More general variable

This commit is contained in:
dadav 2019-10-05 11:32:54 +02:00
parent 2bbe5cc9c3
commit 7db7874d8e
2 changed files with 7 additions and 7 deletions
sdcard/rootfs/root/pwnagotchi
config.yml
scripts/pwnagotchi/plugins/default

@ -11,8 +11,9 @@ main:
interval: 1 # every day
files:
- /root/brain.nn
backup_cmd: 'tar czf /tmp/backup.tar.gz {files}'
upload_cmd: 'scp /tmp/backup.tar.gz 10.0.0.1:/backups/backup-$(date).tar.gz'
commands:
- 'tar czf /tmp/backup.tar.gz {files}'
- 'scp /tmp/backup.tar.gz 10.0.0.1:/backups/backup-$(date).tar.gz'
gps:
enabled: false
twitter:

@ -28,8 +28,8 @@ def on_loaded():
logging.error("AUTO-BACKUP: Interval is not set.")
return
if 'backup_cmd' not in OPTIONS or ('backup_cmd' in OPTIONS and OPTIONS['backup_cmd'] is None):
logging.error("AUTO-BACKUP: No backup_cmd given.")
if 'commands' not in OPTIONS or ('commands' in OPTIONS and OPTIONS['commands'] is None):
logging.error("AUTO-BACKUP: No commands given.")
return
if os.path.exists('/root/.auto-backup'):
@ -51,9 +51,8 @@ def on_internet_available(display, config, log):
files_to_backup = " ".join(OPTIONS['files'])
try:
subprocess.call(OPTIONS['backup_cmd'].format(files=files_to_backup).split(), stdout=open(os.devnull, 'wb'))
if 'upload_cmd' in OPTIONS and OPTIONS['upload_cmd'] is not None:
subprocess.call(OPTIONS['upload_cmd'].split(), stdout=open(os.devnull, 'wb'))
for cmd in OPTIONS['commands']:
subprocess.call(cmd.format(files=files_to_backup).split(), stdout=open(os.devnull, 'wb'))
logging.info("AUTO-BACKUP: Successfuly ran backup commands.")
LAST_BACKUP = datetime.now()
with open('/root/.auto-backup', 'w') as f: