Compare commits
1 Commits
services-s
...
postcfg
| Author | SHA1 | Date | |
|---|---|---|---|
| 041dcd2983 |
80
src/modules/postcfg/main.py
Normal file
80
src/modules/postcfg/main.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
#
|
||||||
|
# Copyright 2014 - 2016, Philip Müller <philm@manjaro.org>
|
||||||
|
# Copyright 2016, Artoo <artoo@manjaro.org>
|
||||||
|
# Copyright 2018, Artoo <artoo@artixlinux.org>
|
||||||
|
#
|
||||||
|
# Calamares is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Calamares is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from os.path import join, exists
|
||||||
|
|
||||||
|
import libcalamares
|
||||||
|
from libcalamares.utils import target_env_call
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigController:
|
||||||
|
"""Configuration controller
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.root = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
|
|
||||||
|
def terminate(self, proc):
|
||||||
|
"""Send SIGKILL to the given proccess
|
||||||
|
"""
|
||||||
|
target_env_call(['killall', '-9', proc])
|
||||||
|
|
||||||
|
def sedFile(self, pattern, file):
|
||||||
|
"""Sed the given file with the given pattern
|
||||||
|
"""
|
||||||
|
target_env_call(["sed", "-e", pattern, "-i", file])
|
||||||
|
|
||||||
|
def configure(self):
|
||||||
|
"""Configure the services
|
||||||
|
"""
|
||||||
|
if exists(join(self.root, "/etc/conf.d/keymaps")):
|
||||||
|
exp = 's|^.*keymap=.*|keymap="{}"|'.format(
|
||||||
|
libcalamares.globalstorage.value("keyboardLayout")
|
||||||
|
)
|
||||||
|
self.sedFile(exp, "/etc/conf.d/keymaps")
|
||||||
|
|
||||||
|
if exists(join(self.root, "/etc/conf.d/xdm")):
|
||||||
|
for dm in libcalamares.globalstorage.value("displayManagers"):
|
||||||
|
exp = 's|^.*DISPLAYMANAGER=.*|DISPLAYMANAGER="{}"|'.format(dm)
|
||||||
|
self.sedFile(exp, "/etc/conf.d/xdm")
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Run the controller
|
||||||
|
|
||||||
|
Workaround for pacman-key bug
|
||||||
|
FS#45351 https://bugs.archlinux.org/task/45351
|
||||||
|
We have to kill gpg-agent because if it stays
|
||||||
|
around we can't reliably unmount
|
||||||
|
the target partition.
|
||||||
|
"""
|
||||||
|
self.configure()
|
||||||
|
self.terminate('gpg-agent')
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
""" Misc postinstall configurations """
|
||||||
|
|
||||||
|
config = ConfigController()
|
||||||
|
|
||||||
|
return config.run()
|
||||||
7
src/modules/postcfg/module.desc
Normal file
7
src/modules/postcfg/module.desc
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Syntax is YAML 1.2
|
||||||
|
---
|
||||||
|
type: "job"
|
||||||
|
name: "postcfg"
|
||||||
|
interface: "python"
|
||||||
|
script: "main.py" #assumed relative to the current directory
|
||||||
|
noconfig: true
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
#
|
|
||||||
# Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
|
|
||||||
# Copyright 2019, Artoo <artoo@artixlinux.org>
|
|
||||||
#
|
|
||||||
# Calamares is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Calamares is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import libcalamares
|
|
||||||
|
|
||||||
from libcalamares.utils import target_env_call, warning
|
|
||||||
from os.path import exists, join
|
|
||||||
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
_ = gettext.translation("calamares-python",
|
|
||||||
localedir=libcalamares.utils.gettext_path(),
|
|
||||||
languages=libcalamares.utils.gettext_languages(),
|
|
||||||
fallback=True).gettext
|
|
||||||
|
|
||||||
|
|
||||||
def pretty_name():
|
|
||||||
return _("Configure s6 services")
|
|
||||||
|
|
||||||
|
|
||||||
class S6Controller:
|
|
||||||
"""
|
|
||||||
This is the s6 service controller.
|
|
||||||
All of its state comes from global storage and the job
|
|
||||||
configuration at initialization time.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.root = libcalamares.globalstorage.value('rootMountPoint')
|
|
||||||
|
|
||||||
self.svDir = libcalamares.job.configuration['svDir']
|
|
||||||
self.dbDir = libcalamares.job.configuration['dbDir']
|
|
||||||
self.defaultBundle = libcalamares.job.configuration['defaultBundle']
|
|
||||||
|
|
||||||
self.services = dict()
|
|
||||||
self.services["add"] = libcalamares.job.configuration.get('services', [])
|
|
||||||
self.services["delete"] = libcalamares.job.configuration.get('disable', [])
|
|
||||||
|
|
||||||
|
|
||||||
def makeBundle(self):
|
|
||||||
"""
|
|
||||||
Call s6-rc-bundle with each service listed
|
|
||||||
in services as arg.
|
|
||||||
"""
|
|
||||||
|
|
||||||
deleteBundles = self.services.get("delete", [])
|
|
||||||
|
|
||||||
if deleteBundles:
|
|
||||||
ec = target_env_call(["s6-rc-bundle", "-c", self.dbDir, "delete", *deleteBundles])
|
|
||||||
if ec != 0:
|
|
||||||
warning("Cannot delete {}".format(*deleteBundles))
|
|
||||||
warning("s6-rc-bundle returned error code {!s}".format(ec))
|
|
||||||
|
|
||||||
for svc in self.services.get('add', []):
|
|
||||||
ec = target_env_call(["s6-rc-db", "-c", self.dbDir, "type", svc])
|
|
||||||
if ec != 0:
|
|
||||||
warning("Service {} does not exist.".format(svc))
|
|
||||||
warning("s6-rc-db returned error code {!s}".format(ec))
|
|
||||||
else:
|
|
||||||
ec = target_env_call(["s6-service", "add", self.defaultBundle, svc])
|
|
||||||
if ec != 0:
|
|
||||||
warning("Cannot add service {} to {} bundle".format(svc, self.defaultBundle))
|
|
||||||
warning("s6-service returned error code {!s}".format(ec))
|
|
||||||
|
|
||||||
ec = target_env_call(["s6-db-reload", "-r"])
|
|
||||||
if ec != 0:
|
|
||||||
warning("Cannot reload service db.")
|
|
||||||
warning("s6-db-reload returned error code {!s}".format(ec))
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
"""Run the controller
|
|
||||||
"""
|
|
||||||
|
|
||||||
r = self.makeBundle()
|
|
||||||
if r is not None:
|
|
||||||
return r
|
|
||||||
|
|
||||||
def run():
|
|
||||||
"""
|
|
||||||
Setup services
|
|
||||||
"""
|
|
||||||
|
|
||||||
return S6Controller().run()
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
type: "job"
|
|
||||||
name: "services-s6"
|
|
||||||
interface: "python"
|
|
||||||
script: "main.py"
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# s6 services module to create a services bundle via s6-rc-bundle in the chroot
|
|
||||||
#
|
|
||||||
# Services can be added to default bundle
|
|
||||||
# Handle disable with care and only use it if absolutely necessary.
|
|
||||||
#
|
|
||||||
# if a service is listed in the conf but is not present/detected on the target system,
|
|
||||||
# it will be ignored and skipped; a warning is logged.
|
|
||||||
#
|
|
||||||
---
|
|
||||||
|
|
||||||
# services path
|
|
||||||
svDir: /etc/s6/sv
|
|
||||||
|
|
||||||
# database path
|
|
||||||
dbDir: /etc/s6/rc/compiled
|
|
||||||
|
|
||||||
# default bundle name
|
|
||||||
defaultBundle: default
|
|
||||||
|
|
||||||
# services: a list of services to **add** to the default bundle
|
|
||||||
# disable: a list of bundles to **delete**
|
|
||||||
#
|
|
||||||
# Each entry:
|
|
||||||
# - the name
|
|
||||||
# # Example services and disable settings:
|
|
||||||
# services:
|
|
||||||
# - foo1
|
|
||||||
# - foo2
|
|
||||||
# disable:
|
|
||||||
# - foo3
|
|
||||||
# - foo4
|
|
||||||
services: []
|
|
||||||
disable: []
|
|
||||||
Reference in New Issue
Block a user