From 8bc16aa05fd788e3ecf5f4a5569e19cb489b00af Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 2 Nov 2023 12:35:46 +0100 Subject: [PATCH] Refactoring snippets/tpl.075.tmp-tmpfs.sh --- snippets/tpl.075.tmp-tmpfs.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) 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 -- 2.39.5