From 1993f193c6d0725382151f976dc321a8d88794de Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Wed, 22 Sep 2021 11:48:11 +0200 Subject: [PATCH] added network configuration --- .gitignore | 1 + update.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.gitignore b/.gitignore index 9cef971..ae123e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +network.env salt/pillars/local.sls diff --git a/update.sh b/update.sh index 5e922e4..c5f2b43 100755 --- a/update.sh +++ b/update.sh @@ -7,6 +7,7 @@ function printHelp(){ cat << EOF Usage ${0##*/} [options..] -h,-?, --help Show help and exit +-N, --network configure network settings -s, --salt run a masterless salt-call -y, --yes answer 'yes' on all questions EOF @@ -64,6 +65,25 @@ function do_salt_call(){ $salt state.apply pillar="{username: $USER}" } +function configure_network(){ + new_log "Configure network" + if asktobreak; then + return + fi + source network.env + sudo nmcli connection show + sudo nmcli connection modify "$INTERNAL_IF" ipv4.addresses "$INTERNAL_ADDRESS" + sudo nmcli connection modify "$INTERNAL_IF" ipv4.dns "127.0.0.1, 1.1.1.1, 1.1.1.2" + sudo nmcli connection modify "$INTERNAL_IF" ipv4.method manual + sudo nmcli connection down "$INTERNAL_IF" + sudo nmcli connection up "$INTERNAL_IF" + + sudo nmcli connection add type vlan con-name "$EXTERNAL_IF" ifname "$EXTERNAL_IF" dev "$INTERNAL_IF" id "${EXTERNAL_IF#*.}" + sudo nmcli connection modify "$EXTERNAL_IF" ipv4.method auto + sudo nmcli connection up "$EXTERNAL_IF" + + +} ######################### # @@ -74,6 +94,7 @@ function do_salt_call(){ #initialize all options ALL=true SALT=false +NETWORK=false ANSWER_YES=false while :; do @@ -86,6 +107,10 @@ while :; do SALT=true ALL=false ;; + -N|--network) + NETWORK=true + ALL=false + ;; -y|--yes) ANSWER_YES=true ;; @@ -107,6 +132,7 @@ for cmd in git salt-minion curl;do check_prerequisites "$cmd" done +[[ $ALL == true ]] || [[ $NETWORK == true ]] && configure_network [[ $ALL == true ]] || [[ $SALT == true ]] && do_salt_call printf "\n DONE!!!!!!!\n"