* updated maddy (0.7.1 -> 0.8.1), untested
[t2sde.git] / package / network / rocknet / ifswitch.sh
blob01dbe899a02ff2c932e0352127b7341dbbf93c10
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: package/*/rocknet/ifswitch.sh
4 # Copyright (C) 2022 The T2 SDE Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 set -e
15 active=$( cat /var/run/rocknet/active-interfaces 2>/dev/null || true )
17 if [ $# -eq 0 ]; then
18 echo "Usage $0 [ interface profile ] | [ profile ]"
19 exit
22 i=0
23 for x in ${active//,/ }; do
24 [ $(( i++ )) -eq 0 ] && echo "Deactivating current interfaces ..."
25 if=${x/(*)/}
26 profile=${x/*(/} profile=${profile%)}
27 ifdown $if $profile
28 done
30 echo "Activating specified profile/interfaces ..."
32 if [ $# -eq 1 ]; then
33 rocknet $1 auto up
34 else
35 ifup $1 $2