01-configserver.sh

Uit Brakwiki
Versie door Ben (Overleg | bijdragen) op 3 okt 2017 om 15:27
(wijz) ← Oudere versie | Huidige versie (wijz) | Nieuwere versie → (wijz)
Ga naar: navigatie, zoeken
#!/bin/bash
read -p "Enter New Hostname: " HN

if [ -z $HN ]; then
 echo "No hostname specified"
 exit 1
fi

CURRDOM="dom"
CURRHN="$(cat /etc/hostname)"
DOM=${HN:0:3}

sed -i "s/$CURRHN/$HN/g" /etc/hosts
sed -i "s/$CURRHN/$HN/g" /etc/hostname
sed -i "s/$CURRHN/$HN/g" /etc/mailname

sed -i "s/$CURRDOM/$DOM/g" /etc/hosts
sed -i "s/$CURRDOM/$DOM/g" /etc/mailname

echo "Set Hostname from:" $CURRHN " to:" $HN

#echo "Phase 3: Changing LVM Group name"

#NEWLVM="$HN""-vg"

#echo "Get current LVM Name"
#CURLVM="$(lvm vgdisplay | grep "VG Name" | awk '{print $NF}')"

#CURLVMDD="$(echo $CURLVM | sed "s/-/--/g")"
#NEWLVMDD="$(echo $NEWLVM | sed "s/-/--/g")"

#echo "Rename $CURLVM to $NEWLVM"
#lvm vgrename $CURLVM $NEWLVM
#sed -i "s/$CURLVMDD/$NEWLVMDD/g" /boot/grub/grub.cfg
#sed -i "s/$CURLVMDD/$NEWLVMDD/g" /etc/fstab

#VERS="$(uname -r)"
#echo "Reconfiguring Linux Image with version $VERS"
#dpkg-reconfigure "linux-image-$VERS"

sync
sync


read -p "Press any key to reboot... " -n1 -s
shutdown now -r