better error handling and german keyboard layout as default

This commit is contained in:
nospoonuser 2018-05-31 13:01:20 +02:00
parent 4f8c0bd73d
commit 65b5cf2b07
7 changed files with 84 additions and 26 deletions

View File

@ -1,16 +1,19 @@
#!/bin/bash
source $(dirname $0)/defaults.conf
source ${WORKDIR}/mklive.conf
source $(dirname $0)/functions.sh
echo "Build live"
set -e
einfo "Bootstraping live system"
BUILD_TIME=$(date +%Y-%m-%dT%H:%M)
CHROOT=${WORKDIR}/chroot
startstage bootstrap
#bootstrap basic system
[ -d $CHROOT ] || debootstrap --components=main,restricted,universe,multiverse --variant=$DIST_VARIANT --arch=$ARCH $DIST_RELEASE $CHROOT $DIST_MIRROR
[ -d $CHROOT ] && einfo "Skipping 'debootstrap' as chrootdir is already present" || debootstrap --components=main,restricted,universe,multiverse --variant=$DIST_VARIANT --arch=$ARCH $DIST_RELEASE $CHROOT $DIST_MIRROR
#prepair chroot
mount -t proc proc $CHROOT/proc/
@ -18,22 +21,24 @@ mount -t sysfs sys $CHROOT/sys/
mount -o bind /dev $CHROOT/dev/
#install locales
if [ ! -e $STAGEDIR/_locales ]; then
if ! checkstage bootstrap_locales; then
einfo " installing locales"
chroot $CHROOT apt -y install locales
echo "de_DE.UTF-8 UTF-8" >> $CHROOT/etc/locale.gen
echo "en_US.UTF-8 UTF-8" >> $CHROOT/etc/locale.gen
chroot $CHROOT locale-gen
echo "done" > $STAGEDIR/_locales
endstage bootstrap_locales
fi
#install systemd
chroot $CHROOT apt -y install systemd
checkstage bootstrap_systemd || chroot $CHROOT apt -y install systemd && endstage bootstrap_systemd
#install live-boot
chroot $CHROOT apt-get -y install live-boot
checkstage bootstrap_liveboot || chroot $CHROOT apt-get -y install live-boot && endstage bootstrap_liveboot
DEFAULT_PACKAGES=console-setup
DEFAULT_PACKAGES="console-setup language-pack-de"
#install additional packages
if [ -n "${PACKAGES}" ]; then
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
@ -44,13 +49,13 @@ echo "LANG=de_DE.UTF-8" >> $CHROOT/etc/default/locale
if [ "${LIVE_AUTOLOGIN}" == "true" ]; then
einfo "Autologin is enabled"
requiredir "$CHROOT/etc/systemd/system/getty@tty1.service.d/"
cat > "$CHROOT/etc/systemd/system/getty@tty1.service.d/override.conf" << EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin root --noclear %I \$TERM
EOF
fi
#set the rootpw
@ -65,10 +70,11 @@ do
[ -f ${CHROOT}/etc/update-motd.d/$f ] && rm ${CHROOT}/etc/update-motd.d/$f
done
#install kernel
#(re)install kernel
chroot $CHROOT apt -y -o "APT::Install-Recommends=false" install ${KERNEL_PACKAGE}
#clean chroot
chroot $CHROOT apt autoremove
chroot $CHROOT apt-get clean
umount $CHROOT/proc/
umount $CHROOT/sys/
@ -77,6 +83,9 @@ umount $CHROOT/dev/
if [ -x $CHROOT/usr/sbin/sshd ];then
sed -i -r "s/^[#]?PermitRootLogin .+$/PermitRootLogin ${LIVE_SSH_ROOTLOGIN}/" $CHROOT/etc/ssh/sshd_config
cat > $CHROOT/etc/systemd/system/regenerate_ssh_host_keys.service << EOF
[Unit]
Description=Regenerate SSH host keys
@ -104,6 +113,17 @@ echo "${LIVE_NAME} Build@${BUILD_TIME}" > $CHROOT/etc/issue.net
echo "" > $CHROOT/etc/legal
#set a default keyboard layout
cat > ${CHROOT}/etc/default/keyboard << EOF
XKBMODEL="pc105"
XKBLAYOUT="de"
XKBVARIANT="nodeadkeys"
XKBOPTIONS=""
BACKSPACE="guess"
EOF
cat > ${CHROOT}/etc/update-motd.d/01-info << EOF
#!/bin/bash
@ -130,4 +150,6 @@ EOF
chmod +x ${CHROOT}/etc/update-motd.d/01-info
einfo "Bootstrap done"
endstage bootstrap

View File

@ -2,3 +2,4 @@ MEMTEST_BIN="/boot/memtest86+.bin"
UBUNTU_INSTALL_NETBOOT="http://de.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/netboot.tar.gz"
DEBIAN_INSTALL_NETBOOT="http://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/netboot.tar.gz"
ARCH_BASEDIR="arch/arch"
LIVE_SSH_ROOTLOGIN="yes"

View File

