Mercurial > sat_docs
diff docker/libervia/scripts/libervia_cont_launch @ 105:b69056368901
docker: images optimisation:
- reduced the number of layers by grouping many instructions
- moved stuff which don't change a lot at the beginning, and hg/apt at the end
- scripts are not now in scripts/ subdirectories
- prosody.cfg.lua is added using ADD instead of getting it online
- .hg/dirstate is copied in base (backend) and libervia, so mercurial revision is known
- removed lot of useless WORKDIR instruction, they are replaced by "cd" inside RUN instructions
- cleaning (apt-clean, rm) is done on the same instruction as the one than generate the data, to avoid useless data in layers
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 28 Feb 2016 02:01:20 +0100 |
parents | |
children | 5d8b9ca2afd4 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docker/libervia/scripts/libervia_cont_launch Sun Feb 28 02:01:20 2016 +0100 @@ -0,0 +1,33 @@ +#!/usr/bin/env python2 + +# this script check if libervia and admin accounts exist, and create them if necessary +# then it launch libervia +import os, sys, string, random +from sat.plugins import plugin_misc_account as account +from sat.tools import config +from sat_frontends.bridge import DBus + +def generate_pwd(): + chars = string.letters + string.digits + length = 12 + return "".join(random.choice(chars) for _ in range(length)) + +sat=DBus.DBusBridgeFrontend() +sat.getReady() +admin_email = sat.getConfig(account.CONFIG_SECTION, "admin_email") or account.default_conf["admin_email"] + +for profile in ["libervia", "admin"]: + try: + sat.getProfileName(profile) + except Exception as e: + print "{} profile doesn'\''t exists, creating it".format(profile) + print "registering {}@{}".format(profile, sat.getNewAccountDomain()) + pwd = generate_pwd() + if profile == "libervia": + config.fixConfigOption("libervia", "passphrase", pwd) + elif profile == "admin": + with open("/home/sat/ADMIN_PWD", "w") as f: + f.write("%s\\n" % pwd) + sat.registerSatAccount(admin_email, pwd, profile) + +os.execvp("libervia", ["libervia"] + sys.argv[1:])