You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ublinux-init/ublinux/rc.network.d/10-network

50 lines
2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env bash
ENABLED=yes
[ "$ENABLED" != "yes" ] && exit 0
DEBUGMODE=no
SOURCE=/usr/lib/ublinux/functions; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null || exit 0
SOURCE=/usr/lib/ublinux/os-config; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null || exit 0
SOURCE=${SYSCONF}/config; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null
SOURCE=${SYSCONF}/network; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null
debug_mode "$0" "$@"
# mount ublinux-server
## Переделать authselect и связать с опциями домена
# Name Service Switch Win Avahi nsswitch.conf
# if [[ ${NSSWITCHAVAHI,,} == "yes" ]]; then
# file_nss=$(grep hosts /etc/nsswitch.conf)
# grep -q "mdns4_minimal" <<< "${file_nss}" || sed "/^hosts: /s/ resolve/ mdns4_minimal [NOTFOUND=return] resolve/" -i /etc/nsswitch.conf
# grep -q "mdns4" <<< "${file_nss}" || sed "/^hosts: /s/ dns/ dns mdns4/" -i /etc/nsswitch.conf
# fi
# if [[ ${NSSWITCHWINS,,} == "yes" ]]; then
# [[ -z ${file_nss} ]] && file_nss=$(grep hosts /etc/nsswitch.conf)
# grep -q "wins" <<< "${file_nss}" || sed "/^hosts:/s/ dns/ dns wins/" -i /etc/nsswitch.conf
# fi
# Network configuration
while read CONNECTION; do
CON_DEVICE=${CONNECTION%%:*}; CONNECTION=${CONNECTION#*:}
CON_UUID=${CONNECTION%%:*}; CONNECTION=${CONNECTION#*:}
CON_NAME=${CONNECTION%%:*}
CON_TYPE=${CONNECTION#*:}
for NETWORK_ITEM in "${!NETWORK[@]}"; do
unset NETWORK_DEVICE NETWORK_CONNECTION
NETWORK_NAME=${NETWORK_ITEM%%:*}
NETWORK_TYPE=${NETWORK_ITEM#*:}
if [[ ${NETWORK_TYPE,,} == "device" || ${NETWORK_TYPE,,} == "dev" ]]; then
[[ ${NETWORK_NAME,,} == ${CON_DEVICE,,} ]] && nmcli device modify "${CON_DEVICE}" ${NETWORK[${NETWORK_ITEM}]}
else
[[ ${NETWORK_NAME,,} == "all" || ${NETWORK_NAME,,} == "any" \
|| ${NETWORK_NAME,,} == "connection" || ${NETWORK_NAME,,} == "con" \
|| ${NETWORK_NAME,,} == ${CON_DEVICE,,} || ${NETWORK_NAME,,} == ${CON_UUID,,} \
|| ${NETWORK_NAME,,} == ${CON_NAME,,} || ${NETWORK_NAME,,} == ${CON_TYPE,,} ]] \
&& nmcli connection modify "${CON_UUID}" ${NETWORK[${NETWORK_ITEM}]}
systemctl restart NetworkManager.service
fi
done
done < <(nmcli -g device,uuid,name,type connection show)