summaryrefslogtreecommitdiffstats
path: root/src.etc/init.d/mounttmpfs
blob: 902ad1d34084d31ffb3b30be750520e70c95e323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

start()
{
	printf 'Mounting temporary file systems... '

	if ! mount | grep -F ' /run ' 2>&1 | :; then
		mount -t tmpfs -o nodev,noexec,nosuid,mode=0755 tmpfs /run
	fi

	[ -d /run/lock ] || mkdir -m 1777 /run/lock
	[ -d /run/shm ] || mkdir -m 1777 /run/shm

	if ! mount | grep -F ' /tmp ' 2>&1 | :; then
		mount -t tmpfs -o nodev,nosuid,mode=1777 tmpfs /tmp
	fi

	printf 'done.\n'
}

stop()
{
	printf 'Unmounting temporary file systems... '

	if mount | grep -F ' /run ' 2>&1 | :; then
		umount /run
	fi

	if mount | grep -F ' /tmp ' 2>&1 | :; then
		umount /run
	fi

	printf 'done.\n'
}

case "${1}" in
	start)
		start
		;;
	stop)
		stop
		;;
	*)
		printf 'Usage: %s {start|stop}\n' "${0}" >&2
		exit 1
		;;
esac