updated scripts
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
# ask to set static ip address
|
||||
read -r -p "Set Static IP address? <y/N> " prompt
|
||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]] ; then
|
||||
read -r -p "Enter Static IP Address with subnet prefix: " staticip
|
||||
read -r -p "Enter Gateway IP Address: " gatewayip
|
||||
read -r -p "Enter DNS IP Address (separated by commas): " dnsip
|
||||
# get adapter name
|
||||
name=$(basename /sys/class/net/e*)
|
||||
# backup original netplan yaml file
|
||||
mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak > /dev/null 2>&1
|
||||
rm /etc/netplan/01-network-manager-all.yaml > /dev/null 2>&1
|
||||
# create new netplan yaml file
|
||||
cat >> /etc/netplan/01-network-manager-all.yaml <<HERE
|
||||
|
||||
if [[ ! -d /etc/cloud ]]
|
||||
then
|
||||
read -r -p "Enter Static IP Address with subnet prefix: " staticip
|
||||
read -r -p "Enter Gateway IP Address: " gatewayip
|
||||
read -r -p "Enter DNS IP Address (separated by commas): " dnsip
|
||||
# get adapter name
|
||||
name=$(basename /sys/class/net/e*)
|
||||
# backup original netplan yaml file
|
||||
mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak > /dev/null 2>&1
|
||||
rm /etc/netplan/01-network-manager-all.yaml > /dev/null 2>&1
|
||||
# create new netplan yaml file
|
||||
cat >> /etc/netplan/01-network-manager-all.yaml <<HERE
|
||||
network:
|
||||
version: 2
|
||||
renderer: networkd
|
||||
@@ -22,8 +23,11 @@ network:
|
||||
addresses: [$dnsip]
|
||||
routes:
|
||||
- to: default
|
||||
via: $gatewayip
|
||||
via: $gatewayip
|
||||
HERE
|
||||
# apply netplan
|
||||
sudo netplan apply
|
||||
# apply netplan
|
||||
sudo netplan apply
|
||||
echo "Static IP set successfully."
|
||||
else
|
||||
echo "Static IP not set."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user