#1517 Issue closed: Split up lib/network-functions.sh into DHCP setup and general ReaR functions

Labels: cleanup, fixed / solved / done

jsmeix opened issue at 2017-09-26 11:15:

lib/network-functions.sh should be split into functions
for DHCP setup during recovery system startup
and general functions used in usual ReaR scripts.

This issue emerged from
https://github.com/rear/rear/pull/1510
therein see in particular
https://github.com/rear/rear/pull/1510#issuecomment-331423317
and
https://github.com/rear/rear/pull/1510#issuecomment-332140203
where the latter reads (excerpts):

network-functions.sh is collection ... grabbed from an
old RHEL system to get the job done as easy as possible
...
we better split it apart (network piece required
for DHCP in skel and network functions which
are required by main rear script).

For "ReaR future" because currently nothing goes wrong
so that there is no need to do such this cleanup right now.

jsmeix commented at 2017-10-05 15:41:

In which normal ReaR scripts the old functions of
usr/share/rear/lib/network-functions.sh
are called:

prefix2netmask is found in
usr/share/rear/finalize/GNU/Linux/320_migrate_network_configuration_files.sh

get_device_by_hwaddr is found in
usr/share/rear/finalize/GNU/Linux/320_migrate_network_configuration_files.sh

Normal ReaR scripts are usr/sbin/rear and the scripts in
usr/share/rear except the recovery system startup scripts in
usr/share/rear/skel/default

The old functions are

exit_with_hooks
logmessage
save_previous
eventually_add_hostnames_domain_to_search
make_resolv_conf
change_resolv_conf
my_ipcalc
quad2num
ip2num
num2ip
get_network_address
prefix2netmask
get_prefix
class_bits
is_router_reachable
add_default_gateway
flush_dev
dhconfig
add_ipv6_addr_with_DAD
dh6config
get_hwaddr
get_device_by_hwaddr
need_hostname
set_hostname
check_device_down
check_link_down
check_default_route
find_gateway_dev
add_default_route
is_wireless_device
install_bonding_driver
is_bonding_device

which are all functions in
usr/share/rear/lib/network-functions.sh
except the

function is_ip()
function get_ip_from_fqdn()
function linearize_interfaces_file()
function rebuild_interfaces_file_from_linearized()

that were recently addeb by @schabrolles

jsmeix commented at 2017-10-05 16:06:

prefix2netmask calls
num2ip and needs
MASKS

num2ip does not need other functions or variables

get_device_by_hwaddr does not need other functions or variables

so that normal ReaR scripts only need those
old functions and variables of
usr/share/rear/lib/network-functions.sh

MASKS
num2ip
prefix2netmask
get_device_by_hwaddr 

jsmeix commented at 2017-10-10 09:11:

With https://github.com/rear/rear/pull/1526 merged
this issue should be fixed.


[Export of Github issue for rear/rear.]