Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Config
Commits
8c79473d
Commit
8c79473d
authored
Apr 19, 2019
by
Igor Pecovnik
Browse files
Improved hotspot management
parent
8ab62d59
Changes
2
Hide whitespace changes
Inline
Side-by-side
debian-config-functions-network
View file @
8c79473d
...
@@ -548,28 +548,35 @@ function get_wlan_interface ()
...
@@ -548,28 +548,35 @@ function get_wlan_interface ()
#
#
function
select_default_interface
()
function
select_default_interface
()
{
{
ALREADY_DEFINED
=
$(
cat
/etc/iptables.ipv4.nat 2> /dev/null |
grep
"POSTROUTING -o"
|
tail
-1
|
awk
'{ print $4 }'
)
if
[[
-n
"
${
ALREADY_DEFINED
}
"
]]
;
then
IFS
=
$'
\r\n
'
DEFAULT_ADAPTER
=
${
ALREADY_DEFINED
}
GLOBIGNORE
=
'*'
local
ADAPTER
=(
$(
ls
/sys/class/net |
grep
-E
-v
'lo|tun|bonding_masters|dummy0|bond0|sit0|br0'
)
)
local
LIST
=()
for
i
in
"
${
ADAPTER
[@]
}
"
do
local
IPADDR
=
$(
ip
-4
addr show dev
${
i
[0]
}
|
awk
'/inet/ {print $2}'
|
cut
-d
'/'
-f1
)
[[
$IPADDR
!=
"172.24.1.1"
]]
&&
LIST+
=(
"
${
i
[0]//[[
:blank:]]/
}
"
"
${
IPADDR
}
"
)
done
LIST_LENGTH
=
$((${#
LIST
[@]
}
/
2
))
;
if
[
"
$LIST_LENGTH
"
-eq
0
]
;
then
DEFAULT_ADAPTER
=
"lo"
elif
[
"
$LIST_LENGTH
"
-eq
1
]
;
then
DEFAULT_ADAPTER
=
${
ADAPTER
[0]
}
else
else
exec
3>&1
IFS
=
$'
\r\n
'
DEFAULT_ADAPTER
=
$(
dialog
--nocancel
--backtitle
"
$BACKTITLE
"
--no-collapse
\
GLOBIGNORE
=
'*'
--title
"Select default interface"
--clear
--menu
""
$((
6
+
${
LIST_LENGTH
}))
40 15
"
${
LIST
[@]
}
"
2>&1 1>&3
)
local
ADAPTER
=(
$(
ls
/sys/class/net |
grep
-E
-v
'lo|tun|bonding_masters|dummy0|bond0|sit0|br0'
)
)
exec
3>&-
local
LIST
=()
for
i
in
"
${
ADAPTER
[@]
}
"
do
local
IPADDR
=
$(
LC_ALL
=
C ip
-4
addr show dev
${
i
[0]
}
|
awk
'/inet/ {print $2}'
|
cut
-d
'/'
-f1
)
ADD_SPEED
=
""
[[
$i
==
eth
*
||
$i
==
en
*
]]
&&
ADD_SPEED
=
$(
ethtool
$i
|
grep
Speed
)
[[
$i
==
wl
*
]]
&&
ADD_SPEED
=
$(
LC_ALL
=
C nmcli
-f
RATE,DEVICE,ACTIVE dev wifi list |
grep
$i
|
grep yes
|
awk
'NF==4{print $1""$2}NF==1'
|
sed
-e
's/^/ Speed: /'
|
tail
-1
)
[[
$IPADDR
!=
"172.24.1.1"
&&
-n
$IPADDR
]]
&&
LIST+
=(
"
${
i
[0]//[[
:blank:]]/
}
"
"
${
IPADDR
}
${
ADD_SPEED
}
"
)
done
LIST_LENGTH
=
$((${#
LIST
[@]
}
/
2
))
;
if
[
"
$LIST_LENGTH
"
-eq
0
]
;
then
DEFAULT_ADAPTER
=
"lo"
elif
[
"
$LIST_LENGTH
"
-eq
1
]
;
then
DEFAULT_ADAPTER
=
${
ADAPTER
[0]
}
else
exec
3>&1
DEFAULT_ADAPTER
=
$(
dialog
--nocancel
--backtitle
"
$BACKTITLE
"
--no-collapse
\
--title
"Select default interface"
--clear
--menu
""
$((
6
+
${
LIST_LENGTH
}))
0 15
"
${
LIST
[@]
}
"
2>&1 1>&3
)
exec
3>&-
fi
fi
fi
}
}
...
...
debian-config-jobs
View file @
8c79473d
...
@@ -355,10 +355,14 @@ function jobs ()
...
@@ -355,10 +355,14 @@ function jobs ()
"Clear"
)
"Clear"
)
# remove managed interfaces
# remove managed interfaces
systemctl daemon-reload
systemctl daemon-reload
nmcli con delete
$(
nmcli
--fields
NAME,UUID,TYPE con |
grep
wifi |
awk
'{print $2}'
)
sed
's/interface-name:wl.*//'
-i
/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
sed
's/interface-name:wl.*//'
-i
/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
sed
's/,$//'
-i
/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
sed
's/,$//'
-i
/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/dnsmasq.conf
rm
-f
/etc/iptables.ipv4.nat
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
reload-nety
reload-nety
;;
;;
...
@@ -391,6 +395,8 @@ function jobs ()
...
@@ -391,6 +395,8 @@ function jobs ()
ifdown
$WIRELESS_ADAPTER
2> /dev/null
ifdown
$WIRELESS_ADAPTER
2> /dev/null
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/dnsmasq.conf
rm
-f
/etc/iptables.ipv4.nat
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
sed
-i
'/^iptables/ d'
/etc/rc.local
sed
-i
'/^iptables/ d'
/etc/rc.local
sed
-i
'/^service dnsmasq/ d'
/etc/rc.local
sed
-i
'/^service dnsmasq/ d'
/etc/rc.local
...
@@ -500,7 +506,7 @@ function jobs ()
...
@@ -500,7 +506,7 @@ function jobs ()
[[
!
-f
/etc/network/interfaces
]]
&&
echo
"source /etc/network/interfaces.d/*"
>
/etc/network/interfaces
[[
!
-f
/etc/network/interfaces
]]
&&
echo
"source /etc/network/interfaces.d/*"
>
/etc/network/interfaces
# select default interfaces if there is more than one
# select default interfaces if there is more than one
select_default_interface
#
select_default_interface
NETWORK_CONF
=
"/etc/network/interfaces"
NETWORK_CONF
=
"/etc/network/interfaces"
...
@@ -707,7 +713,7 @@ function jobs ()
...
@@ -707,7 +713,7 @@ function jobs ()
# Remove automatic wifi conections
# Remove automatic wifi conections
#
#
"Forget"
)
"Forget"
)
LC_ALL
=
C nmcli
--fields
UUID,TIMESTAMP-REAL,TYPE con show |
grep
wi
reless
|
awk
'{print $1}'
|
while
read
line
;
\
LC_ALL
=
C nmcli
--fields
UUID,TIMESTAMP-REAL,TYPE con show |
grep
wi
fi
|
awk
'{print $1}'
|
while
read
line
;
\
do
nmcli con delete uuid
$line
;
done
>
/dev/null
do
nmcli con delete uuid
$line
;
done
>
/dev/null
;;
;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment