Update linupx-scripts.sh
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
action="$1"
|
||||
FOLDER='/opt/idssys/linupx'
|
||||
VERS='5.88-06242023'
|
||||
VERS='5.9-07162023'
|
||||
|
||||
if [ -d /opt/idssys/settings ]; then
|
||||
[ $(ls /opt/idssys/settings | wc -l) -eq 0 ] && rm -rf /opt/idssys/settings
|
||||
@@ -689,6 +689,85 @@ UPDATEREPOKEYS(){
|
||||
read -n 1 -s -p "Press any key to continue"
|
||||
}
|
||||
|
||||
RECONFIGURE_NETWORK(){
|
||||
echo -en "\n${idsCL[LightCyan]}Would you like to configure the hostname and network settings (y/N)? ${idsCL[Default]}"
|
||||
read choice
|
||||
case "$choice" in
|
||||
[Yy])
|
||||
echo
|
||||
echo -en "${idsCL[LightYellow]}Hostname [Current='${idsCL[White]}$(hostname)${idsCL[LightYellow]}']: ${idsCL[Default]}"
|
||||
read -e HOSTNAME
|
||||
[ "${HOSTNAME}" == "" ] && HOSTNAME=$(hostname)
|
||||
echo
|
||||
REPIP=`hostname -I`
|
||||
REPIP=${REPIP/ /}
|
||||
echo -en "${idsCL[LightYellow]}IP Address [Current='${idsCL[White]}${REPIP}${idsCL[LightYellow]}']: ${idsCL[Default]}"
|
||||
read -e IPADDRESS
|
||||
[ "${IPADDRESS}" == "" ] && IPADDRESS=${REPIP}
|
||||
echo
|
||||
REPSUB=`/sbin/ifconfig eth0 | awk '/netmask/{ print $4;} '`
|
||||
echo -en "${idsCL[LightYellow]}Subnet Mask [Current='${idsCL[White]}${REPSUB}${idsCL[LightYellow]}']: ${idsCL[Default]}"
|
||||
read -e SUBNET
|
||||
[ "${SUBNET}" == "" ] && SUBNET=${REPSUB}
|
||||
echo
|
||||
REPGW=`route -n | grep 'UG[ \t]' | awk '{print $2}'`
|
||||
echo -en "${idsCL[LightYellow]}Gateway IP [Current='${idsCL[White]}${REPGW}${idsCL[LightYellow]}']: ${idsCL[Default]}"
|
||||
read -e GATEWAY
|
||||
[ "${GATEWAY}" == "" ] && GATEWAY=${REPGW}
|
||||
echo
|
||||
REPPRIDNS=`resolvectl -i eth0 dns | awk '/eth0/{ print $4;} '`
|
||||
echo -en "${idsCL[LightYellow]}Primary DNS [Current='${idsCL[White]}${REPPRIDNS}${idsCL[LightYellow]}']: ${idsCL[Default]}"
|
||||
read -e PRIDNS
|
||||
[ "${PRIDNS}" == "" ] && PRIDNS=${REPPRIDNS}
|
||||
echo
|
||||
REPSECDNS=`resolvectl -i eth0 dns | awk '/eth0/{ print $5;} '`
|
||||
echo -en "${idsCL[LightYellow]}Secondary DNS (optional) [Current='${idsCL[White]}${REPSECDNS}${idsCL[LightYellow]}']: ${idsCL[Default]}"
|
||||
read -e SECDNS
|
||||
[ "${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]}${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
|
||||
echo -en "${idsCL[LightCyan]}Is this correct (Y/n)? ${idsCL[Default]}"
|
||||
read -n 1 choice
|
||||
case "$choice" in
|
||||
[Nn]) ;;
|
||||
*)
|
||||
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 >/dev/null 2>&1
|
||||
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 >/dev/null 2>&1
|
||||
sed -i "s/${REPIP}\/${REPSUB}/${IPADDRESS}\/${NEWSUB}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1
|
||||
|
||||
[ "${SECDNS}" != "" ] && DNS="${PRIDNS},${SECDNS}" || DNS="${PRIDNS}"
|
||||
[ "${REPSECDNS}" != "" ] && REPDNS="${REPPRIDNS},${REPSECDNS}" || REPDNS="${REPPRIDNS}"
|
||||
sed -i "s/${REPDNS}/${DNS}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1
|
||||
|
||||
sed -i "s/${REPGW}/${GATEWAY}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1
|
||||
|
||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||
echo
|
||||
|
||||
;;
|
||||
esac
|
||||
echo -e "\n${idsCL[Green]}Network has been updated${idsCL[Default]}]\n"
|
||||
read -n 1 -s -p "Press any key to continue"
|
||||
echo
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
SCRIPT_MENU() {
|
||||
if [ -f ${FOLDER}/lastrun ]; then
|
||||
LASTRUND=$(stat -c %y ${FOLDER}/lastrun | cut -d ' ' -f1)
|
||||
@@ -743,8 +822,9 @@ SCRIPT_MENU() {
|
||||
echo " [0] Enable/Disable Automatic Security Updates"
|
||||
echo ""
|
||||
fi
|
||||
echo " [K] Update/Fix Missing APT Repo Keys"
|
||||
echo " [I] Installation Scripts"
|
||||
echo " [K] Update/Fix Missing APT Repo Keys"
|
||||
echo " [N] Reconfigure Network"
|
||||
echo ""
|
||||
# echo " [L] Enable Remote Syslog"
|
||||
# echo " [Config file: RemoteSyslogServer=${RemoteSyslogServer}]"
|
||||
@@ -794,6 +874,8 @@ SCRIPT_MENU() {
|
||||
SCRIPT_MENU;;
|
||||
[Rr]) GO_REBOOT
|
||||
SCRIPT_MENU;;
|
||||
[Nn]) RECONFIGURE_NETWORK
|
||||
SCRIPT_MENU;;
|
||||
[Ss]) SHUTDOWN
|
||||
SCRIPT_MENU;;
|
||||
[Uu]) COPYCERTS_UPDATE
|
||||
|
||||
Reference in New Issue
Block a user