started working on #343
This commit is contained in:
parent
cd5d783c52
commit
ff6bf5c198
@ -17,6 +17,12 @@ main:
|
|||||||
report: false # don't report pwned networks by default!
|
report: false # don't report pwned networks by default!
|
||||||
exclude: # do not report the following networks (accepts both ESSIDs and BSSIDs)
|
exclude: # do not report the following networks (accepts both ESSIDs and BSSIDs)
|
||||||
- YourHomeNetworkHere
|
- YourHomeNetworkHere
|
||||||
|
|
||||||
|
auto-update:
|
||||||
|
enabled: false
|
||||||
|
interval: 12 # every 12 hours
|
||||||
|
install: true # if false, it will only warn that updates are available, if true it will install them
|
||||||
|
|
||||||
auto-backup:
|
auto-backup:
|
||||||
enabled: false
|
enabled: false
|
||||||
interval: 1 # every day
|
interval: 1 # every day
|
||||||
|
67
pwnagotchi/plugins/default/auto-update.py
Normal file
67
pwnagotchi/plugins/default/auto-update.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
__author__ = 'evilsocket@gmail.com'
|
||||||
|
__version__ = '1.1.0'
|
||||||
|
__name__ = 'auto-update'
|
||||||
|
__license__ = 'GPL3'
|
||||||
|
__description__ = 'This plugin checks when updates are available and applies them when internet is available.'
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import subprocess
|
||||||
|
from pwnagotchi.utils import StatusFile
|
||||||
|
|
||||||
|
OPTIONS = dict()
|
||||||
|
READY = False
|
||||||
|
STATUS = StatusFile('/root/.auto-update')
|
||||||
|
|
||||||
|
|
||||||
|
def on_loaded():
|
||||||
|
global READY
|
||||||
|
if 'interval' not in OPTIONS or ('interval' in OPTIONS and OPTIONS['interval'] is None):
|
||||||
|
logging.error("[update] main.plugins.auto-update.interval is not set")
|
||||||
|
return
|
||||||
|
READY = True
|
||||||
|
logging.info("[update] plugin loaded.")
|
||||||
|
|
||||||
|
|
||||||
|
def run(cmd):
|
||||||
|
return subprocess.Popen(cmd, shell=True, stdin=None, stdout=open("/dev/null", "w"), stderr=None,
|
||||||
|
executable="/bin/bash")
|
||||||
|
|
||||||
|
|
||||||
|
def on_internet_available(agent):
|
||||||
|
global STATUS
|
||||||
|
|
||||||
|
if READY:
|
||||||
|
if STATUS.newer_then_hours(OPTIONS['interval']):
|
||||||
|
logging.debug("[update] last check happened less than %d hours ago" % OPTIONS['interval'])
|
||||||
|
return
|
||||||
|
|
||||||
|
logging.debug("[update] start")
|
||||||
|
|
||||||
|
display = agent.view()
|
||||||
|
prev_status = display.get('status')
|
||||||
|
|
||||||
|
try:
|
||||||
|
display.set('status', 'Checking for updates ...')
|
||||||
|
display.update()
|
||||||
|
|
||||||
|
"""
|
||||||
|
logging.info("auto-update: updating pwnagotchi ...")
|
||||||
|
run('pip3 install --upgrade --upgrade-strategy only-if-needed pwnagotchi').wait()
|
||||||
|
|
||||||
|
if OPTIONS['system']:
|
||||||
|
logging.info("auto-update: updating packages index ...")
|
||||||
|
run('apt update -y').wait()
|
||||||
|
|
||||||
|
logging.info("auto-update: updating packages ...")
|
||||||
|
run('apt upgrade -y').wait()
|
||||||
|
"""
|
||||||
|
|
||||||
|
logging.info("[update] done")
|
||||||
|
|
||||||
|
STATUS.update()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("[update] %s" % e)
|
||||||
|
|
||||||
|
display.set('status', prev_status if prev_status is not None else '')
|
||||||
|
display.update()
|
@ -263,6 +263,9 @@ class StatusFile(object):
|
|||||||
def newer_then_minutes(self, minutes):
|
def newer_then_minutes(self, minutes):
|
||||||
return self._updated is not None and ((datetime.now() - self._updated).seconds / 60) < minutes
|
return self._updated is not None and ((datetime.now() - self._updated).seconds / 60) < minutes
|
||||||
|
|
||||||
|
def newer_then_hours(self, hours):
|
||||||
|
return self._updated is not None and ((datetime.now() - self._updated).seconds / (60*60)) < hours
|
||||||
|
|
||||||
def newer_then_days(self, days):
|
def newer_then_days(self, days):
|
||||||
return self._updated is not None and (datetime.now() - self._updated).days < days
|
return self._updated is not None and (datetime.now() - self._updated).days < days
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user