From: Frank Brehm Date: Thu, 2 Nov 2023 11:35:46 +0000 (+0100) Subject: Refactoring snippets/tpl.075.tmp-tmpfs.sh X-Git-Tag: 3.2.1~40^2~1 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=8bc16aa05fd788e3ecf5f4a5569e19cb489b00af;p=pixelpark%2Fcreate-vmware-tpl.git Refactoring snippets/tpl.075.tmp-tmpfs.sh --- diff --git a/snippets/tpl.075.tmp-tmpfs.sh b/snippets/tpl.075.tmp-tmpfs.sh index f0d54e2..e0a44f5 100644 --- a/snippets/tpl.075.tmp-tmpfs.sh +++ b/snippets/tpl.075.tmp-tmpfs.sh @@ -4,19 +4,29 @@ #----------------------------------------------------------- setup_tmp_tmpfs() { - local fstab="/etc/fstab" - if [[ -f "${fstab}" ]] ; then + echo -e "\e[0Ksection_start:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0KSetting up /tmp as a tmpfs ..." + echo + echo "${HASH_LINE}" + echo + log "Setting up /tmp as a tmpfs by a systemd mount unit ..." + echo + mkdir --parents --verbose /etc/systemd/system/tmp.mount.d + cat > /etc/systemd/system/tmp.mount.d/mount_options.conf <<-EOF + [Mount] + Options=mode=1777,strictatime,nosuid,nodev,size=10%%,nr_inodes=1m + EOF - echo -e "\e[0Ksection_start:$( date +%s ):ks_setup_tmp_tmpfs[collapsed=true]\r\e[0KSetting up /tmp as a tmpfs ..." - echo - echo "${HASH_LINE}" - echo - log "Setting up /tmp as a tmpfs in '${fstab}' ..." + echo + echo "Generated /etc/systemd/system/tmp.mount.d/mount_options.conf:" + echo "---------- snip -----------" + cat /etc/systemd/system/tmp.mount.d/mount_options.conf + echo "---------- snip -----------" - echo 'tmpfs /tmp tmpfs nosuid,size=10% 0 0' >>"${fstab}" + echo + echo "Enabling unit tmp.mount ..." + systemctl enable tmp.mount - echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K" - fi + echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K" } setup_tmp_tmpfs