diff options
author | Hans Fernhout <hfern@fernhout.info> | 2020-05-30 22:27:16 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2020-05-30 22:29:36 -0700 |
commit | c0f36e9995b6e07b6691fa0c2d5c3a13223f9815 (patch) | |
tree | 587af1614bb874a83c424965fbc77c7c7b13fb47 | |
parent | doc: Document bridge_forward_delay/bridge_hello_time (diff) | |
download | netifrc-c0f36e9995b6e07b6691fa0c2d5c3a13223f9815.tar.gz netifrc-c0f36e9995b6e07b6691fa0c2d5c3a13223f9815.tar.bz2 netifrc-c0f36e9995b6e07b6691fa0c2d5c3a13223f9815.zip |
net/iwd: add iwd helper
Bug: https://bugs.gentoo.org/690808
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | net/iwd.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/net/iwd.sh b/net/iwd.sh new file mode 100644 index 0000000..afb5b22 --- /dev/null +++ b/net/iwd.sh @@ -0,0 +1,53 @@ +# Original copyright (c) 2007-2009 Roy Marples <roy@marples.name> +# Released under the 2-clause BSD license. + +iwd_depend() +{ + need dbus + after macnet plug + before interface + provide wireless + after iwconfig +} + +_config_vars="$_config_vars iwd" + +iwd_pre_start() +{ + local iwds=/usr/libexec/iwd + local args= opt= opts= + eval opts=\$iwd_${IFVAR} + + #set a "safe" default in case phy was not defined + PHY="phy0" + + for opt in ${opts}; do + case "${opt}" in + phy* ) PHY="${opt}" + einfo "Assigned PHY to be ${PHY}" + ;; + * ) ;; + esac + done + ebegin "Starting iwd on ${PHY} and ${IFVAR}" + pidfile="/run/iwd-${IFVAR}.pid" + start-stop-daemon --start --exec "${iwds}" --pidfile "${pidfile}" --background --verbose --make-pidfile -- -p ${PHY} -i "${IFVAR}" + return $? +} + + +iwd_post_stop() +{ + local iwds=/usr/libexec/iwd + pidfile="/run/iwd-${IFVAR}.pid" + if [ -f ${pidfile} ]; then + ebegin "Stopping iwd on ${IFACE}" + start-stop-daemon --stop --exec "${iwds}" --pidfile "${pidfile}" + eend $? + fi + + # If iwd exits uncleanly, we need to remove the stale dir + [ -S "/run/iwd/${IFACE}" ] \ + && rm -f "/run/iwd/${IFACE}" +} + |