Files
initscripts/SRC/initscripts/init.d/mountvirtfs
Jay Larson 17afdf7765 The following changes were made:
* removed quotes around chroot command in usher
  * removed hwclock from Required-Start in checkfs
  * removed $local_fs from Required-Start in hostname
  * updated mountvirtfs to create /run/utmp
  * added 2 conditionals to readsvcs() in update-rc
2017-05-20 09:18:03 -05:00

129 lines
2.6 KiB
Bash
Executable File

#!/bin/sh
### BEGIN INIT INFO
# Provides: mountvirtfs
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Mounts virtual file systems
# Description: Mount /sys and /proc kernel filesystems, also
# mount /run (tmpfs) and /dev (devtmpfs)
# X-Required: true
### END INIT INFO
. /lib/lsb/init-functions
calcsize () {
RAM=$(($(grep MemTotal /proc/meminfo|grep -o '[0-9]*')+0))
SWAP=$(($(grep SWAPTotal /proc/meminfo|grep -o '[0-9]*')+0))
VM=$((RAM+SWAP))
case "$1" in
*%*)
SIZE=$(((VM/100) * ${1%\%}))
;;
*)
SIZE=${1}
;;
esac
echo "$SIZE"
}
mountdev () {
KB=$(calcsize ${DEVSIZE:-10240})
if ! mountpoint -q /run; then
mount -o rw,relatime,size=${KB}k,mode=755 -t devtmpfs devtmpfs /dev || \
return 1
else
mount -o remount,rw,relatime,size=${KB}k,mode=755 -t devtmpfs devtmpfs \
/dev || return 1
fi
return 0
}
mountproc () {
if ! mountpoint -q /proc; then
mount -o nosuid,noexec,nodev -t proc proc /proc || return 1
else
mount -o remount,nosuid,noexec,nodev -t proc proc /proc || return 1
fi
return 0
}
mountpts () {
if [ ! -d /dev/pts ]; then
mkdir /dev/pts || return 1
fi
if ! mountpoint -q /dev/pts; then
mount -o rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 \
-t devpts devpts /dev/pts || return 1
fi
return 0
}
mountrun () {
KB=$(calcsize ${RUNSIZE:-10%})
if ! mountpoint -q /run; then
mount -o rw,nosuid,relatime,size=${KB}k,mode=755 -t tmpfs tmpfs /run || \
return 1
else
mount -o remount,rw,nosuid,relatime,size=${KB}k,mode=755 -t tmpfs tmpfs \
/run || return 1
fi
mkdir -p /run/lock /run/shm || return 1
chmod 1777 /run/shm || return 1
if grep -q '^utmp:' /etc/group; then
chmod 664 /run/utmp >> /run/utmp
chgrp utmp /run/utmp
fi
return 0
}
mountsys () {
if ! mountpoint -q /sys; then
mount -o nosuid,noexec,nodev -t sysfs sys /sys || return 1
else
mount -o remount,nosuid,noexec,nodev -t sysfs sys /sys || return 1
fi
return 0
}
case "$1" in
start|restart)
log_init_msg "Mounting virtual file systems"
for dir in dev pts proc run sys; do
mount$dir || error=1
done
ln -sfn /run/shm /dev/shm
[ -z $error ] && log_success_msg || log_failure_msg
;;
status)
for dir in /dev /proc /run /sys; do
log_init_msg "Checking $dir"
mountpoint -q $dir && log_success_msg || log_failure_msg
done
;;
*)
echo "Usage: $0 [start|restart|status]"
exit 1
;;
esac
exit 0