Expand PMF_FN_* macros.
[netbsd-mini2440.git] / etc / rc.d / perusertmp
blob274867669dde8380fb4dd46c467e6da18d925346
1 #!/bin/sh
3 # $NetBSD: perusertmp,v 1.6 2007/02/15 13:27:35 tron Exp $
6 # PROVIDE: perusertmp
7 # REQUIRE: mountall
8 # BEFORE: cleartmp
10 $_rc_subr_loaded . /etc/rc.subr
12 name="perusertmp"
13 rcvar="per_user_tmp"
14 start_cmd="perusertmp_start"
15 stop_cmd=":"
17 perusertmp_start()
19 echo "Preparing per-user /tmp."
21 # If /tmp is a mount point, we can't do anything.
22 if [ -d "/tmp" ]; then
23 local mount_point
25 mount_point=$(cd /tmp && /bin/df . | /usr/bin/tail -1 | /usr/bin/awk '{print $6}')
26 if [ "${mount_point}" = "/tmp" ]; then
27 echo "WARNING: /tmp is mounted."
28 exit 1
32 # Enable magic symlinks.
33 /sbin/sysctl -qw vfs.generic.magiclinks=1
35 # Fixup real temporary directory.
36 if [ ! -d ${per_user_tmp_dir} ]; then
37 /bin/mkdir -p ${per_user_tmp_dir}
39 /usr/sbin/chown root:wheel ${per_user_tmp_dir}
40 /bin/chmod 0555 ${per_user_tmp_dir}
42 # Create magic link for /tmp.
43 if [ "$(/usr/bin/readlink /tmp)" != ${per_user_tmp_dir}/@ruid ]; then
44 /bin/rm -rf /tmp
45 /bin/ln -s ${per_user_tmp_dir}/@ruid /tmp
49 load_rc_config $name
50 run_rc_command "$1"