Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
improve fstab reload
Browse files Browse the repository at this point in the history
  • Loading branch information
jjm2473 committed Apr 4, 2019
1 parent cd5342a commit e78de98
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions root/etc/init.d/fstab
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ fstab_add_mount() {
local cmd

config_get_bool enabled "$1" enabled 0
[ $enabled -gt 0 ] && {
config_get uuid "$1" 'uuid'
if [ -z "$uuid" ] ; then
config_get label "$1" 'label'
if [ -z "$label" ] ; then
config_get device "$1" 'device'
else
device=`blkid -o device -L $label`
fi

config_get uuid "$1" 'uuid'
if [ -z "$uuid" ] ; then
config_get label "$1" 'label'
if [ -z "$label" ] ; then
config_get device "$1" 'device'
else
device=`blkid -o device -U $uuid`
device=`blkid -o device -L $label`
fi
else
device=`blkid -o device -U $uuid`
fi

[ -n "$device" ] && {
[ -n "$device" -a -b "$device" ] && {
config_get target "$1" 'target'

[ -z "$target" ] && return 0

if [ $enabled -gt 0 ] ; then
# mount
config_get fstype "$1" 'fstype'
config_get options "$1" 'options'
config_get target "$1" 'target'

[ -z "$target" ] && return 0

[ -d "$target" ] || mkdir -p "$target"

Expand All @@ -51,19 +54,22 @@ fstab_add_mount() {
cmd="$cmd $device $target"

$cmd
}
else
grep -q "$device $target " /proc/mounts && umount -r "$target"
fi
}
}

boot() {
start

}

start() {
config_load fstab
config_foreach fstab_add_mount mount
}

reload() {
start
}

stop() {
sync
find /mnt/ -maxdepth 1 -mindepth 1 -type d | xargs -n1 umount -r
Expand Down

0 comments on commit e78de98

Please sign in to comment.