diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2022-01-05 23:15:00 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2022-01-05 23:15:00 +0100 |
commit | a5e7e25ae1cf12050737d4844ae8c3ec43566b84 (patch) | |
tree | 3ccf43c29264349bbde9a043b278434f1eb90f3e | |
parent | e4eeef4ebae8b5d980adbc4d94036fccfceefeb2 (diff) | |
download | itzks-systems-a5e7e25ae1cf12050737d4844ae8c3ec43566b84.tar.gz itzks-systems-a5e7e25ae1cf12050737d4844ae8c3ec43566b84.tar.bz2 itzks-systems-a5e7e25ae1cf12050737d4844ae8c3ec43566b84.zip |
sbin/itzks-update-disklserver-squashfs-images: Create ltsp.conf from ltsp.conf.in template file and use disklserver's root PW for root@<diskless-workstation>.
-rw-r--r-- | etc/ltsp/ltsp.conf.in | 4 | ||||
-rwxr-xr-x | sbin/itzks-update-disklserver-squashfs-images | 19 |
2 files changed, 20 insertions, 3 deletions
diff --git a/etc/ltsp/ltsp.conf.in b/etc/ltsp/ltsp.conf.in index 0e00294..a9a21a4 100644 --- a/etc/ltsp/ltsp.conf.in +++ b/etc/ltsp/ltsp.conf.in @@ -35,7 +35,7 @@ MASK_SYSTEM_SERVICES="apache2 etckeeper icinga2 nmbd smbd systemd-journald isc-d # Allow local root logins by setting a password hash for the root user. # The hash contains $, making it hard to escape in POST_INIT_x="sed ...". # So put sed in a section and call it at POST_INIT like this: -#POST_INIT_SET_ROOT_HASH="section_set_root_hash" +POST_INIT_SET_ROOT_HASH="section_set_root_hash" #[set_root_hash] -#sed 's|^root:[^:]*:|root:@rootpw@:|' -i /etc/shadow +sed 's|^root:[^:]*:|root:@rootpw@:|' -i /etc/shadow diff --git a/sbin/itzks-update-disklserver-squashfs-images b/sbin/itzks-update-disklserver-squashfs-images index ed0d94f..1e8d8ce 100755 --- a/sbin/itzks-update-disklserver-squashfs-images +++ b/sbin/itzks-update-disklserver-squashfs-images @@ -29,12 +29,29 @@ mkdir -p ${TMPDIR}/ chown root:root ${TMPDIR} chmod 1777 ${TMPDIR} -ltsp_chroots=$(ls "${LTSP_OPT}" | while read chroot_dir; do test ! -h "${LTSP_OPT}/${chroot_dir}" -a -x "${LTSP_OPT}/${chroot_dir}/bin/bash" && echo -n "${chroot_dir} "; done) +if [ -e "/etc/ltsp/ltsp.conf.in" ] && cat "/etc/ltsp/ltsp.conf.in" | grep -v "#" | grep -q "@rootpw@"; then + + # Drop previous ltsp.conf (yes, we want to do that!) + rm /etc/ltsp/ltsp.conf + touch /etc/ltsp/ltsp.conf + chown root:root /etc/ltsp/ltsp.conf + chmod 0600 /etc/ltsp/ltsp.conf + + echo "# THIS FILE IS RECREATED DAILY FROM /etc/ltsp/ltsp.conf.in - DON'T EDIT THIS FILE" >> /etc/ltsp/ltsp.conf + echo >> /etc/ltsp/ltsp.conf + + # configure LTSP before creating ltsp.img and iPXE config + host_rootpw=$(cat /etc/shadow | grep -E "^root:" | cut -d":" -f2) + [ "$host_rootpw" ] && export host_rootpw && perl -p -e "s/\@rootpw\@/\$ENV{host_rootpw}/g" "/etc/ltsp/ltsp.conf.in" >> "/etc/ltsp/ltsp.conf" + unset host_rootpw +fi # let's update ltsp.img (LTSP initrd) and LTSP's iPXE boot menu configuration, just in case... ltsp initrd ltsp ipxe +ltsp_chroots=$(ls "${LTSP_OPT}" | while read chroot_dir; do test ! -h "${LTSP_OPT}/${chroot_dir}" -a -x "${LTSP_OPT}/${chroot_dir}/bin/bash" && echo -n "${chroot_dir} "; done) + for chroot in ${ltsp_chroots}; do if [ -e "${LTSP_OPT}/${chroot}/chroot-upgrade-in-process" ]; then |