-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount_sys.sh
29 lines (24 loc) · 1.04 KB
/
mount_sys.sh
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
#!/bin/sh -eu
### Check parameters
[ -n "${1:-}" ] || { printf -- 'ERROR: No parameter given\n'; return 1 2>/dev/null || exit 1; }
[ -d "${1}" ] || { printf -- 'ERROR: parameter not a directory\n'; return 1 2>/dev/null || exit 1; }
### Mount /dev
if [ -d "${1}/dev" ]; then
grep -q -F -e "${1}/dev" /proc/mounts || { mount -t devtmpfs /dev "${1}/dev" || mount --bind /dev "${1}/dev" ; }
grep -q -F -e "${1}/dev/pts" /proc/mounts || mount -t devpts /dev/pts "${1}/dev/pts"
grep -q -F -e "${1}/dev/shm" /proc/mounts || mount -t tmpfs tmpfs "${1}/dev/shm"
#mqueue on /dev/mqueue type mqueue (rw,relatime)
fi
### Mount /proc
if [ -d "${1}/proc" ]; then
grep -q -F -e "${1}/proc" /proc/mounts || mount -t proc /proc "${1}/proc"
fi
### Mount /sys
if [ -d "${1}/sys" ]; then
grep -q -F -e "${1}/sys" /proc/mounts || mount -t sysfs /sys "${1}/sys"
fi
### Mount /run
if [ -d "${1}/run" ]; then
grep -q -F -e "${1}/run" /proc/mounts || mount -o bind /run "${1}/run"
grep -q -F -e "${1}/run/lock" /proc/mounts || mount -o bind /run/lock "${1}/run/lock"
fi