summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/create-scripts/bootstrap (renamed from share/create-scripts/debootstrap)27
-rwxr-xr-xshare/create-scripts/parts/chroot_clean-apt-archives23
-rwxr-xr-xshare/create-scripts/parts/chroot_config-root-password33
-rwxr-xr-xshare/create-scripts/parts/chroot_config-system-hostname23
4 files changed, 93 insertions, 13 deletions
diff --git a/share/create-scripts/debootstrap b/share/create-scripts/bootstrap
index bef75b1..a332d4d 100755
--- a/share/create-scripts/debootstrap
+++ b/share/create-scripts/bootstrap
@@ -24,6 +24,7 @@ SOFTWARE="compute-tools"
PROGRAM="container"
SCRIPT="$(basename ${0})"
+DIRECTORY="$(dirname ${0})"
HOOKS="/etc/${SOFTWARE}/hooks"
MACHINES="/var/lib/machines"
@@ -109,15 +110,15 @@ case "${SCRIPT}" in
BOOTSTRAP_OPTIONS=""
;;
- debootstrap)
- BOOTSTRAP="/usr/sbin/debootstrap"
- BOOTSTRAP_OPTIONS=""
- ;;
-
mmdebstrap)
BOOTSTRAP="/usr/bin/mmdebstrap"
BOOTSTRAP_OPTIONS="--mode=root"
;;
+
+ *)
+ BOOTSTRAP="/usr/sbin/debootstrap"
+ BOOTSTRAP_OPTIONS=""
+ ;;
esac
if [ ! -x "${BOOTSTRAP}" ]
@@ -135,7 +136,6 @@ fi
ARCHITECTURE="${ARCHITECTURE:-$(dpkg --print-architecture)}"
DISTRIBUTION="${DISTRIBUTION:-bullseye}"
MIRROR="${MIRROR:-https://deb.debian.org/debian}"
-PASSWORD="${PASSWORD:-$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)}"
INCLUDE="dbus"
@@ -158,15 +158,16 @@ done
mkdir -p "${MACHINES}"
${BOOTSTRAP} ${BOOTSTRAP_OPTIONS} --arch=${ARCHITECTURE} --include=${INCLUDE} ${DISTRIBUTION} ${MACHINES}/${NAME} ${MIRROR}
-# Cleaning apt cache
-chroot "${MACHINES}/${NAME}" apt clean
+SYSTEM_NAME="${NAME}"
+SYSTEM_PATH="${MACHINES}/${NAME}"
+SYSTEM_ROOT_PASSWORD="${PASSWORD}"
-# Setting hostname
-echo "${NAME}" > "${MACHINES}/${NAME}/etc/hostname"
+export SYSTEM_NAME SYSTEM_PATH SYSTEM_ROOT_PASSWORD
-# Setting root password
-echo root:${PASSWORD} | chroot "${MACHINES}/${NAME}" chpasswd
-echo "${NAME}: root password set to '${PASSWORD}'."
+# Customization
+"${DIRECTORY}"/parts/chroot_clean-apt-archives
+"${DIRECTORY}"/parts/chroot_config-root-password
+"${DIRECTORY}"/parts/chroot_config-system-hostname
# Post hooks
for FILE in "${HOOKS}/post-${SCRIPT}".* "${HOOKS}/${NAME}.post-${SCRIPT}"
diff --git a/share/create-scripts/parts/chroot_clean-apt-archives b/share/create-scripts/parts/chroot_clean-apt-archives
new file mode 100755
index 0000000..5c86cf0
--- /dev/null
+++ b/share/create-scripts/parts/chroot_clean-apt-archives
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
+
+set -e
+
+echo "${SYSTEM_NAME}: cleaning apt archives"
+chroot "${SYSTEM_PATH}" apt-get clean
diff --git a/share/create-scripts/parts/chroot_config-root-password b/share/create-scripts/parts/chroot_config-root-password
new file mode 100755
index 0000000..4868ccd
--- /dev/null
+++ b/share/create-scripts/parts/chroot_config-root-password
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
+
+set -e
+
+if [ -e "${SYSTEM_ROOT_PASSWORD}" ]
+then
+ SYSTEM_ROOT_PASSWORD="$(head -n1 ${SYSTEM_ROOT_PASSWORD})"
+fi
+
+if [ -z "${SYSTEM_ROOT_PASSWORD}" ]
+then
+ SYSTEM_ROOT_PASSWORD="$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)"
+fi
+
+echo "${SYSTEM_NAME}: setting root password to '${SYSTEM_ROOT_PASSWORD}'"
+echo root:${SYSTEM_ROOT_PASSWORD} | chroot "${SYSTEM_PATH}" chpasswd
diff --git a/share/create-scripts/parts/chroot_config-system-hostname b/share/create-scripts/parts/chroot_config-system-hostname
new file mode 100755
index 0000000..7580f45
--- /dev/null
+++ b/share/create-scripts/parts/chroot_config-system-hostname
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
+
+set -e
+
+echo "${SYSTEM_NAME}: setting hostname"
+echo "${SYSTEM_NAME}" > "${SYSTEM_PATH}/etc/hostname"