added network configuration

This commit is contained in:
Jonas Forsberg 2021-09-22 11:48:11 +02:00
parent cb7abf7c82
commit 1993f193c6
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
network.env
salt/pillars/local.sls

View File

@ -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"