set -Ceu
SCRIPT_NAME=$0
cd "$(dirname "${SCRIPT_NAME}")"
+. lib/include.sh
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/NAME_LUKSVG.sh
-. lib/PATH_MNT_CHROOT.sh
-. lib/PATH_PARTITION_LUKSVG.sh
-. lib/await_path.sh
-. lib/check_openable_luksvg.sh
-. lib/check_tools.sh
-. lib/check_partition_mountable.sh
-. lib/chroot_sh.sh
-. lib/close_luksvg.sh
-. lib/mount_privately.sh
-. lib/msg.sh
-. lib/open_luksvg.sh
-. lib/path_vg.sh
-. lib/rbind_mnt.sh
-. lib/unmount_unrbind.sh
-. lib/usage.sh
+include NAME_LUKSVG
+include PATH_MNT_CHROOT
+include PATH_PARTITION_LUKSVG
+include await_path
+include check_openable_luksvg
+include check_tools
+include check_partition_mountable
+include chroot_sh
+include close_luksvg
+include mount_privately
+include msg
+include open_luksvg
+include path_vg
+include rbind_mnt
+include unmount_unrbind
+include usage
# inputs to confirm
usage $# "root-name" "command"
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/DIRNAME_REPO.sh
-. lib/DIRNAME_SCRIPTS.sh
-. lib/FNAME_INITRD.sh
-. lib/FNAME_PROFILE.sh
-. lib/FNAME_VMLINUZ.sh
-. lib/IDX_PARTITION_EFI.sh
-. lib/NAME_DATA.sh
-. lib/NAME_LUKSVG.sh
-. lib/NAME_SWAP.sh
-. lib/PATH_BOOT_DEVICE.sh
-. lib/PATH_DATA.sh
-. lib/PATH_EFI.sh
-. lib/PATH_FIRST_BOOT_PENDING.sh
-. lib/PATH_HOME_ROOT.sh
-. lib/PATH_MNT_CHROOT.sh
-. lib/PATH_PARTITION_LUKSVG.sh
-. lib/await_path.sh
-. lib/check_boot_device_layout.sh
-. lib/check_partition_mountable.sh
-. lib/close_luksvg.sh
-. lib/check_openable_luksvg.sh
-. lib/check_tools.sh
-. lib/chroot_sh.sh
-. lib/create_lv.sh
-. lib/disable_apt_recommends.sh
-. lib/efi_copy_kernel_vmlinuz.sh
-. lib/error.sh
-. lib/msg.sh
-. lib/open_luksvg.sh
-. lib/mount_privately.sh
-. lib/path_vg.sh
-. lib/render_template.sh
-. lib/rbind_mnt.sh
-. lib/retry_until_success.sh
-. lib/unmount_unrbind.sh
-. lib/usage.sh
+include DIRNAME_REPO
+include DIRNAME_SCRIPTS
+include FNAME_INITRD
+include FNAME_PROFILE
+include FNAME_VMLINUZ
+include IDX_PARTITION_EFI
+include NAME_DATA
+include NAME_LUKSVG
+include NAME_SWAP
+include PATH_BOOT_DEVICE
+include PATH_DATA
+include PATH_EFI
+include PATH_FIRST_BOOT_PENDING
+include PATH_HOME_ROOT
+include PATH_MNT_CHROOT
+include PATH_PARTITION_LUKSVG
+include await_path
+include check_boot_device_layout
+include check_partition_mountable
+include close_luksvg
+include check_openable_luksvg
+include check_tools
+include chroot_sh
+include create_lv
+include disable_apt_recommends
+include efi_copy_kernel_vmlinuz
+include error
+include msg
+include open_luksvg
+include mount_privately
+include path_vg
+include render_template
+include rbind_mnt
+include retry_until_success
+include unmount_unrbind
+include usage
# constants unlikely to change
FNAME_NM_CONN=wifi.nmconnection
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/DIRNAME_REPO.sh
-. lib/DIRNAME_SCRIPTS.sh
-. lib/PATH_MY_SSH.sh
-. lib/PATH_REPO.sh
-. lib/check_tools.sh
-. lib/msg.sh
-. lib/usage.sh
+include DIRNAME_REPO
+include DIRNAME_SCRIPTS
+include PATH_MY_SSH
+include PATH_REPO
+include check_tools
+include msg
+include usage
# constants we might want to change at some point
FNAME_REPO_TAR=repo.tar
-. lib/PATH_REPO.sh
+include PATH_REPO
DIRNAME_REPO=$(basename "${PATH_REPO}")
-. lib/PATH_DEV.sh
+include PATH_DEV
PATH_BOOT_DEVICE="${PATH_DEV}/nvme0n1"
-. lib/NAME_DATA.sh
+include NAME_DATA
PATH_DATA="/${NAME_DATA}"
-. lib/DIRNAME_DEV.sh
+include DIRNAME_DEV
PATH_DEV="/${DIRNAME_DEV}"
-. lib/PATH_HOME_ROOT.sh
+include PATH_HOME_ROOT
PATH_FIRST_BOOT_PENDING="${PATH_HOME_ROOT}/.first-boot-pending"
-. lib/PATH_MNT.sh
+include PATH_MNT
PATH_MNT_CHROOT="${PATH_MNT}/chroot"
-. lib/DIRNAME_SSH.sh
+include DIRNAME_SSH
PATH_MY_SSH="${HOME}/${DIRNAME_SSH}"
-. lib/IDX_PARTITION_EFI.sh
-. lib/PATH_BOOT_DEVICE.sh
+include IDX_PARTITION_EFI
+include PATH_BOOT_DEVICE
PATH_PARTITION_EFI="${PATH_BOOT_DEVICE}p${IDX_PARTITION_EFI}"
-. lib/PATH_BOOT_DEVICE.sh
+include PATH_BOOT_DEVICE
PATH_PARTITION_LUKSVG="${PATH_BOOT_DEVICE}p3"
-. lib/DIRNAME_DEV.sh
+include DIRNAME_DEV
TO_RBIND="${DIRNAME_DEV} proc sys"
-. lib/FNAME_PROFILE.sh
-. lib/msg.sh
+include FNAME_PROFILE
+include msg
augment_profile() {
local ALIAS_LS='alias ls="ls --color=auto"'
-. lib/msg.sh
+include msg
await_path() {
local TO_AWAIT=$1
-. lib/PATH_BOOT_DEVICE.sh
-. lib/PATH_DEV.sh
-. lib/PATH_EFI.sh
-. lib/PATH_PARTITION_EFI.sh
-. lib/error.sh
-. lib/try_quiet.sh
+include PATH_BOOT_DEVICE
+include PATH_DEV
+include PATH_EFI
+include PATH_PARTITION_EFI
+include error
+include try_quiet
check_boot_device_layout() {
local COUNT_NVME
-. lib/NAME_LUKSVG.sh
-. lib/error.sh
-. lib/try_quiet.sh
+include NAME_LUKSVG
+include error
+include path_luks_mapper
+include try_quiet
check_new_luksvg() {
local PATH_LUKS_MAPPER
- PATH_LUKS_MAPPER="${PATH_DEV}/mapper/${NAME_LUKSVG}"
+ PATH_LUKS_MAPPER=$(path_luks_mapper "${NAME_LUKSVG}")
try_quiet vgs "${NAME_LUKSVG}"\
&& error "volume group '${NAME_LUKSVG}' already exists"
[ -e "${PATH_LUKS_MAPPER}" ]\
-. lib/PATH_PARTITION_LUKSVG.sh
-. lib/check_new_luksvg.sh
-. lib/error.sh
-. lib/try_quiet.sh
+include PATH_PARTITION_LUKSVG
+include check_new_luksvg
+include error
+include try_quiet
check_openable_luksvg() {
check_new_luksvg
-. lib/error.sh
-. lib/try_quiet.sh
+include error
+include try_quiet
check_partition_mountable() {
local PARTITION=$1
-. lib/error.sh
-. lib/try_quiet.sh
+include error
+include try_quiet
check_tools() {
for CMD in "$@"; do
-. lib/PATH_MNT_CHROOT.sh
+include PATH_MNT_CHROOT
chroot_sh() {
LANG=C.UTF-8 chroot "${PATH_MNT_CHROOT}" /bin/sh -c "$@"
-. lib/NAME_LUKSVG.sh
-. lib/msg.sh
+include NAME_LUKSVG
+include msg
close_luksvg() {
msg 'Deactivating volume group and closing LUKS container …'
-. lib/msg.sh
+include msg
create_lv() {
local VG=$1
-. lib/msg.sh
+include msg
die() {
msg '%s' "$*" >&2
-. lib/msg.sh
+include msg
disable_apt_recommends() {
local PREFIX=${1:-}
-. lib/FNAME_INITRD.sh
-. lib/FNAME_VMLINUZ.sh
-. lib/msg.sh
+include FNAME_INITRD
+include FNAME_VMLINUZ
+include msg
efi_copy_kernel_vmlinuz() {
local PATH_EFI_NAME_BOOT=$1
-. lib/die.sh
+include die
error() {
die "error: $*"
--- /dev/null
+INCLUDED=""
+
+include() {
+ case " ${INCLUDED} " in
+ *" $1 "*) return 0 ;;
+ esac
+ INCLUDED="${INCLUDED} $1"
+ . "lib/$1.sh"
+}
-. lib/msg.sh
+include msg
mount_privately() {
local TO_MOUNT=$1
-. lib/msg_nonl.sh
+include msg_nonl
msg() {
msg_nonl "$@"
-. lib/NAME_LUKSVG.sh
-. lib/PATH_PARTITION_LUKSVG.sh
-. lib/msg.sh
+include NAME_LUKSVG
+include PATH_PARTITION_LUKSVG
+include msg
open_luksvg() {
msg 'Opening LUKS container as "%s" …' "${NAME_LUKSVG}"
-. lib/PATH_DEV.sh
+include PATH_DEV
path_vg() {
printf '%s/%s' "${PATH_DEV}" "$1"
-. lib/PATH_MNT_CHROOT.sh
-. lib/TO_RBIND.sh
-. lib/msg.sh
+include PATH_MNT_CHROOT
+include TO_RBIND
+include msg
rbind_mnt() {
for NAME in ${TO_RBIND}; do
-. lib/PATH_REPO.sh
+include PATH_REPO
render_template() {
local PATH_TEMPLATE="${PATH_REPO}/templates/$1"
-. lib/msg.sh
+include msg
retry_until_success() {
until "$@"; do
-. lib/DIRNAME_SCRIPTS.sh
-. lib/PATH_REPO.sh
-. lib/USERNAME.sh
-. lib/augment_profile.sh
-. lib/msg.sh
-. lib/retry_until_success.sh
-. lib/try_quiet.sh
+include DIRNAME_SCRIPTS
+include PATH_REPO
+include USERNAME
+include augment_profile
+include msg
+include retry_until_success
+include try_quiet
start_root() {
local PATH_TO_INSTALL="${PATH_REPO}/to_install/$1"
-. lib/PATH_MNT_CHROOT.sh
-. lib/TO_RBIND.sh
-. lib/msg.sh
+include PATH_MNT_CHROOT
+include TO_RBIND
+include msg
unmount_unrbind() {
msg 'Unmounting chroot environment …'
-. lib/die.sh
+include die
usage() {
local COUNT_INPUTS=$1
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/DIRNAME_REPO.sh
-. lib/PATH_REPO.sh
-. lib/USERNAME.sh
-. lib/error.sh
-. lib/msg.sh
-. lib/render_template.sh
+include DIRNAME_REPO
+include PATH_REPO
+include USERNAME
+include error
+include msg
+include render_template
# constants we might want to change at some point
PATH_GIT_BASE=/srv/git
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/NAME_DATA.sh
-. lib/NAME_LUKSVG.sh
-. lib/NAME_SWAP.sh
-. lib/PATH_MNT.sh
-. lib/PATH_DATA.sh
-. lib/PATH_PARTITION_LUKSVG.sh
-. lib/PATH_REPO.sh
-. lib/check_boot_device_layout.sh
-. lib/check_partition_mountable.sh
-. lib/check_new_luksvg.sh
-. lib/check_tools.sh
-. lib/close_luksvg.sh
-. lib/create_lv.sh
-. lib/die.sh
-. lib/error.sh
-. lib/msg.sh
-. lib/msg_nonl.sh
-. lib/open_luksvg.sh
-. lib/mount_privately.sh
-. lib/path_vg.sh
-. lib/try_quiet.sh
-. lib/usage.sh
+include NAME_DATA
+include NAME_LUKSVG
+include NAME_SWAP
+include PATH_MNT
+include PATH_DATA
+include PATH_PARTITION_LUKSVG
+include PATH_REPO
+include check_boot_device_layout
+include check_partition_mountable
+include check_new_luksvg
+include check_tools
+include close_luksvg
+include create_lv
+include die
+include error
+include msg
+include msg_nonl
+include open_luksvg
+include mount_privately
+include path_luks_mapper
+include path_vg
+include try_quiet
+include usage
# inputs to confirm
usage $#
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/DIRNAME_SSH.sh
-. lib/PATH_MY_SSH.sh
-. lib/USERNAME.sh
-. lib/disable_apt_recommends.sh
-. lib/msg.sh
-. lib/retry_until_success.sh
-. lib/start_root.sh
+include DIRNAME_SSH
+include PATH_MY_SSH
+include USERNAME
+include disable_apt_recommends
+include msg
+include retry_until_success
+include start_root
# constants unlikely to change
PATH_SSHD_DROPIN=/etc/ssh/sshd_config.d/60-ssh-hardening.conf
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/DIRNAME_SCRIPTS.sh
-. lib/PATH_FIRST_BOOT_PENDING.sh
-. lib/PATH_REPO.sh
-. lib/msg.sh
-. lib/start_root.sh
-. lib/render_template.sh
+include DIRNAME_SCRIPTS
+include PATH_FIRST_BOOT_PENDING
+include PATH_REPO
+include msg
+include start_root
+include render_template
# constants unlikely to change
PATH_DEFAULT_LOCALE=/etc/default/locale
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/PATH_REPO.sh
-. lib/augment_profile.sh
-. lib/msg.sh
+include PATH_REPO
+include augment_profile
+include msg
# constants we might want to change at some point
DIRNAME_HOME_USER=home_user
#!/bin/sh
. "$(dirname "$0")/_lib.sh"
-. lib/PATH_PARTITION_EFI.sh
-. lib/check_partition_mountable.sh
-. lib/efi_copy_kernel_vmlinuz.sh
-. lib/msg.sh
-. lib/usage.sh
+include PATH_PARTITION_EFI
+include check_partition_mountable
+include efi_copy_kernel_vmlinuz
+include msg
+include usage
usage $#