From e35de9080665621f5771138c6605431c8d6de225 Mon Sep 17 00:00:00 2001 From: Walter Date: Sun, 1 Nov 2015 10:57:25 -0500 Subject: [PATCH 1/3] Version checking should work now --- install.sh | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index 9aaffcf0dc..77e1280a50 100755 --- a/install.sh +++ b/install.sh @@ -1,9 +1,9 @@ #!/bin/bash ###################################################### -# Snipe-It Install Script # -# Script created by Mike Tucker # -# mtucker6784@gmail.com # +# Snipe-It Install Script # +# Script created by Mike Tucker # +# mtucker6784@gmail.com # # This script is just to help streamline the # # install process for Debian and CentOS # # based distributions. I assume you will be # @@ -16,7 +16,7 @@ # ensure running as root if [ "$(id -u)" != "0" ]; then - exec sudo "$0" "$@" + exec sudo "$0" "$@" fi #First things first, let's set some variables and find our distro. @@ -25,7 +25,6 @@ si="Snipe-IT" hostname="$(hostname)" fqdn="$(hostname --fqdn)" hosts=/etc/hosts -distro="$(cat /proc/version)" file=master.zip webdir=/var/www/html name="snipeit" @@ -33,6 +32,18 @@ tmp=/tmp/$name ans=default mkdir $tmp +# Lets find what distro we are using and what version +distro="$(cat /proc/version)" +if grep -q ubuntu <<<$distro; then + for f in $(find /etc -type f -maxdepth 1 \( ! -wholename /etc/os-release ! -wholename /etc/lsb-release -wholename /etc/\*release -o -wholename /etc/\*version \) 2> /dev/null); + do + distro="${f:5:${#f}-13}" + done; + if [ "$distro" = "centos" ] || [ "$distro" = "redhat" ]; then + distro+="$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release))" + fi +fi + echo " _____ _ __________ / ___/____ (_)___ ___ / _/_ __/ @@ -46,19 +57,23 @@ echo "" echo "" echo " Welcome to Snipe-IT Inventory Installer for Centos and Debian!" echo "" -#TODO add centos/redhat version checking to determine <6 or 7 + case $distro in *Ubuntu*|*Debian*) echo " The installer has detected Ubuntu/Debian as the OS." - distro=u + distro=debian ;; - *centos*) - echo " The installer has detected CentOS as the OS." - distro=c6 + *centos6*|*redhat6*) + echo " The installer has detected $distro $distVersion as the OS." + distro=redhat6 + ;; + *centos7*|*redhat7*) + echo " The installer has detected $distro $distVersion as the OS." + distro=redhat7 ;; *) echo " The installer was unable to determine your OS. Exiting for safety." - exit + exit ;; esac @@ -67,7 +82,7 @@ esac echo -n " Q. What is the FQDN of your server? ($fqdn): " read fqdn if [ -z "$fqdn" ]; then - fqdn="$(hostname --fqdn)" + fqdn="$(hostname --fqdn)" fi echo " Setting to $fqdn" echo "" @@ -129,7 +144,7 @@ chown root:root $passwordfile $creatstufffile chmod 700 $passwordfile $createstufffile case $distro in - u ) + debian) ##################################### Install for Debian/ubuntu ############################################## #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. @@ -199,7 +214,7 @@ case $distro in service apache2 restart ;; - c6 ) + redhat6 ) ##################################### Install for Centos/Redhat 6 ############################################## #Make directories so we can create a new apache vhost @@ -311,7 +326,7 @@ case $distro in service httpd restart ;; - c7 ) + redhat7 ) ##################################### Install for Centos/Redhat 7 ############################################## #Make directories so we can create a new apache vhost From 187ab53c1805d94c9f3d8b5825f983b7d0f0bcc6 Mon Sep 17 00:00:00 2001 From: Walter Date: Sun, 1 Nov 2015 11:03:02 -0500 Subject: [PATCH 2/3] centos > ubuntu :) --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 77e1280a50..d31155e6f0 100755 --- a/install.sh +++ b/install.sh @@ -34,7 +34,7 @@ mkdir $tmp # Lets find what distro we are using and what version distro="$(cat /proc/version)" -if grep -q ubuntu <<<$distro; then +if grep -q centos <<<$distro; then for f in $(find /etc -type f -maxdepth 1 \( ! -wholename /etc/os-release ! -wholename /etc/lsb-release -wholename /etc/\*release -o -wholename /etc/\*version \) 2> /dev/null); do distro="${f:5:${#f}-13}" From 9f12b6a084f15edc3b7c3b825f3a6b91022b0dff Mon Sep 17 00:00:00 2001 From: Walter Date: Sun, 1 Nov 2015 11:35:33 -0500 Subject: [PATCH 3/3] Should be read to merge! --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index d31155e6f0..330e49c145 100755 --- a/install.sh +++ b/install.sh @@ -140,8 +140,8 @@ echo " I recommend You delete this file for security purposes" echo "" #Let us make it so only root can read the file. Again, this isn't best practice, so please remove these after the install. -chown root:root $passwordfile $creatstufffile -chmod 700 $passwordfile $createstufffile +chown root:root $passwordfile $dbSetup +chmod 700 $passwordfile $dbSetup case $distro in debian) @@ -227,7 +227,7 @@ case $distro in echo >> $mariadbRepo "[mariadb]" echo >> $mariadbRepo "name = MariaDB" echo >> $mariadbRepo "baseurl = http://yum.mariadb.org/10.0/centos7-amd64" - echo >> $mariadbRepo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" + echo >> $mariadbRepo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaD6" echo >> $mariadbRepo "gpgcheck=1" echo >> $mariadbRepo "enable=1"