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
77b8e9f4
Commit
77b8e9f4
authored
Feb 15, 2018
by
Igor Pecovnik
Browse files
Add support for systemd-network type of changing IP
parent
ecc2280a
Changes
2
Hide whitespace changes
Inline
Side-by-side
debian-config-jobs
View file @
77b8e9f4
...
...
@@ -194,18 +194,35 @@ function jobs ()
# Select dynamic or edit static IP address
#
"IP"
)
#
select default interfaces if there is more than
on
e
select_default_interface
#
check if we have systemd networking in acti
on
SYSTEMDNET
=
$(
service systemd-networkd status |
grep
-w
active |
grep
-w
running
)
dialog
--title
" IP address assignment "
--colors
--backtitle
"
$BACKTITLE
"
--help-button
--help-label
"Cancel"
\
--yes-label
"DHCP"
--no-label
"Static"
--yesno
\
"
\n\Z
1DHCP:
\Z
0 automatic IP asignment by your router or DHCP server
\n\n\Z
1Static:
\Z
0 manually fixed IP address"
9 70
exitstatus
=
$?
;
# dynamic
if
[[
$exitstatus
=
0
]]
;
then
create_if_config
"
$DEFAULT_ADAPTER
"
"
$DEFAULT_ADAPTER
"
"dynamic"
>
/etc/network/interfaces
if
[[
-n
$SYSTEMDNET
]]
;
then
filename
=
"/etc/systemd/network/10-
${
DEFAULT_ADAPTER
}
.network"
if
[[
-f
$filename
]]
;
then
sed
-i
'/Network/,$d'
$filename
echo
-e
"[Network]"
>>
$filename
echo
-e
"DHCP=ipv4"
>>
$filename
fi
else
create_if_config
"
$DEFAULT_ADAPTER
"
"
$DEFAULT_ADAPTER
"
"dynamic"
>
/etc/network/interfaces
fi
fi
# static
if
[[
$exitstatus
=
1
]]
;
then
create_if_config
"
$DEFAULT_ADAPTER
"
"
$DEFAULT_ADAPTER
"
"fixed"
>
/dev/null
ip_editor
"
$DEFAULT_ADAPTER
"
"
$DEFAULT_ADAPTER
"
"/etc/network/interfaces"
if
[[
-n
$SYSTEMDNET
]]
;
then
systemd_ip_editor
"
${
DEFAULT_ADAPTER
}
"
else
ip_editor
"
$DEFAULT_ADAPTER
"
"
$DEFAULT_ADAPTER
"
"/etc/network/interfaces"
fi
fi
;;
...
...
debian-config-submenu
View file @
77b8e9f4
...
...
@@ -245,6 +245,30 @@ function description
}
function
systemd_ip_editor
()
{
local
filename
=
"/etc/systemd/network/10-
$1
.network"
if
[[
-f
$filename
]]
;
then
sed
-i
'/Network/,$d'
$filename
exec
3>&1
dialog
--title
" Static IP configuration"
--backtitle
"
$BACKTITLE
"
--form
"
\n
Adapter:
$1
\n
"
12 38 0
\
"Address:"
1 1
"
$address
"
1 15 15 0
\
"Netmask:"
2 1
"
$netmask
"
2 15 15 0
\
"Gateway:"
3 1
"
$gateway
"
3 15 15 0
\
2>&1 1>&3 |
{
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
if
[[
$?
=
0
]]
;
then
echo
-e
"[Network]"
>>
$filename
echo
-e
"Address=
$address
"
>>
$filename
echo
-e
"Gateway=
$gateway
"
>>
$filename
echo
-e
"DNS=8.8.8.8"
>>
$filename
fi
}
fi
}
#-----------------------------------------------------------------------------------------------------------------------------------------#
# edit ip address
#
...
...
@@ -719,10 +743,15 @@ while true; do
local
ipadd
=
$(
ip
-4
addr show dev
$DEFAULT_ADAPTER
|
awk
'/inet/ {print $2}'
|
cut
-d
'/'
-f1
)
if
[[
-n
$(
LC_ALL
=
C nmcli device status |
grep
wlan0 |
grep
connected
)
]]
;
then
if
[[
-n
$(
LC_ALL
=
C nmcli device status |
grep
$DEFAULT_ADAPTER
|
grep
connected
)
]]
;
then
local
ifup
=
"
\n
IP (
$DEFAULT_ADAPTER
) via Network Manager:
\Z
1
${
ipadd
}
\n\Z
0 "
else
local
ifup
=
"
\n
IP (
$DEFAULT_ADAPTER
) via IFUPDOWN:
\Z
1
${
ipadd
}
\n\Z
0 "
if
[[
-n
$(
service systemd-networkd status |
grep
-w
active |
grep
-w
running
)
]]
;
then
local
ifup
=
"
\n
IP (
$DEFAULT_ADAPTER
) via systemd-networkd:
\Z
1
${
ipadd
}
\n\Z
0 "
else
local
ifup
=
"
\n
IP (
$DEFAULT_ADAPTER
) via IFUPDOWN:
\Z
1
${
ipadd
}
\n\Z
0 "
fi
fi
disclaimer
=
"
$ifup
"
...
...
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