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 interval: 1 # every day
files: files:
- /root/brain.nn - /root/brain.nn
backup_cmd: 'tar czf /tmp/backup.tar.gz {files}' commands:
upload_cmd: 'scp /tmp/backup.tar.gz 10.0.0.1:/backups/backup-$(date).tar.gz' - 'tar czf /tmp/backup.tar.gz {files}'
- 'scp /tmp/backup.tar.gz 10.0.0.1:/backups/backup-$(date).tar.gz'
gps: gps:
enabled: false enabled: false
twitter: twitter:

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