void-packages/srcpkgs/sv-netmount/files/netmount/run

24 lines
628 B
Bash

#!/bin/sh
exec 2>&1
# Load user defined variables
[ -r conf ] && . ./conf
# Ensure the network manager is running
[ -z "$NETWORK_MANAGER" ] || sv check "$NETWORK_MANAGER" > /dev/null 2>&1 || exit 1
# If it's running or not in used - rc.local - discover default gateway
if [ -z "$GATEWAY" ]; then
set -- $(ip route show | grep default)
GATEWAY="$3"
fi
ping -W 1 -c 1 $GATEWAY > /dev/null 2>&1 || exit 1
# Network is up and running so now mount network filesystems from fstab
mount -a -t "$NETWORK_FS" || exit 1
mount -a -O _netdev || exit 1
# Then wait to behave like the service is up
exec chpst -b netmount pause