@ -1,22 +1,43 @@
function requiredir {
RED='\033[0;31m'
GREEN='\033[0;32m'
ORGANGE='\033[0;33m'
BLUE='\033[0;34m'
LGRAY='\033[0;37m'
NC='\033[0m'
requiredir() {
[ -n "$1" ] || exit 1
[ -e $1 ] || mkdir $1
}
function err {
echo $1
eexit() {
eerr "$1"
exit 1
}
function checkstage {
checkstage() {
[ -e ${WORKDIR}/stage/_$1 ] || return 1
[ "$(cat $WORKDIR/stage/_$1)" != "done" ] && return 2
return 0
}
function startstage {
startstage() {
echo -n "started" > ${WORKDIR}/stage/_$1
}
function endstage {
endstage() {
echo -n "done" > ${WORKDIR}/stage/_$1
}
eok() {
echo -e "${GREEN}[++] $1${NC}"
}
einfo() {
echo -e "${BLUE}[ii] ${1}${NC}"
}
eerr(){
echo -e "${RED}[--] ${1}${NC}"
}

View File

@ -3,7 +3,9 @@ source $(dirname $0)/defaults.conf
source ${WORKDIR}/mklive.conf
source $(dirname $0)/functions.sh
echo "Preparing Installer"
set -e
einfo "Preparing Installer"
startstage installer
@ -24,9 +26,12 @@ for dist in $installerdists
do
URLVAR="${dist^^}_INSTALL_NETBOOT"
[ -z "${!URLVAR}" ] && continue;
[ -e ${WORKDIR}/INSTALLER/${dist}_netboot.tar.gz ] || wget ${!URLVAR} -O ${WORKDIR}/INSTALLER/${dist}_netboot.tar.gz
[ -e ${WORKDIR}/INSTALLER/${dist}_netboot.tar.gz ] || ( einfo "Missing ${dist} netboot installer. Downloading ..." && wget ${!URLVAR} -O ${WORKDIR}/INSTALLER/${dist}_netboot.tar.gz )
[ $? -eq 0 ] || ( eerr "Download failed." && break )
tar -C ${WORKDIR}/INSTALLER -xzf ${WORKDIR}/INSTALLER/${dist}_netboot.tar.gz ./$dist-installer/amd64/linux ./${dist}-installer/amd64/initrd.gz
tar -C ${WORKDIR}/INSTALLER --transform "s/txt/${dist}/" --strip 4 -xzf ${WORKDIR}/INSTALLER/${dist}_netboot.tar.gz ./${dist}-installer/amd64/boot-screens/txt.cfg
done
eok "Installer done."
endstage installer

View File

@ -4,12 +4,14 @@ source ${WORKDIR}/mklive.conf
source $(dirname $0)/functions.sh
source $(dirname $0)/menufunction.sh
echo "Starting ISO creation"
set -e
einfo "Creating ISO"
ISOLINUX_MODULES="ldlinux.c32 libmenu.c32 menu.c32"
ISOLINUX_BIN="/usr/lib/ISOLINUX/isolinux.bin"
checkstage live || err "Previous stage (live) was not finished"
checkstage live || eexit "Previous stage (live) was not finished"
startstage iso
@ -36,7 +38,7 @@ if [ "$ISO_INCLUDE_UBUNTU_INSTALLER" == "true" ]; then
fi
if [ "$PXE_INCLUDE_DEBIAN_INSTALLER" == "true" ]; then
menuinstaller debian >> $PXEDIR/pxelinux/pxelinux.cfg/default
menuinstaller debian >> $ISODIR/isolinux/isolinux.cfg
[ -L $PXEDIR/debian-installer ] || ln -s ../INSTALLER/debian-installer $PXEDIR/debian-installer
fi
@ -69,4 +71,4 @@ done
mkisofs -f -boot-info-table -boot-load-size 4 -no-emul-boot -o ${ISO_FILENAME}.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -l -R -J $ISODIR
endstage iso
eok "ISO done"

View File

@ -2,7 +2,7 @@
source ${WORKDIR}/mklive.conf
source $(dirname $0)/functions.sh
echo "Build live"
einfo "Packageing live system"
startstage live
@ -19,4 +19,4 @@ cp -L $CHROOT/vmlinuz ${WORKDIR}/LIVE/
mksquashfs $CHROOT ${WORKDIR}/LIVE/filesystem.squashfs
endstage live
eok "Done"

View File

@ -4,12 +4,17 @@ source ${WORKDIR}/mklive.conf
source $(dirname $0)/functions.sh
source $(dirname $0)/menufunction.sh
echo "Starting PXE creation"
if [ "$PXE" != "true" ]; then
einfo "Skipping PXE - not configured"
exit 0
fi
einfo "Creating PXE enviroment"
PXELINUX_MODULES="ldlinux.c32 libmenu.c32 menu.c32"
PXELINUX_BIN="/usr/lib/PXELINUX/pxelinux.0"
checkstage live || err "Previous stage (live) was not finished"
checkstage live || eexit "Previous stage (live) was not finished"
startstage pxe
@ -68,8 +73,10 @@ do
cp ${SYSLINUX_MODULESDIR}/$m $PXEDIR/pxelinux/
done
#pack files
[ "$PXE_NO_TAR" == "true" ] && einfo "Skipping 'tar' step - disabled by config." || tar -hczf pxe.tar.gz -C $PXEDIR/ .
#create tarball
endstage pxe
eok "PXE build Done"