#!/bin/sh
### BEGIN INIT INFO
# Provides:            $local_fs
# Required-Start:      udev checkfs checkroot
# Should-Start:
# Required-Stop:       swap
# Should-Stop:
# Default-Start:       S
# Default-Stop:        0 6
# Short-Description:   Mounts/unmounts local filesystems
# Description:         Remounts root filesystem read/write and mounts all
#                      remaining local filesystems defined in /etc/fstab
#                      During stop remounts root filesystem read-only and
#                      unmounts remaining filesystems.
# X-Required:          true
### END INIT INFO

. /lib/lsb/init-functions

[ -z $container ] || exit 0

case "$1" in
  start)
    log_init_msg "Mounting local file systems"
    mount -a -O no_netdev >/dev/null && log_success_msg || log_failure_msg
    ;;
  stop)
    log_init_msg "Unmounting local file systems"
    umount -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts \
      >/dev/null && log_success_msg || log_failure_msg

    mount -o remount,ro /
    ;;
  *)
    echo "Usage: $0 [start|stop]"
    exit 1
    ;;
esac

exit 0
