--- trunk/mlivecdbuild/profiles/alx-0_7_branch/prepare_custom 2017/08/31 12:17:26 3060 +++ trunk/mlivecdbuild/profiles/alx-0_7_branch/prepare_custom 2017/08/31 12:27:43 3061 @@ -44,14 +44,67 @@ --update-tarball \ --basesystem basesystem || die "bootstrapping target system failed!" - # set an empty root password for the install system too +# # HACK: add all mesa-gallium modules but intel modules +# local i +# for i in nouveau r300 r600 radeonsi swrast +# do +# CDCHROOTDIR=${LIVECDROOT}/install-temp custom_packages install "mesa-gallium-${i}" || die +# done +# +# # HACK: add mesa-gallium-i915 +# CDCHROOTDIR=${LIVECDROOT}/install-temp custom_packages install "mesa-gallium-i915" || die +# +# # HACK: add all mesa-dri modules +# local i +# for i in i915 i965 nouveau r200 radeon swrast +# do +# CDCHROOTDIR=${LIVECDROOT}/install-temp custom_packages install "mesa-dri-${i}" || die +# done +# # but disable i915_dri atm, which breaks +# if [[ -L ${LIVECDROOT}/install-temp/usr/lib/dri/i915_dri.so ]] +# then +# rm ${LIVECDROOT}/install-temp/usr/lib/dri/i915_dri.so +# fi + +## DEV SERVER ## +# NEW_MCORE_CONTROL_SERVER="alx-control-dev.dom-aka-nt.intern" +# CONFIG="${LIVECDROOT}/install-temp/etc/mcore/mcore.conf" +# updateconfig MCORE_CONTROL_SERVER +### + + # fix missing symlink + if [ ! -L ${LIVECDROOT}/install-temp/usr/bin/X ] + then + ln -snf Xorg ${LIVECDROOT}/install-temp/usr/bin/X + fi + + # generate a new machine-id on first-boot + :> ${LIVECDROOT}/install-temp/etc/machine-id + + # fix localtime symlink + ln -snf ../usr/share/zoneinfo/Europe/Berlin ${LIVECDROOT}/install-temp/etc/localtime + + # activate timeserver via dhcp (NTP - option 42) + CDCHROOTDIR=${LIVECDROOT}/install-temp custom_services add systemd-timesyncd.service + + # empty root password chroot ${LIVECDROOT}/install-temp passwd -d root # add user station with empty password - chroot ${LIVECDROOT}/install-temp adduser -G users -h /home/station -s /bin/bash -D station +# chroot ${LIVECDROOT}/install-temp adduser -G users -h /home/station -s /bin/bash -D station + + # empty user password + chroot ${LIVECDROOT}/install-temp passwd -d station # install xinitrc - echo 'exec startfluxbox' > ${LIVECDROOT}/install-temp/home/station/.xinitrc +# echo 'exec startfluxbox' > ${LIVECDROOT}/install-temp/home/station/.xinitrc + + if [ -x ${LIVECDROOT}/install-temp/usr/bin/mcorepasswd ] || + [ -L ${LIVECDROOT}/install-temp/usr/bin/mcorepasswd ] + then + # add mcored default user + ( echo "foobar"; sleep 0.1; echo "foobar" ) | chroot ${LIVECDROOT}/install-temp /usr/bin/mcorepasswd mcore + fi # fix hostname and hosts file echo "alx-i486" > ${LIVECDROOT}/install-temp/etc/hostname @@ -65,30 +118,30 @@ ff02::3 ip6-allhosts EOF - # create a default network interface config file - cat > ${LIVECDROOT}/install-temp/etc/conf.d/net.eth0 << EOF -ONBOOT="yes" -NETWORKING="dhcp" -EOF +# # create a default network interface config file +# cat > ${LIVECDROOT}/install-temp/etc/conf.d/net.eth0 << EOF +#ONBOOT="yes" +#NETWORKING="dhcp" +#EOF # fix mage.rc and config.rc - NEW_SQL_USER="alx_install" - NEW_SQL_PASS="@lx" - NEW_SQL_HOST="128.20.41.110" - NEW_SQL_DB="alx_web" - NEW_SMB_UPDATE_HOST="//${NEW_SQL_HOST}/magetmp" - NEW_SMB_UPDATE_USER="${NEW_SQL_USER}" - NEW_SMB_UPDATE_PASS="${NEW_SQL_PASS}" - NEW_MAGE_MIRRORS="http://${NEW_SQL_HOST}/magellan/alx-070" - NEW_MAGE_RSYNC="rsync://${NEW_SQL_HOST}/mage-alx-070" - NEW_RSYNC="${NEW_MAGE_RSYNC}" - NEW_SMAGE2RSYNC="rsync://${NEW_SQL_HOST}/smage-alx-070" - NEW_MIRRORS="${NEW_MAGE_MIRRORS}" - NEW_MAGE_UNINSTALL_TIMEOUT="0" - CONFIG="${LIVECDROOT}/install-temp/etc/mage.rc" - updateconfig RSYNC SMAGE2RSYNC MIRRORS MAGE_UNINSTALL_TIMEOUT - CONFIG="${LIVECDROOT}/install-temp/etc/alxconfig-ng/config.rc" - updateconfig SQL_USER SQL_PASS SQL_HOST SQL_DB SMB_UPDATE_HOST SMB_UPDATE_USER SMB_UPDATE_PASS MAGE_MIRRORS MAGE_RSYNC +# NEW_SQL_USER="alx_install" +# NEW_SQL_PASS="@lx" +# NEW_SQL_HOST="128.20.41.110" +# NEW_SQL_DB="alx_web" +# NEW_SMB_UPDATE_HOST="//${NEW_SQL_HOST}/magetmp" +# NEW_SMB_UPDATE_USER="${NEW_SQL_USER}" +# NEW_SMB_UPDATE_PASS="${NEW_SQL_PASS}" +# NEW_MAGE_MIRRORS="http://${NEW_SQL_HOST}/magellan/alx-070" +# NEW_MAGE_RSYNC="rsync://${NEW_SQL_HOST}/mage-alx-070" +# NEW_RSYNC="${NEW_MAGE_RSYNC}" +# NEW_SMAGE2RSYNC="rsync://${NEW_SQL_HOST}/smage-alx-070" +# NEW_MIRRORS="${NEW_MAGE_MIRRORS}" +# NEW_MAGE_UNINSTALL_TIMEOUT="0" +# CONFIG="${LIVECDROOT}/install-temp/etc/mage.rc" +# updateconfig RSYNC SMAGE2RSYNC MIRRORS MAGE_UNINSTALL_TIMEOUT +# CONFIG="${LIVECDROOT}/install-temp/etc/alxconfig-ng/config.rc" +# updateconfig SQL_USER SQL_PASS SQL_HOST SQL_DB SMB_UPDATE_HOST SMB_UPDATE_USER SMB_UPDATE_PASS MAGE_MIRRORS MAGE_RSYNC # create tarball [[ -f ${CDISOROOT}/system/alx-i486.tar.bz2 ]] && rm ${CDISOROOT}/system/alx-i486.tar.bz2 @@ -117,17 +170,24 @@ install -d ${LIVECDROOT}/network-temp/{LiveOS,mnt} || die + # fix fstab, use the livecd fstab without rootfs and swap + install -m 0644 $(get_profile fstab) ${LIVECDROOT}/install-temp/etc/fstab || die + # get the actual size of the chroot size=$(du -s ${LIVECDROOT}/install-temp | sed 's:^\(.*\)[[:space:]].*:\1:') # generate a ext3fs file for devicemapper - dd if=/dev/zero of=${LIVECDROOT}/network-temp/LiveOS/ext3fs.img bs=1024 count=$(( ${size} + 10 )) || die + dd if=/dev/zero of=${LIVECDROOT}/network-temp/LiveOS/ext3fs.img bs=1024 count=$(( ${size} + 20000 )) || die # create a filesystem mkfs.ext3 -L "_${CDID}_EXT3" -m 1 -b 1024 -F ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die # set mount_counts and check_intervals to 0 - # set dir_index top, to speed up thing with hashed b-trees + # set dir_index top, to speed up things with hashed b-trees # allow acls too tune2fs -c0 -i0 -Odir_index -ouser_xattr,acl ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die + # strip the journal +# tune2fs -O^has_journal ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die + # fsck after journal removal +# fsck ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die # losetup the device loopdev=$(losetup -f) @@ -159,27 +219,44 @@ # initrd install -d ${CDCHROOTDIR}/etc/dracut.conf.d || die echo 'add_dracutmodules+=" livenet busybox "' > ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die - echo 'omit_dracutmodules+=" systemd plymouth mcored "' >> ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die + #echo 'omit_dracutmodules+=" systemd plymouth mcored "' >> ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die + # use plymouth to get all kms modules, but boot with nosplash as default to fix some Xorg issues + #echo 'omit_dracutmodules+=" systemd mcored "' >> ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die + echo 'omit_dracutmodules+=" mcored "' >> ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die + echo 'hostonly="no"' >> ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die # install dracut-dev package to have all modules custom_packages install "dracut-dev curl curl-dev" || die ## mlivecdbuild function generate_initrd mv ${CDISOROOT}/isolinux/initrd.gz ${CDISOROOT}/netboot/ || die - custom_packages uninstall "dracut-dev curl curl-dev" || die + # fix initrd permissions + chmod 0644 ${CDISOROOT}/netboot/initrd.gz || die +# custom_packages uninstall "dracut-dev curl curl-dev" || die if [ -e ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf ] then rm ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf fi - # bootloader - install -d ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile netboot/pxelinux.0) ] && install -m0644 $(get_profile netboot/pxelinux.0) ${CDISOROOT}/netboot - [ -f $(get_profile netboot/pxelinux.cfg/default) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/default) ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile netboot/pxelinux.cfg/boot.cat) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/boot.cat) ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile boot.lss) ] && install -m0644 $(get_profile boot.lss) ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile boot.msg) ] && install -m0644 $(get_profile boot.msg) ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile debug.msg) ] && install -m0644 $(get_profile debug.msg) ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile help.msg) ] && install -m0644 $(get_profile help.msg) ${CDISOROOT}/netboot/pxelinux.cfg - [ -f $(get_profile index.msg) ] && install -m0644 $(get_profile index.msg) ${CDISOROOT}/netboot/pxelinux.cfg + # bootloader pxelinux + install -d ${CDISOROOT}/netboot/pxelinux/pxelinux.cfg + [ -f $(get_profile netboot/pxelinux.0) ] && install -m0644 $(get_profile netboot/pxelinux.0) ${CDISOROOT}/netboot/pxelinux/ + [ -f $(get_profile netboot/pxelinux.cfg/pxelinux-default) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/pxelinux-default) ${CDISOROOT}/netboot/pxelinux/pxelinux.cfg + [ -f $(get_profile netboot/pxelinux.cfg/boot.cat) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/boot.cat) ${CDISOROOT}/netboot/pxelinux/ + [ -f $(get_profile boot.lss) ] && install -m0644 $(get_profile boot.lss) ${CDISOROOT}/netboot/pxelinux/ + [ -f $(get_profile boot.msg) ] && install -m0644 $(get_profile boot.msg) ${CDISOROOT}/netboot/pxelinux/ + [ -f $(get_profile debug.msg) ] && install -m0644 $(get_profile debug.msg) ${CDISOROOT}/netboot/pxelinux/ + [ -f $(get_profile help.msg) ] && install -m0644 $(get_profile help.msg) ${CDISOROOT}/netboot/pxelinux/ + [ -f $(get_profile index.msg) ] && install -m0644 $(get_profile index.msg) ${CDISOROOT}/netboot/pxelinux/ + # bootloader lpxelinux + install -d ${CDISOROOT}/netboot/lpxelinux/pxelinux.cfg + [ -f $(get_profile netboot/lpxelinux.0) ] && install -m0644 $(get_profile netboot/lpxelinux.0) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile netboot/ldlinux.c32) ] && install -m0644 $(get_profile netboot/ldlinux.c32) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile netboot/pxelinux.cfg/lpxelinux-default) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/lpxelinux-default) ${CDISOROOT}/netboot/lpxelinux/pxelinux.cfg + [ -f $(get_profile netboot/pxelinux.cfg/boot.cat) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/boot.cat) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile boot.lss) ] && install -m0644 $(get_profile boot.lss) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile boot.msg) ] && install -m0644 $(get_profile boot.msg) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile debug.msg) ] && install -m0644 $(get_profile debug.msg) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile help.msg) ] && install -m0644 $(get_profile help.msg) ${CDISOROOT}/netboot/lpxelinux/ + [ -f $(get_profile index.msg) ] && install -m0644 $(get_profile index.msg) ${CDISOROOT}/netboot/lpxelinux/ # final cleanup if [[ -d ${LIVECDROOT}/network-temp ]] @@ -188,6 +265,86 @@ fi } +## +# create the server tarball +## +create_server_tarball() +{ + install -d ${LIVECDROOT}/server-temp + install -d ${CDISOROOT}/server + + mage-bootstrap \ + --root ${LIVECDROOT}/server-temp \ + --profile ${MAGE_PROFILE} \ + --magerc ${MAGERC} \ + --toolchain ${TOOLCHAIN} \ + --update-tarball \ + --basesystem serversystem || die "bootstrapping target system failed!" + + # generate a new machine-id on first-boot + :> ${LIVECDROOT}/server-temp/etc/machine-id + + # enable getty1 + install -d ${LIVECDROOT}/server-temp/etc/systemd/system/getty.target.wants + ln -snf /usr/lib/systemd/system/getty@.service ${LIVECDROOT}/server-temp/etc/systemd/system/getty.target.wants/getty@tty1.service + + # be more verbose + sed -i 's:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1"rd.info":' ${LIVECDROOT}/server-temp/etc/conf.d/grub + + # fix localtime symlink + ln -snf ../usr/share/zoneinfo/Europe/Berlin ${LIVECDROOT}/server-temp/etc/localtime + + # activate timeserver via dhcp (NTP - option 42) + CDCHROOTDIR=${LIVECDROOT}/server-temp custom_services add systemd-timesyncd.service + + # empty root password + chroot ${LIVECDROOT}/server-temp passwd -d root + + # empty user password + chroot ${LIVECDROOT}/server-temp passwd -d station + + if [ -x ${LIVECDROOT}/server-temp/usr/bin/mcorepasswd ] || + [ -L ${LIVECDROOT}/server-temp/usr/bin/mcorepasswd ] + then + # add mcored default user + ( echo "foobar"; sleep 0.1; echo "foobar" ) | chroot ${LIVECDROOT}/server-temp /usr/bin/mcorepasswd mcore + fi + + # remove phpmyadmin configuration directory + if [ -d ${LIVECDROOT}/server-temp/usr/share/phpmyadmin/config ] + then + rm -r ${LIVECDROOT}/server-temp/usr/share/phpmyadmin/config + fi + + # fix hostname and hosts file + echo "alx-svr-i486" > ${LIVECDROOT}/server-temp/etc/hostname + echo "127.0.0.1 localhost alx-svr-i486.magellan-linux.de alx-svr-i486" > ${LIVECDROOT}/server-temp/etc/hosts + # fix certificate issues with mcored (common name of cert issuer) and >php-5.4 + echo "127.0.0.1 mcored" >> ${LIVECDROOT}/server-temp/etc/hosts + cat >> ${LIVECDROOT}/server-temp/etc/hosts << EOF +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +ff02::3 ip6-allhosts +EOF + + # create tarball + [[ -f ${CDISOROOT}/server/alx-svr-i486.tar.bz2 ]] && rm ${CDISOROOT}/server/alx-svr-i486.tar.bz2 + ( cd ${LIVECDROOT}/server-temp; tar cvjpf ${CDISOROOT}/server/alx-svr-i486.tar.bz2 ./ | tee log) + + # create images.conf + echo "CDIMAGENAME=alx-svr-i486.tar.bz2" > ${CDISOROOT}/server/images.conf + echo "TOTALLINES=$(wc -l ${LIVECDROOT}/server-temp/log | cut -d' ' -f1)" >> ${CDISOROOT}/server/images.conf + + # clean up + if [[ -d ${LIVECDROOT}/server-temp ]] + then + rm -rf ${LIVECDROOT}/server-temp + fi +} + # set an empty root password chroot ${CDCHROOTDIR} passwd -d root @@ -226,8 +383,18 @@ # stop here if the user don't want to create the install tarball [[ -n ${SKIP_CREATE_INSTALL_TARBALL} ]] || create_install_tarball +# stop here if the user don't want to create the server tarball +[[ -n ${SKIP_CREATE_SERVER_TARBALL} ]] || create_server_tarball + # install usb-install script [ ! -d ${CDISOROOT}/usb-install ] && mkdir ${CDISOROOT}/usb-install [ -f $(get_profile usb-install/usb-install.cmd) ] && cp $(get_profile usb-install)/usb-install.cmd ${CDISOROOT}/usb-install [ -f $(get_profile usb-install/syslinux.exe) ] && cp $(get_profile usb-install)/syslinux.exe ${CDISOROOT}/usb-install [ -f $(get_profile usb-install/syslinux.cfg) ] && cp $(get_profile usb-install)/syslinux.cfg ${CDISOROOT}/usb-install + +# add installer-server script +cat > ${CDCHROOTDIR}/usr/bin/installer-server << EOF +#!/bin/bash +/usr/bin/installer --imageroot /run/initramfs/live/server +EOF +chmod 0755 ${CDCHROOTDIR}/usr/bin/installer-server