From: Frank Brehm Date: Tue, 31 Oct 2023 14:04:15 +0000 (+0100) Subject: Changing snippets/tpl.075.tmp-tmpfs.sh to a systemd mount unit file X-Git-Tag: 3.2.1~40^2~8 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=cb17a9f370cac17d5c604e3fa852224a512fae93;p=pixelpark%2Fcreate-vmware-tpl.git Changing snippets/tpl.075.tmp-tmpfs.sh to a systemd mount unit file --- diff --git a/snippets/tpl.075.tmp-tmpfs.sh b/snippets/tpl.075.tmp-tmpfs.sh index f0d54e2..ba39704 100644 --- a/snippets/tpl.075.tmp-tmpfs.sh +++ b/snippets/tpl.075.tmp-tmpfs.sh @@ -4,19 +4,37 @@ #----------------------------------------------------------- setup_tmp_tmpfs() { - local fstab="/etc/fstab" - if [[ -f "${fstab}" ]] ; then + echo -e "\e[0Ksection_start:$( date +%s ):ks_setup_tmp_tmpfs[collapsed=true]\r\e[0KSetting up /tmp as a tmpfs ..." - 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}' ..." + local unit_file="/etc/systemd/system/tmp.mount" + echo + echo "Creating a systemd unit file '${unit_file}' providing a temp filesystem below /tmp" - echo 'tmpfs /tmp tmpfs nosuid,size=10% 0 0' >>"${fstab}" + cat > "${unit_file}" <<-EOF + # Unit file for creating a temp filesystem below /tmp - echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K" - fi + [Unit] + Description=Creating a temporary filesystem below /tmp + Before=local-fs.target + + [Install] + WantedBy=local-fs.target + + [Mount] + What=tmpfs + Where=/tmp + Type=tmpfs + Options=nosuid,size=10%% + + EOF + + echo + echo "Content of '${unit_file}':" + echo "---------- snip ----------" + cat "${unit_file}" + echo "---------- snip ----------" + + echo -e "\e[0Ksection_end:$( date +%s ):ks_setup_tmp_tmpfs\r\e[0K" } setup_tmp_tmpfs