From 8af7868947b81d379966f5a3a620e94475aad1f3 Mon Sep 17 00:00:00 2001 From: fbt Date: Mon, 2 Mar 2015 18:00:23 +0300 Subject: [PATCH] even better: configurable tpdirs and tmpfiles creation --- rc.in | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rc.in b/rc.in index 09f3f25..9fcaf5c 100755 --- a/rc.in +++ b/rc.in @@ -14,6 +14,9 @@ cfg_mounts+=( 'shm:tmpfs:/dev/shm:defaults,mode=0777' ) # Some temporary directories cfg_tmpdirs+=( '/run/lock' '/run/lock/lvm' '/run/lvm' '/run/user' ) +# And temporary files +cfg_tmpfiles+=( '/run/utmp' ) + # Functions rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; } @@ -27,8 +30,15 @@ rc.motd() { return 0 } -rc.tmpdirs() { - mkdir -p -m0755 "${cfg_tmpdirs[@]}" +rc.tmpfiles() { + printf '%s\n' "${cfg_tmpdirs[@]}" | while IFS=':' read dir perm; do + mkdir -v -m "${perm:-755}" "$dir" + done + + printf '%s\n' "${cfg_tmpfiles[@]}" | while IFS=':' read file perm; do + > "$file" + chmod -v "${perm:-644}" "$file" + done } rc.mount_misc() { @@ -114,7 +124,6 @@ rc.remount_root() { rc.boot() { rc.mount_misc - rc.tmpdirs rc.tmpfiles rc.hostname rc.timezone @@ -160,10 +169,6 @@ rc.timezone() { } } -rc.tmpfiles() { - >/run/utmp -} - rc.main() { source "@ETC@/rc.conf"