mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
76 lines
1.6 KiB
Bash
Executable File
76 lines
1.6 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
START=45
|
|
STOP=99
|
|
NAME="nfs"
|
|
|
|
nfs_share() {
|
|
|
|
local enabled path clients options
|
|
config_get_bool enabled "$1" enabled 0
|
|
for opt in path clients options
|
|
do
|
|
config_get "$opt" "$1" "$opt"
|
|
done
|
|
|
|
if [ "$enabled" = 1 ]; then
|
|
grep -qs $path /etc/exports
|
|
if [ $? -ne 0 ]; then
|
|
echo -e "$path\t$clients($options)" >>/etc/exports
|
|
exportfs -r
|
|
fi
|
|
elif [ "$enabled" = 0 ]; then
|
|
exportfs -u | grep -qs $path
|
|
if [ $? -eq 0 ]; then
|
|
exportfs -u $clients:$path
|
|
fi
|
|
fi
|
|
exportfs -r
|
|
}
|
|
|
|
nfs_share_stop() {
|
|
exportfs -au &>/dev/null
|
|
}
|
|
|
|
nfs_mount() {
|
|
|
|
local enabled target source options delay
|
|
config_get_bool enabled "$1" enabled 0
|
|
for opt in target source options delay
|
|
do
|
|
config_get "$opt" "$1" "$opt"
|
|
done
|
|
|
|
if [ "$enabled" = 1 ]; then
|
|
if [ "$delay" -a $delay -gt 0 ]; then
|
|
logger "NetMount: Sleep $delay seconds before mount"
|
|
sleep $delay
|
|
fi
|
|
grep -qs $target /proc/mounts
|
|
if [ $? -ne 0 ]; then
|
|
mkdir -p $target
|
|
logger "NetMount: Mounting $source in $target"
|
|
mount -t nfs -o $options $source $target
|
|
fi
|
|
elif [ "$enabled" = 0 ]; then
|
|
if grep -qs $target /proc/mounts; then
|
|
umount -fr $target
|
|
sleep $delay
|
|
fi
|
|
fi
|
|
}
|
|
|
|
start() {
|
|
config_load "$NAME"
|
|
config_foreach nfs_share share
|
|
config_foreach nfs_mount mount
|
|
}
|
|
|
|
stop() {
|
|
nfs_share_stop
|
|
}
|
|
|
|
restart() {
|
|
echo > /etc/exports
|
|
start
|
|
}
|