Mercurial > sat_docs
comparison 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 |
comparison
equal
deleted
inserted
replaced
104:b59491821a8a | 105:b69056368901 |
---|---|
1 #!/usr/bin/env python2 | |
2 | |
3 # this script check if libervia and admin accounts exist, and create them if necessary | |
4 # then it launch libervia | |
5 import os, sys, string, random | |
6 from sat.plugins import plugin_misc_account as account | |
7 from sat.tools import config | |
8 from sat_frontends.bridge import DBus | |
9 | |
10 def generate_pwd(): | |
11 chars = string.letters + string.digits | |
12 length = 12 | |
13 return "".join(random.choice(chars) for _ in range(length)) | |
14 | |
15 sat=DBus.DBusBridgeFrontend() | |
16 sat.getReady() | |
17 admin_email = sat.getConfig(account.CONFIG_SECTION, "admin_email") or account.default_conf["admin_email"] | |
18 | |
19 for profile in ["libervia", "admin"]: | |
20 try: | |
21 sat.getProfileName(profile) | |
22 except Exception as e: | |
23 print "{} profile doesn'\''t exists, creating it".format(profile) | |
24 print "registering {}@{}".format(profile, sat.getNewAccountDomain()) | |
25 pwd = generate_pwd() | |
26 if profile == "libervia": | |
27 config.fixConfigOption("libervia", "passphrase", pwd) | |
28 elif profile == "admin": | |
29 with open("/home/sat/ADMIN_PWD", "w") as f: | |
30 f.write("%s\\n" % pwd) | |
31 sat.registerSatAccount(admin_email, pwd, profile) | |
32 | |
33 os.execvp("libervia", ["libervia"] + sys.argv[1:]) |