* updated maddy (0.7.1 -> 0.8.1), untested
[t2sde.git] / package / network / rocknet / ifup.sh
blob8ddd7829c13f5b02e7817af4a79b0bb455d6f3fe
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: package/*/rocknet/ifup.sh
4 # Copyright (C) 2004 - 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 rocknet_tmp_base="/var/run/rocknet"
14 [ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
16 var_contains() {
17 local tmp
18 eval "tmp=\"\$$1\""
20 [ "${tmp/$3$2/}" != "$tmp" ]
23 usage() {
24 echo "Usage: $0 interface [ profile ] [ -force ]"
25 exit 1
28 force=0
30 if="$1" ; shift ; [ "$if" ] || usage
31 profile=""
32 action="${0/#*\/if}"
34 while [ "$1" ] ; do
35 case $1 in
36 -force) force=1 ;;
37 *) [ "$profile" = "" ] && profile="$1" || usage ;;
38 esac
39 shift
40 done
42 [ "$profile" ] || profile="`cat /etc/conf/network-profile 2> /dev/null`"
43 profile=${profile:-default}
45 # sanity checks (...)
47 if [ $force -eq 0 ]; then
48 active_interfaces="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
50 if test $action = "up" && var_contains active_interfaces ',' "$if($profile)"
51 then
52 echo "Interface $if($profile) is already listed active, it is probably a good idea to"
53 echo "take it down before activating it. Use -force to suppress this warning."
54 exit 2
57 if test $action = "down" && ! var_contains active_interfaces ',' "$if($profile)"
58 then
59 echo "Interface $if($profile) is not listed active, it is probably a good idea to"
60 echo "activate it before deactivating it. Use -force to suppress this warning."
61 exit 2
65 /sbin/rocknet "$profile" "$if" "$action"
66 echo "$profile" > /etc/conf/network-profile