From 0f3fa64430095bcaedfa091d7a27b1d2dc728f9d Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Wed, 18 Jan 2012 20:38:34 +0000 Subject: [PATCH] wicd: integrate with upstart events quite some services need to be started/restarted when a connection is established/teared down. Also, some services are optional depending on the connected access point. For example: use a vpn on an untrusted network. these small trigger scripts don't change any behaviour by themselves, but allow you to hook in to them if you need. example use: jobs.gw6c.startOn = pkgs.lib.mkForce "started openvpn-dcsOffice"; jobs.gw6c.stopOn = pkgs.lib.mkForce "stopping openvpn-dcsOffice"; jobs."openvpn-dcsOffice".startOn = pkgs.lib.mkForce "wicd-postconnect"; jobs."openvpn-dcsOffice".stopOn = pkgs.lib.mkForce "stopping network-interfaces or wicd-predisconnect"; In the example, I use 3 layers. When a physical connection is available (wifi connect), I setup a vpn connection, and setup an ipv6 tunnel on top of that. When disconnecting, they are automatically shut down in the right order as well. svn path=/nixpkgs/trunk/; revision=31662 --- pkgs/tools/networking/wicd/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/tools/networking/wicd/default.nix b/pkgs/tools/networking/wicd/default.nix index 19f30713a9fe..72d41519c7ce 100644 --- a/pkgs/tools/networking/wicd/default.nix +++ b/pkgs/tools/networking/wicd/default.nix @@ -85,6 +85,17 @@ stdenv.mkDerivation rec { # . cp -v "${./wpa2-ttls}" "$out/etc/encryption/templates/wpa2-ttls" echo "wpa2-ttls" >> "$out/etc/encryption/templates/active" + + # have wicd generate upstart events + echo '#!/bin/sh +initctl emit -n wicd-preconnect ITYPE="$1" ESSID="$2" BSSID="$3"' > $out/etc/scripts/preconnect/upstart-emit + echo '#!/bin/sh +initctl emit -n wicd-postconnect ITYPE="$1" ESSID="$2" BSSID="$3"' > $out/etc/scripts/postconnect/upstart-emit + echo '#!/bin/sh +initctl emit -n wicd-predisconnect ITYPE="$1" ESSID="$2" BSSID="$3"' > $out/etc/scripts/predisconnect/upstart-emit + echo '#!/bin/sh +initctl emit -n wicd-postdisconnect ITYPE="$1" ESSID="$2" BSSID="$3"' > $out/etc/scripts/postdisconnect/upstart-emit + chmod a+x $out/etc/scripts/*/upstart-emit ''; meta = {