Update mm-scripts.sh
This commit is contained in:
@@ -848,6 +848,75 @@ SHOWSRVCUPDATES(){
|
||||
MMSETUP(){
|
||||
echo -e "${idsCL[Green]}Media Manager Setup Scripts${idsCL[Default]}"
|
||||
echo
|
||||
|
||||
read -n 1 -p "Would you like to configure the hostname and network settings (y/N)?" choice
|
||||
case "$choice" in
|
||||
[Yy])
|
||||
echo -en "${idsCL[LightCyan]}Hostname [Default='`hostname`']: ${idsCL[Default]}"
|
||||
read -e HOSTNAME
|
||||
[ "${HOSTNAME}" == "" ] && HOSTNAME=`hostname`
|
||||
echo
|
||||
REPIP=`hostname -I`
|
||||
REPIP=${REPIP/ /}
|
||||
echo -en "${idsCL[LightCyan]}IP Address [Current='${REPIP}']: ${idsCL[Default]}"
|
||||
read -e IPADDRESS
|
||||
[ "${HOSTNAME}" == "" ] && IPADDRESS=${REPIP}
|
||||
echo
|
||||
REPSUB=`/sbin/ifconfig eth0 | awk '/netmask/{ print $4;} '`
|
||||
echo -en "${idsCL[LightCyan]}Subnet Mask [Current='${REPSUB}']: ${idsCL[Default]}"
|
||||
read -e SUBNET
|
||||
[ "${HOSTNAME}" == "" ] && SUBNET=${REPSUB}
|
||||
echo
|
||||
REPGW=`route -n | grep 'UG[ \t]' | awk '{print $2}'`
|
||||
echo -en "${idsCL[LightCyan]}Gateway IP [Current='${REPGW}']: ${idsCL[Default]}"
|
||||
read -e GATEWAY
|
||||
[ "${HOSTNAME}" == "" ] && GATEWAY=${REPGW}
|
||||
echo
|
||||
REPPRIDNS=`resolvectl -i eth0 dns | awk '/eth0/{ print $4;} '`
|
||||
echo -en "${idsCL[LightCyan]}Primary DNS [Current='${REPPRIDNS}']: ${idsCL[Default]}"
|
||||
read -e PRIDNS
|
||||
[ "${HOSTNAME}" == "" ] && PRIDNS=${REPPRIDNS}
|
||||
echo
|
||||
REPSECDNS=`resolvectl -i eth0 dns | awk '/eth0/{ print $5;} '`
|
||||
echo -en "${idsCL[LightCyan]}Secondary DNS (optional) [Current='${REPSECDNS}']: ${idsCL[Default]}"
|
||||
read -e SECDNS
|
||||
[ "${HOSTNAME}" == "" ] && SECDNS=${REPSECDNS}
|
||||
echo
|
||||
echo
|
||||
echo "Confirm settings:"
|
||||
echo -e "${idsCL[LightCyan]}Hostname : ${idsCL[Green]}${HOSTNAME}${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightCyan]}IP Address : ${idsCL[Green]}${IPADDRESS}${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightCyan]}Subnet Mask : ${idsCL[Green]}${SUBNET}${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightCyan]}Gateway IP : ${idsCL[Green]}${SUBNET}${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightCyan]}Primary DNS : ${idsCL[Green]}${PRIDNS}${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightCyan]}Secondary DNS : ${idsCL[Green]}${SECDNS}${idsCL[Default]}"
|
||||
echo
|
||||
read -n 1 -p "Is this correct (Y/n)?" choice
|
||||
case "$choice" in
|
||||
[Nn]) MMSETUP; exit 0;;
|
||||
esac
|
||||
|
||||
sudo hostnamectl set-hostname ${HOSTNAME} >/dev/null 2>&1
|
||||
sudo sed -i '/127.0.1.1/d' /etc/hosts
|
||||
echo "127.0.1.1 ${HOSTNAME} mm" >> /etc/hosts
|
||||
|
||||
NEWSUB=`IPprefix_by_netmask ${SUBNET}`
|
||||
REPSUB=`IPprefix_by_netmask ${REPSUB}`
|
||||
sed -i "s/${REPIP}${REPSUB}/${IPADDRESS}${NEWSUB}/g" /etc/netplan/eth0.yaml
|
||||
sed -i "s/${REPIP}${REPSUB}/${IPADDRESS}${NEWSUB}/g" /etc/netplan/eth0.yaml
|
||||
|
||||
[ "${SECDNS}" != "" ] && DNS="${PRIDNS},${SECDNS}" || DNS="${PRIDNS}"
|
||||
[ "${REPSECDNS}" != "" ] && REPDNS="${REPPRIDNS},${REPSECDNS}" || REPDNS="${REPPRIDNS}"
|
||||
sed -i "s/${REPDNS}/${DNS}/g" /etc/netplan/eth0.yaml
|
||||
|
||||
sed -i "s/${REPGW}/${GATEWAY}/g" /etc/netplan/eth0.yaml
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
read -n 1 -p "This will reset the config, do you wish to continue (y/N)?" choice
|
||||
case "$choice" in
|
||||
[Yy])
|
||||
|
||||
Reference in New Issue
Block a user