diff --git a/mm-scripts.sh b/mm-scripts.sh index 61ee6d5..d50bd1c 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -848,6 +848,8 @@ SHOWSRVCUPDATES(){ MMSETUP(){ echo -e "${idsCL[Green]}Media Manager Setup Scripts${idsCL[Default]}" echo + echo -e "${idsCL[LightCyan]}Stopping system services ... ${idsCL[Default]}" + MMSTOP read -n 1 -p "Would you like to configure the hostname and network settings (y/N)?" choice case "$choice" in @@ -861,34 +863,34 @@ MMSETUP(){ REPIP=${REPIP/ /} echo -en "${idsCL[LightCyan]}IP Address [Current='${REPIP}']: ${idsCL[Default]}" read -e IPADDRESS - [ "${HOSTNAME}" == "" ] && IPADDRESS=${REPIP} + [ "${IPADDRESS}" == "" ] && 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} + [ "${SUBNET}" == "" ] && 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} + [ "${GATEWAY}" == "" ] && 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} + [ "${PRIDNS}" == "" ] && 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} + [ "${SECDNS}" == "" ] && 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]}Gateway IP : ${idsCL[Green]}${GATEWAY}${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 @@ -897,6 +899,8 @@ MMSETUP(){ [Nn]) MMSETUP; exit 0;; esac + echo -en "${idsCL[LightCyan]}Making configuration changes ... ${idsCL[Default]}" + 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 @@ -912,6 +916,11 @@ MMSETUP(){ sed -i "s/${REPGW}/${GATEWAY}/g" /etc/netplan/eth0.yaml + echo -e "${idsCL[Green]}Done${idsCL[Default]}" + echo + + [ `hostname` != ${HOSTNAME} ] || [ $REPIP != $IPADDRESS ] || [ $REPSUB != $NEWUB ] || [ $REPGW != $GATEWAY ] || [ $REPDNS != $DNS ] && NETCHNG=true || NETCHNG=false + ;; esac @@ -921,9 +930,6 @@ MMSETUP(){ read -n 1 -p "This will reset the config, do you wish to continue (y/N)?" choice case "$choice" in [Yy]) - echo - echo -e "${idsCL[LightCyan]}Stopping system services ... ${idsCL[Default]}" - MMSTOP echo echo -en "${idsCL[LightCyan]}Resetting config ... ${idsCL[Default]}" sed -i '/SERVICESCHECK/d' ${MMFOLDER}/settings.conf @@ -933,7 +939,6 @@ MMSETUP(){ sed -i '/^$/d' ${MMFOLDER}/settings.conf echo -e "${idsCL[Green]}Done${idsCL[Default]}" - if [ "${SERVICESCHECK}" != "" ]; then echo srvcs=${SERVICESCHECK/snap.tautulli.tautulli/tautulli} @@ -999,26 +1004,36 @@ MMSETUP(){ else echo "# PUSHOVER_USER_TOKEN=\"\"" >> ${MMFOLDER}/settings.conf fi - + + CNFG=true + + # cat ${MMFOLDER}/settings.conf + ;; + *) exit 0;; + esac + + if [ "${NETCHNG}" == "true" ] || [ "${CNFG}" == "true" ]; then + if [ "${NETCHNG}" == "true" ]; then + echo + read -n 1 -p "A reboot is recommended, would you like to reboot now (Y/n)?" choice + case "$choice" in + [Nn]) echo;; + * ) reboot;; + esac + else echo read -n 1 -p "Do you wish to start services now (y/N)?" choice echo case "$choice" in [Yy]) source /opt/idssys/mediamanager/settings.conf;IFS=,;SERVICES_CHECK=(${SERVICESCHECK});unset IFS;MMSTART start;; * ) echo -e "${idsCL[Cyan]}Not starting. To start, run the command '${idsCL[Green]}mm start${idsCL[LightCyan]}'${idsCL[Default]}";echo;echo;; - esac - echo -e "${idsCL[LightCyan]}The following are Media Manager (mm) usage commands:${idsCL[Default]}" - DIVIDER . lightGreen - USAGE + esac - # cat ${MMFOLDER}/settings.conf - ;; - *) exit 0;; - esac - - - # sed -e 's;%NIP%;${nip};g' ${MMFOLDER}/settings.conf > ${MMFOLDER}/settings.conf - + fi + echo -e "${idsCL[LightCyan]}The following are Media Manager (mm) usage commands:${idsCL[Default]}" + DIVIDER . lightGreen + USAGE + fi }