You are not logged in.
The man pages are bit ambiguous, but this is what I'd like to know:
Given I'm connecting to wireless network "MyESSID" on interface "wlan0", what is the execution order of these scripts:
/etc/netctl/hooks/*
/etc/netctl/interfaces/wlan0
/etc/netctl/wlan0-MyESSID (ExecUpPost)
Given I'm disconnecting from the same interface/essid, what is the execution order again:
/etc/netctl/hooks/*
/etc/netctl/interfaces/wlan0
/etc/netctl/wlan0-MyESSID (ExecDownPre)
Some of my wireless networks need proxies, and others don't.
I'd like to start/stop Dropbox on connect/disconnect of any network (but only after the proxies are set)
Thanks in advance!
Last edited by sxtynnmach1 (2013-07-27 05:38:39)
Hello Darkness, my old friend. I've come to talk with you again.
Offline
The nice thing about netctl is that is is jsut a collection of shell scripts. So you should check out /usr/bin/netctl and see if there is a function there that tells you about this. If not there, then check out what other files it may source and then check those functions as well.
Offline
Let us know how you set it up. I was just now also looking for the most convenient way to turn a service (in my case CrashPlan) on or off based on network location.
Offline
To be honest I've been experimenting between wicd, networkmanager and netctl.
I really like wicd's way of executing scripts based on preconnect, postconnect, predisconnect and postdisconnect. Each script you make receives the ESSID or profile name so that you can have if or case statements per network location.
Unfortunately, it seems that wicd development has stagnated for the past year and a half
I didn't want something as heavy-weight as networkmanager, but it's looking to be the most convenient solution. After looking through the netctl bash scripts it seems a bit janky with it's handling of /etc/netctl/hooks.
Hello Darkness, my old friend. I've come to talk with you again.
Offline
For my purposes in this particular case I can live with just having a "systemctl crashplan restart" in /etc/netctl/interfaces/INTERFACE. I think making hook scripts aware of action (up/down) and interface, as well as maybe ESSID or whatever would be useful though, so if you have an idea on how that should work I think you should put in a feature request.
Last edited by bkhl (2013-07-21 18:23:23)
Offline
Added the feature request to the netctl github page.
Since the hooks/interface scripts are sourced instead of passed to a subshell, they have access to previously-defined variables. At the time of this writing, when netctl sources it's hooks and interface scripts the following are already available in the environment:
$interface (ex: wlan0)
$profile (ex: wlan0-essid)
$action (ex: CONNECT, see wpa_actiond --help)
$ssid
Following the convention of prepending two-digit numbers to my scripts to enforce execution order, I have gotten pretty fine-grained control over my scripts and netctl actions
/etc/netctl/hooks/10-proxy.sh
-----------------------------
#!/bin/sh
if [ "$profile" = "wlan0-companyESSID" ]
then
case "$action" in
"CONNECT"|"REESTABLISHED")
export http_proxy="http://proxy.company.com:8080"
;;
*)
unset http_proxy
;;
esac
fi
Hello Darkness, my old friend. I've come to talk with you again.
Offline
Good to know. I don't think your proxy setting script will work like that though, since the environment variable will only be visible within the scope of the script.
Offline
I was intentionally setting the proxy that way :-)
I have another hook script later on that starts processes that pull http_proxy from the environment, if available.
Hello Darkness, my old friend. I've come to talk with you again.
Offline