From 735840aafd88fb54f1041590d0e887ea5ca3056e Mon Sep 17 00:00:00 2001 From: tiagom62 Date: Thu, 15 Mar 2018 13:20:42 -0400 Subject: [PATCH] Revert removing setting hostname (#5208) --- snipeit.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 1385c0560d..b876f9cb6a 100644 --- a/snipeit.sh +++ b/snipeit.sh @@ -28,7 +28,9 @@ clear name="snipeit" verbose="false" +hostname="$(hostname)" fqdn="$(hostname --fqdn)" +hosts=/etc/hosts spin[0]="-" spin[1]="\\" @@ -165,6 +167,11 @@ configureselinux () { fi } +sethostfile () { + echo "* Setting up hosts file." + echo >> $hosts "127.0.0.1 $hostname $fqdn" +} + if [[ -f /etc/lsb-release || -f /etc/debian_version ]]; then distro="$(lsb_release -s -i)" version="$(lsb_release -s -r)" @@ -220,8 +227,12 @@ case $distro in esac shopt -u nocasematch -echo "" -read -rsn1 -p " Press any key to continue..." +echo -n " Q. What is the FQDN of your server? ($fqdn): " +read -r fqdn +if [ -z "$fqdn" ]; then + fqdn="$(hostname --fqdn)" +fi +echo " Setting to $fqdn" echo "" ans=default @@ -271,6 +282,8 @@ case $distro in log "a2enmod rewrite" log "a2ensite $name.conf" + sethostfile + echo "* Securing MariaDB." /usr/bin/mysql_secure_installation @@ -309,6 +322,8 @@ case $distro in log "a2enmod rewrite" log "a2ensite $name.conf" + sethostfile + echo "* Securing MariaDB." /usr/bin/mysql_secure_installation @@ -351,6 +366,8 @@ case $distro in log "a2enmod rewrite" log "a2ensite $name.conf" + sethostfile + echo "* Starting MariaDB." log "service mysql start" @@ -392,6 +409,8 @@ case $distro in log "a2enmod rewrite" log "a2ensite $name.conf" + sethostfile + echo "* Starting MariaDB." log "service mysql start" @@ -443,6 +462,8 @@ case $distro in log "chkconfig mysql on" log "/sbin/service mysql start" + sethostfile + echo "* Securing MariaDB." /usr/bin/mysql_secure_installation @@ -478,6 +499,8 @@ case $distro in echo "* Configuring Apache." createvh + sethostfile + echo "* Setting MariaDB to start on boot and starting MariaDB." log "systemctl enable mariadb.service" log "systemctl start mariadb.service" @@ -514,6 +537,8 @@ case $distro in echo "* Configuring Apache." createvh + sethostfile + echo "* Setting MariaDB to start on boot and starting MariaDB." log "systemctl enable mariadb.service" log "systemctl start mariadb.service"