56 lines
1.5 KiB
Bash
Executable File
56 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This script utilizes netcfg-daemon.
|
|
|
|
. /etc/rc.conf
|
|
. /etc/rc.d/functions
|
|
. /usr/lib/network/globals
|
|
|
|
case "$1" in
|
|
start)
|
|
if ! ck_daemon net-profiles; then
|
|
exit_stderr "net-profiles has already been started. Try '/etc/rc.d/net-profiles restart'"
|
|
fi
|
|
|
|
# Ensure any device renaming has occurred as intended
|
|
for daemon in "${DAEMONS[@]}"; do
|
|
if [[ $daemon = net-rename ]]; then
|
|
if ck_daemon net-rename; then
|
|
/etc/rc.d/net-rename start
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# $NET env var is passed from the kernel boot line
|
|
if [[ -n $NET ]]; then
|
|
# Record the connected profile for net-profiles stop
|
|
if [[ $NET = menu ]]; then
|
|
/usr/bin/netcfg-menu || exit 1
|
|
mv "$STATE_DIR"/{menu,netcfg-daemon}
|
|
else
|
|
/usr/bin/netcfg check-iface "$NET" || exit 1
|
|
echo "$NET" > "$STATE_DIR/netcfg-daemon"
|
|
fi
|
|
elif ! /usr/bin/netcfg-daemon start; then
|
|
exit_err "No profile started."
|
|
fi
|
|
add_daemon net-profiles
|
|
;;
|
|
stop)
|
|
if ck_daemon net-profiles; then
|
|
exit_stderr "net-profiles is not running"
|
|
fi
|
|
/usr/bin/netcfg-daemon stop
|
|
rm_daemon net-profiles
|
|
;;
|
|
restart)
|
|
"$0" stop
|
|
sleep 1
|
|
"$0" start
|
|
;;
|
|
*)
|
|
exit_stderr "Usage: $0 {start|stop|restart}"
|
|
esac
|
|
|
|
# vim: ft=sh ts=4 et sw=4:
|