[initramfscfg] New module: pre-configuration for update-initramfs.
Added an initramfscfg module to handle pre-configuration for the Debian update-initramfs, such as installing hooks (needed for luks/FDE support on Debian-based distros). Closes #254. (Cherry-picked from the pull request.)
This commit is contained in:
parent
ebfa1e2838
commit
1b8b5aab13
26
src/modules/initramfscfg/encrypt_hook
Executable file
26
src/modules/initramfscfg/encrypt_hook
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
PREREQ=""
|
||||
|
||||
prereqs()
|
||||
{
|
||||
echo "$PREREQ"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
# get pre-requisites
|
||||
prereqs)
|
||||
prereqs
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /usr/share/initramfs-tools/hook-functions
|
||||
if [ -f /crypto_keyfile.bin ]
|
||||
then
|
||||
cp /crypto_keyfile.bin ${DESTDIR}
|
||||
fi
|
||||
if [ -f /etc/crypttab ]
|
||||
then
|
||||
cp /etc/crypttab ${DESTDIR}/etc/
|
||||
fi
|
52
src/modules/initramfscfg/main.py
Normal file
52
src/modules/initramfscfg/main.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2014, Rohan Garg <rohan@kde.org>
|
||||
# Copyright 2015, Philip Müller <philm@manjaro.org>
|
||||
# Copyright 2016, David McKinney <mckinney@subgraph.com>
|
||||
#
|
||||
# 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
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def copy_initramfs_hooks(partitions, root_mount_point):
|
||||
""" Copies initramfs hooks so they are picked up by update-initramfs
|
||||
|
||||
:param partitions:
|
||||
:param root_mount_point:
|
||||
"""
|
||||
encrypt_hook = False
|
||||
|
||||
for partition in partitions:
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
encrypt_hook = True
|
||||
|
||||
if encrypt_hook:
|
||||
shutil.copy2("/usr/lib/calamares/modules/initramfscfg/encrypt_hook", "{!s}/usr/share/initramfs-tools/hooks/".format(root_mount_point))
|
||||
os.chmod("{!s}/usr/share/initramfs-tools/hooks/encrypt_hook".format(root_mount_point), 0o755)
|
||||
|
||||
def run():
|
||||
""" Calls routine with given parameters to configure initramfs
|
||||
|
||||
:return:
|
||||
"""
|
||||
partitions = libcalamares.globalstorage.value("partitions")
|
||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||
copy_initramfs_hooks(partitions, root_mount_point)
|
||||
|
||||
return None
|
5
src/modules/initramfscfg/module.desc
Normal file
5
src/modules/initramfscfg/module.desc
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
type: "job"
|
||||
name: "initramfscfg"
|
||||
interface: "python"
|
||||
script: "main.py"
|
Loading…
Reference in New Issue
Block a user