#!/bin/sh #---------------------------------------------------------------------------- # /etc/init.d/mtab - initial boot script # # Creation : 2015-06-20 hbfl # Last Update: $Id$ # # Copyright (c) 2015-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # --------------------------------------------------------------------------- # Update the mount program's mtab file after # all local filesystems have been mounted. # --------------------------------------------------------------------------- lsb=false if ${lsb} then # read init-functions . /lib/lsb/init-functions else # read functions . /etc/init.d/functions fi # --------------------------------------------------------------------------- # usage # --------------------------------------------------------------------------- usage() { cat < symlink to /proc/self/mounts mtab=true if ! /usr/bin/readlink /etc/mtab | /usr/bin/grep -wq 'proc/self/mounts' then call_dir=$( pwd ) cd /etc /usr/bin/rm -f mtab /usr/bin/ln -s ../proc/self/mounts mtab cd ${call_dir} fi fi if ! ${mtab:-false} then if /usr/bin/grep -q '/dev/root' /proc/self/mounts then # /etc/mtab -> regular file mtab=true mtab_file=true _old_rootfs='/dev/root' fi fi if ! ${mtab:-false} then _root_device=$( /usr/bin/cat /proc/cmdline | /usr/bin/sed 's/^.*root=\(.*\) .*$/\1/' ) if /usr/bin/grep -q "${_root_device}" /proc/self/mounts then # /etc/mtab -> regular file mtab=true mtab_file=true _old_rootfs="${_root_device}" fi fi if ${mtab_file:-false} then # remove the old file /usr/bin/rm -f /etc/mtab # create /etc/mtab /usr/bin/awk '$1 != "rootfs" {print}' /proc/self/mounts | /usr/bin/sed "s%${_old_rootfs}%${ROOTFS}%" > /etc/mtab fi # Remove stale backups /usr/bin/rm -f /etc/mtab~ /etc/mtab~~ } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { while [ ${#} -gt 0 ] do case "${1}" in -q|--quiet) _quiet=true shift ;; *) _action=${1} shift ;; esac done case "${_action}" in start) start ;; *) usage exit 1 ;; esac exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------