Skip to content

Commit

Permalink
start/enable svcs on install
Browse files Browse the repository at this point in the history
  • Loading branch information
peakwinter committed Oct 17, 2016
1 parent e5da811 commit f937fe5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
20 changes: 18 additions & 2 deletions arkos/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,11 @@ def uninstall(self, force=False, nthread=NotificationThread()):
for item in self.dependencies:
if item["type"] == "system" and not item["package"] in exclude:
if item.get("daemon"):
services.stop(item["daemon"])
services.disable(item["daemon"])
try:
services.get(item["daemon"]).stop()
services.get(item["daemon"]).disable()
except:
pass
pacman.remove([item["package"]],
purge=config.get("apps", "purge"))

Expand Down Expand Up @@ -615,5 +618,18 @@ def _install(id, load=True, cry=True):
setattr(app, x, data[x])
app.upgradable = ""
app.installed = True
for x in app.services:
if x["type"] == "system" and x.get("binary") \
and not x.get("ignore_on_install"):
s = services.get(x["binary"])
if s:
s.enable()
if s.state != "running":
try:
s.start()
except services.ActionError as e:
logger.warning(
"Apps", "{0} could not be automatically started."
.format(s.name))
if load:
app.load(cry=cry)
4 changes: 2 additions & 2 deletions arkos/system/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class Service:
Services can be of type ``systemd`` or ``supervisor``.
"""

def __init__(self, name="", stype="", state=False, enabled=False, cfg={}):
def __init__(self, name="", stype="", state="", enabled=False, cfg={}):
"""
Initialize the service.
:param str name: Service name
:param str stype: either ``systemd`` or ``supervisor``
:param bool state: Running state of the service
:param str state: Running state of the service
:param bool enabled: Service starts on boot?
:param dict cfg: Config (for supervisor services)
"""
Expand Down
2 changes: 1 addition & 1 deletion arkos/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def str_fperms(mode):

def path_to_b64(path):
"""Convert a filesystem path to a safe base64-encoded string."""
if type(path) == str:
if isinstance(path, str):
path = bytes(path, 'utf-8')
path = path.replace(b"//", b"/")
return base64.b64encode(path, altchars=b"+-").replace(b"=", b"*").decode()
Expand Down
2 changes: 1 addition & 1 deletion arkos/websites.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ def scan():
if not app or not app.loadable or not app.installed:
logger.debug(
"Webs", "Website found but could not be loaded: {0}"
.format(meta.get("id")))
.format(meta.get("website", "id")))
continue
site = app._website(id=meta.get("website", "id"))
site.app = app
Expand Down

0 comments on commit f937fe5

Please sign in to comment.