Mini Shell
#!/usr/bin/bash
#
# cagefs Startup script for CageFS
solo_marker="/etc/cloudlinux-edition-solo"
container_marker="/etc/cloudlinux-container"
cagefs_bin="/usr/sbin/cagefsctl"
lvectl_bin="/usr/sbin/lvectl"
if [ -e "$solo_marker" ] || [ -e "$container_marker" ]; then
lvectl_bin="/bin/true"
fi
function run {
local command="$@"
$command
local retval=$?
if [ $retval -ne 0 ]; then
echo "Command execution failed: ${command}"
return $retval
fi
}
start() {
run $cagefs_bin --mount-skel || return $?
run $lvectl_bin destroy all --force || return $?
if [ -e "$solo_marker" ] || [ -e "$container_marker" ]; then
run /usr/sbin/cagefsctl --delete-namespaces --wait-lock || return $?
fi
sleep 1
run $cagefs_bin --remove-unused-mount-points --wait-lock || return $?
if [ -e "$solo_marker" ] || [ -e "$container_marker" ]; then
run /usr/sbin/cagefsctl --create-namespaces --wait-lock || return $?
fi
run $lvectl_bin apply all --force
local retval=$?
rm -f /usr/share/cagefs/need.remount
return $retval
}
restart() {
start
}
stop() {
run $cagefs_bin --unmount-skel || return $?
run $lvectl_bin destroy all || return $?
sleep 1
if [ -e "$solo_marker" ] || [ -e "$container_marker" ]; then
run /usr/sbin/cagefsctl --delete-namespaces --wait-lock || return $?
fi
run $cagefs_bin --remove-unused-mount-points --wait-lock || return $?
run $lvectl_bin apply all || return $?
return 0
}
RETVAL=0
# See how we were called.
case "$1" in
start)
start
RETVAL=$?
;;
restart)
if [ -e /usr/share/cagefs/skip.cagefs.restart ]; then
rm -f /usr/share/cagefs/skip.cagefs.restart
exit 0
fi
restart
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|restart|stop}"
exit 1
esac
exit $RETVAL
Zerion Mini Shell 1.0