2018-05-21 12:41:52 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
source $(dirname $0)/defaults.conf
|
2018-05-21 12:41:52 +00:00
|
|
|
source ${WORKDIR}/mklive.conf
|
|
|
|
source $(dirname $0)/functions.sh
|
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
einfo "Bootstraping live system"
|
2018-05-21 12:41:52 +00:00
|
|
|
|
2018-05-27 08:42:07 +00:00
|
|
|
BUILD_TIME=$(date +%Y-%m-%dT%H:%M)
|
2018-05-21 12:41:52 +00:00
|
|
|
CHROOT=${WORKDIR}/chroot
|
|
|
|
|
|
|
|
startstage bootstrap
|
|
|
|
#bootstrap basic system
|
2018-05-31 11:01:20 +00:00
|
|
|
[ -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
|
2018-05-21 12:41:52 +00:00
|
|
|
|
|
|
|
#prepair chroot
|
|
|
|
mount -t proc proc $CHROOT/proc/
|
|
|
|
mount -t sysfs sys $CHROOT/sys/
|
|
|
|
mount -o bind /dev $CHROOT/dev/
|
|
|
|
|
|
|
|
#install locales
|
2018-05-31 11:01:20 +00:00
|
|
|
if ! checkstage bootstrap_locales; then
|
|
|
|
einfo " installing locales"
|
2018-05-21 12:41:52 +00:00
|
|
|
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
|
2018-05-31 11:01:20 +00:00
|
|
|
endstage bootstrap_locales
|
2018-05-21 12:41:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#install systemd
|
2018-05-31 11:01:20 +00:00
|
|
|
checkstage bootstrap_systemd || chroot $CHROOT apt -y install systemd && endstage bootstrap_systemd
|
2018-05-21 12:41:52 +00:00
|
|
|
|
|
|
|
#install live-boot
|
2018-05-31 11:01:20 +00:00
|
|
|
checkstage bootstrap_liveboot || chroot $CHROOT apt-get -y install live-boot && endstage bootstrap_liveboot
|
|
|
|
|
2018-05-21 12:41:52 +00:00
|
|
|
|
2018-05-27 08:42:07 +00:00
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
DEFAULT_PACKAGES="console-setup language-pack-de"
|
2018-05-21 12:41:52 +00:00
|
|
|
#install additional packages
|
|
|
|
if [ -n "${PACKAGES}" ]; then
|
2018-05-27 08:42:07 +00:00
|
|
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
|
|
|
LC_ALL=C LANGUAGE=C LANG=C chroot $CHROOT apt-get -y install ${DEFAULT_PACKAGES} ${PACKAGES}
|
2018-05-21 12:41:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-05-27 08:42:07 +00:00
|
|
|
echo "LANG=de_DE.UTF-8" >> $CHROOT/etc/default/locale
|
|
|
|
|
2018-05-22 19:39:33 +00:00
|
|
|
|
|
|
|
if [ "${LIVE_AUTOLOGIN}" == "true" ]; then
|
2018-05-31 11:01:20 +00:00
|
|
|
einfo "Autologin is enabled"
|
2018-05-22 19:39:33 +00:00
|
|
|
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
|
|
|
|
|
2018-05-21 12:41:52 +00:00
|
|
|
#set the rootpw
|
|
|
|
chpasswd -R $(readlink -f $CHROOT) <<< "root:${LIVE_ROOTPW}"
|
|
|
|
|
|
|
|
#change to a full busybox - for tftp support
|
|
|
|
sed -i -r 's/=.+(\/bin\/busybox)/=\1/' chroot/usr/share/initramfs-tools/hooks/zz-busybox-initramfs
|
|
|
|
|
2018-05-22 19:39:33 +00:00
|
|
|
#remove ubuntu ads
|
|
|
|
for f in 00-header 10-help-text 50-motd-news
|
|
|
|
do
|
|
|
|
[ -f ${CHROOT}/etc/update-motd.d/$f ] && rm ${CHROOT}/etc/update-motd.d/$f
|
|
|
|
done
|
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
#(re)install kernel
|
2018-05-21 12:41:52 +00:00
|
|
|
chroot $CHROOT apt -y -o "APT::Install-Recommends=false" install ${KERNEL_PACKAGE}
|
|
|
|
|
|
|
|
#clean chroot
|
2018-05-31 11:01:20 +00:00
|
|
|
chroot $CHROOT apt autoremove
|
2018-05-21 12:41:52 +00:00
|
|
|
chroot $CHROOT apt-get clean
|
|
|
|
umount $CHROOT/proc/
|
|
|
|
umount $CHROOT/sys/
|
|
|
|
umount $CHROOT/dev/
|
|
|
|
|
2018-05-27 08:42:07 +00:00
|
|
|
|
|
|
|
if [ -x $CHROOT/usr/sbin/sshd ];then
|
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
|
|
|
|
sed -i -r "s/^[#]?PermitRootLogin .+$/PermitRootLogin ${LIVE_SSH_ROOTLOGIN}/" $CHROOT/etc/ssh/sshd_config
|
|
|
|
|
2018-05-27 08:42:07 +00:00
|
|
|
cat > $CHROOT/etc/systemd/system/regenerate_ssh_host_keys.service << EOF
|
|
|
|
[Unit]
|
|
|
|
Description=Regenerate SSH host keys
|
|
|
|
Before=ssh.service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
|
|
|
|
ExecStart=/usr/bin/ssh-keygen -A -v
|
|
|
|
ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
2018-05-27 13:05:48 +00:00
|
|
|
SSH_STATUS="on"
|
2018-05-27 08:42:07 +00:00
|
|
|
[ -e ${CHROOT}/etc/systemd/system/multi-user.target.wants/regenerate_ssh_host_keys.service ] || ln -s ../regenerate_ssh_host_keys.service ${CHROOT}/etc/systemd/system/multi-user.target.wants/regenerate_ssh_host_keys.service
|
2018-05-27 13:05:48 +00:00
|
|
|
else
|
|
|
|
SSH_STATUS="off"
|
2018-05-27 08:42:07 +00:00
|
|
|
fi
|
|
|
|
|
2018-05-21 12:41:52 +00:00
|
|
|
#final changes
|
|
|
|
echo "${LIVE_HOSTNAME}" > $CHROOT/etc/hostname
|
2018-05-27 08:42:07 +00:00
|
|
|
echo "${LIVE_NAME} Build@${BUILD_TIME} \\l" > $CHROOT/etc/issue
|
|
|
|
echo "${LIVE_NAME} Build@${BUILD_TIME}" > $CHROOT/etc/issue.net
|
2018-05-27 13:05:48 +00:00
|
|
|
echo "" > $CHROOT/etc/legal
|
|
|
|
|
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
#set a default keyboard layout
|
|
|
|
cat > ${CHROOT}/etc/default/keyboard << EOF
|
|
|
|
XKBMODEL="pc105"
|
|
|
|
XKBLAYOUT="de"
|
|
|
|
XKBVARIANT="nodeadkeys"
|
|
|
|
XKBOPTIONS=""
|
|
|
|
|
|
|
|
BACKSPACE="guess"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2018-05-27 13:05:48 +00:00
|
|
|
cat > ${CHROOT}/etc/update-motd.d/01-info << EOF
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo -e "\n===== GENERAL =====\n"
|
|
|
|
echo " Systemname: ${LIVE_NAME}"
|
|
|
|
echo " Buildtime: ${BUILD_TIME}"
|
|
|
|
echo " Root password: ${LIVE_ROOTPW}"
|
|
|
|
echo " SSH: ${SSH_STATUS}"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo -e "\n====== NETWORK ======\n"
|
|
|
|
echo " Interfaces:"
|
|
|
|
ip -c -br addr | grep -v lo | sed -r 's/^(.*)$/ \1/g'
|
|
|
|
echo -e "\n Default route: "
|
|
|
|
ip -c -br route show default | awk '{print " "\$3"\t("\$5")"}'
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
#Diskingo
|
|
|
|
echo -e "\n====== DISKS ======\n"
|
|
|
|
lsblk -e 7,11 -o NAME,SIZE,TYPE,FSTYPE,SERIAL,MODEL | sed -r -e 's/^(.*)$/ \1/g' -e 's/([A-Za-z0-9]) /\1 /g'
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
EOF
|
2018-05-27 08:42:07 +00:00
|
|
|
|
2018-05-27 13:05:48 +00:00
|
|
|
chmod +x ${CHROOT}/etc/update-motd.d/01-info
|
2018-05-21 12:41:52 +00:00
|
|
|
|
2018-05-31 11:01:20 +00:00
|
|
|
einfo "Bootstrap done"
|
|
|
|
|
2018-05-21 12:41:52 +00:00
|
|
|
endstage bootstrap
|