From 40ca02481dcd472269ace493d4a9833ed767db82 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 20:54:49 -0400 Subject: [PATCH 01/32] Working on formatting Added a banner and made the formatting a little easier to follow --- install.sh | 121 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 45 deletions(-) diff --git a/install.sh b/install.sh index 1deeac96e6..4b3635caca 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash ###################################################### # Snipe-It Install Script # @@ -24,49 +24,65 @@ file=master.zip dir=/var/www/snipe-it-master ans=default + +echo " + _____ _ __________ + / ___/____ (_)___ ___ / _/_ __/ + \__ \/ __ \/ / __ \/ _ \______ / / / / + ___/ / / / / / /_/ / __/_____// / / / + /____/_/ /_/_/ .___/\___/ /___/ /_/ + /_/ +" + +echo "" +echo "" +echo " Welcome to Snipe-IT Inventory Installer for Centos and Debian!" +echo "" +echo $distro case $distro in *Ubuntu*|*Debian*) - echo "Ubuntu/Debian detected. Carry forth." + echo " The installer has detected Ubuntu/Debian as the OS detected." distro=u ;; *centos*) - echo "CentOS detected. Carry forth." + echo " The installer has detected CentOS as the OS." distro=c ;; *) - echo "Not sure of this OS. Exiting for safety." + echo " The installer was unable to determine your OS. Exiting for safety." exit ;; esac #Get your FQDN. echo "" -echo "$si install script - Installing $ans" -echo "Q. What is the FQDN of your server? (example: www.yourserver.com)" +echo " $si install script - Installing $ans" +echo -n " Q. What is the FQDN of your server? (example: www.yourserver.com): " read fqdn echo "" #Do you want to set your own passwords, or have me generate random ones? ans=default until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do -echo "Q. Do you want me to automatically create the MySQL root & user passwords? (y/n)" +echo -n " Q. Do you want me to automatically create the MySQL root & user passwords? (y/n) " read setpw case $setpw in [yY] | [yY][Ee][Ss] ) mysqlrootpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" - echo "I'm putting this into /root/mysqlpasswords ... PLEASE REMOVE that file after you have recorded the passwords somewhere safe!" + echo " I'm putting this into /root/mysqlpasswords ... " + echo " PLEASE REMOVE that file after you have recorded the passwords somewhere safe!" ans="yes" ;; [nN] | [n|N][O|o] ) - echo "Q. What do you want your root PW to be?" - read mysqlrootpw - echo "Q. What do you want your snipeit user PW to be?" - read mysqluserpw + echo -n " Q. What do you want your root PW to be?" + read -s mysqlrootpw + echo -n " Q. What do you want your snipeit user PW to be?" + read -s mysqluserpw ans="no" ;; - *) echo "Invalid answer. Please type y or n" + *) echo " Invalid answer. Please type y or n" ;; esac done @@ -85,10 +101,16 @@ echo >> $passwordfile "MySQL Passwords..." echo >> $passwordfile "Root: $mysqlrootpw" echo >> $passwordfile "User (snipeit): $mysqluserpw" echo >> $passwordfile "32 bit random string: $random32" -echo "MySQL ROOT password: $mysqlrootpw" -echo "MySQL USER (snipeit) password: $mysqluserpw" -echo "32 bit random string: $random32" -echo "These passwords have been exported to /root/mysqlpasswords.txt...I recommend You delete this file for security purposes" + +echo " ************************************************************" +echo " * MySQL ROOT password: $mysqlrootpw *" +echo " * MySQL USER (snipeit) password: $mysqluserpw *" +echo " * 32 bit random string: $random32 *" +echo " ************************************************************" +echo "" +echo " These passwords have been exported to /root/mysqlpasswords.txt..." +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 @@ -107,7 +129,7 @@ if [[ $distro == "u" ]]; then sudo apt-get install -y php5 php5-mcrypt php5-curl php5-mysql php5-gd #Create MySQL accounts - echo "Create MySQL accounts" + echo "## Create MySQL accounts" sudo mysqladmin -u root password $mysqlrootpw sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql @@ -138,7 +160,7 @@ if [[ $distro == "u" ]]; then sudo chmod -R 755 $dir/app/private_uploads sudo chmod -R 755 $dir/public/uploads sudo chown -R www-data:www-data /var/www/ - echo "Finished permission changes." + echo "## Finished permission changes." #Modify the Snipe-It files necessary for a production environment. replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php @@ -162,14 +184,10 @@ if [[ $distro == "u" ]]; then service apache2 restart else +##################################### Install for Centos/Redhat ############################################## #Make directories so we can create a new apache vhost - sudo mkdir /etc/httpd/ - sudo mkdir /etc/httpd/sites-available/ - sudo mkdir /etc/httpd/sites-enabled/ - apachefile=/etc/httpd/sites-available/$fqdn.conf - apachefileen=/etc/httpd/sites-enabled/$fqdn.conf - apachecfg=/etc/httpd/conf/httpd.conf + apachefile=/etc/httpd/conf.d/snipe-it.conf #Allow us to get the mysql engine sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm @@ -181,12 +199,14 @@ else sudo /sbin/service mysqld start #Create MySQL accounts - echo "Create MySQL accounts" - sudo mysqladmin -u root password $mysqlrootpw + echo "## Create MySQL accounts" + mysqladmin -u root password $mysqlrootpw echo "" - echo "***Your Current ROOT password is---> $mysqlrootpw" - echo "***Use $mysqlrootpw at the following prompt for root login***" - sudo /usr/bin/mysql_secure_installation + echo " ***Your Current ROOT password is---> $mysqlrootpw" + echo " ***Use $mysqlrootpw at the following prompt for root login***" + echo "" + + /usr/bin/mysql_secure_installation #Install PHP stuff. sudo yum -y install php php-mysql php-bcmath.x86_64 php-cli.x86_64 php-common.x86_64 php-embedded.x86_64 php-gd.x86_64 php-mbstring @@ -209,6 +229,8 @@ else echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" echo >> $apachefile " CustomLog /var/log/access.log combined" echo >> $apachefile "" + + echo "## Setup hosts file."; echo >> $hosts "127.0.0.1 $hostname $fqdn" sudo ln -s $apachefile $apachefileen @@ -251,39 +273,48 @@ else service httpd restart fi -echo ""; echo ""; echo "" -echo "***I have no idea about your mail environment, so if you want email capability, open up the following***" -echo "nano -w $dir/app/config/production/mail.php" -echo "And edit the attributes appropriately." +echo "" +echo "" +echo "" +echo " ***I have no idea about your mail environment, so if you want email capability, open up the following***" +echo " nano -w $dir/app/config/production/mail.php" +echo " And edit the attributes appropriately." +echo "" +echo "" sleep 1 -echo "";echo "";echo "" +echo "" + ans=default until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do -echo "Q. Shall I delete the password files I created? (Remember to record the passwords before deleting) (y/n)" +echo " Q. Shall I delete the password files I created? (Remember to record the passwords before deleting) (y/n)" read setpw case $setpw in [yY] | [yY][Ee][Ss] ) rm $createstufffile rm $passwordfile - echo "$createstufffile and $passwordfile files have been removed." + echo " $createstufffile and $passwordfile files have been removed." ans=yes ;; [nN] | [n|N][O|o] ) - echo "Ok, I won't remove the file. Please for the love of security, record the passwords and delete this file regardless." - echo "$si cannot be held responsible if this file is compromised!" - echo "From Snipe: I cannot encourage or even facilitate poor security practices, and still sleep the few, frantic hours I sleep at night." + echo " Ok, I won't remove the file. Please for the love of security, record the passwords and delete this file regardless." + echo " $si cannot be held responsible if this file is compromised!" + echo " From Snipe: I cannot encourage or even facilitate poor security practices, and still sleep the few, frantic hours I sleep at night." ans=no ;; *) - echo "Please select a valid option" + echo " Please select a valid option" ;; esac done -echo ""; echo "" -echo "***If you want mail capabilities, open $dir/app/config/production/mail.php and fill out the attributes***" -echo ""; echo "" -echo "***$si should now be installed. open up http://$fqdn in a web browser to verify.***" +echo "" +echo "" +echo " ***If you want mail capabilities, open $dir/app/config/production/mail.php and fill out the attributes***" +echo "" +echo "" +echo " ***$si should now be installed. open up http://$fqdn in a web browser to verify.***" +echo "" +echo "" sleep 1 From 346090ebff8d2ed50d13e3f7e827d72763fc0e83 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 21:51:44 -0400 Subject: [PATCH 02/32] removing un-needed echo --- install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install.sh b/install.sh index 4b3635caca..740c0c483d 100755 --- a/install.sh +++ b/install.sh @@ -38,7 +38,6 @@ echo "" echo "" echo " Welcome to Snipe-IT Inventory Installer for Centos and Debian!" echo "" -echo $distro case $distro in *Ubuntu*|*Debian*) echo " The installer has detected Ubuntu/Debian as the OS detected." From 21cc1e9aec6039d1d99f3df79c6be77f290a08dc Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 22:04:28 -0400 Subject: [PATCH 03/32] more formatting --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 740c0c483d..d995541f15 100755 --- a/install.sh +++ b/install.sh @@ -56,6 +56,7 @@ esac #Get your FQDN. echo "" echo " $si install script - Installing $ans" +echo "" echo -n " Q. What is the FQDN of your server? (example: www.yourserver.com): " read fqdn echo "" From d1e977b85a0f7d73b11d9887bcd90837280fcbfe Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 22:10:56 -0400 Subject: [PATCH 04/32] force sudo --- install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install.sh b/install.sh index d995541f15..167efc5c0a 100755 --- a/install.sh +++ b/install.sh @@ -15,6 +15,11 @@ ###################################################### #First things first, let's set some variables and find our distro. +# ensure running as root +if [ "$(id -u)" != "0" ]; then + exec sudo "$0" "$@" +fi + clear si="Snipe-IT" hostname="$(hostname)" From 760e2fca01110671667633a65d6fa66c84dbcaef Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 22:31:45 -0400 Subject: [PATCH 05/32] Changed from if/else to case statement I changed the if/else statement to a case statement so that we can do multiple os/versions. Also added the working code for CentOS 7 that I will backport to CentOS 6. Need to add OS version detection. --- install.sh | 378 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 244 insertions(+), 134 deletions(-) diff --git a/install.sh b/install.sh index 167efc5c0a..468fd6db25 100755 --- a/install.sh +++ b/install.sh @@ -26,8 +26,10 @@ hostname="$(hostname)" hosts=/etc/hosts distro="$(cat /proc/version)" file=master.zip +#TODO replace dir with webdir and name dir=/var/www/snipe-it-master - +webdir=/var/www/html +name="snipeit" ans=default echo " @@ -43,6 +45,7 @@ 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 detected." @@ -50,7 +53,7 @@ case $distro in ;; *centos*) echo " The installer has detected CentOS as the OS." - distro=c + distro=c6 ;; *) echo " The installer was unable to determine your OS. Exiting for safety." @@ -122,161 +125,268 @@ chown root:root $passwordfile $creatstufffile chmod 700 $passwordfile $createstufffile if [[ $distro == "u" ]]; then -#Update/upgrade Debian/Ubuntu repositories, get the latest version of git. - apachefile=/etc/apache2/sites-available/$fqdn.conf - sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip +case $distro in + [u] ) + ##################################### Install for Debian/ubuntu ############################################## - wget https://github.com/snipe/snipe-it/archive/$file - sudo unzip $file -d /var/www/ + #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. + apachefile=/etc/apache2/sites-available/$fqdn.conf + sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip - #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ - sudo apt-get install -y php5 php5-mcrypt php5-curl php5-mysql php5-gd + wget https://github.com/snipe/snipe-it/archive/$file + sudo unzip $file -d /var/www/ - #Create MySQL accounts - echo "## Create MySQL accounts" - sudo mysqladmin -u root password $mysqlrootpw - sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql + #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ + sudo apt-get install -y php5 php5-mcrypt php5-curl php5-mysql php5-gd - #Enable mcrypt and rewrite - sudo php5enmod mcrypt - sudo a2enmod rewrite - sudo ls -al /etc/apache2/mods-enabled/rewrite.load + #Create MySQL accounts + echo "## Create MySQL accounts" + sudo mysqladmin -u root password $mysqlrootpw + sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql - #Create a new virtual host for Apache. - echo >> $apachefile "" - echo >> $apachefile "" - echo >> $apachefile "" - echo >> $apachefile "ServerAdmin webmaster@localhost" - echo >> $apachefile " " - echo >> $apachefile " Require all granted" - echo >> $apachefile " AllowOverride All" - echo >> $apachefile " " - echo >> $apachefile " DocumentRoot $dir/public" - echo >> $apachefile " ServerName $fqdn" - echo >> $apachefile " ErrorLog "\${APACHE_LOG_DIR}"/error.log" - echo >> $apachefile " CustomLog "\${APACHE_LOG_DIR}"/access.log combined" - echo >> $apachefile "" - echo >> $hosts "127.0.0.1 $hostname $fqdn" - a2ensite $fqdn.conf + #Enable mcrypt and rewrite + sudo php5enmod mcrypt + sudo a2enmod rewrite + sudo ls -al /etc/apache2/mods-enabled/rewrite.load - #Change permissions on directories - sudo chmod -R 755 $dir/app/storage - sudo chmod -R 755 $dir/app/private_uploads - sudo chmod -R 755 $dir/public/uploads - sudo chown -R www-data:www-data /var/www/ - echo "## Finished permission changes." + #Create a new virtual host for Apache. + echo >> $apachefile "" + echo >> $apachefile "" + echo >> $apachefile "" + echo >> $apachefile "ServerAdmin webmaster@localhost" + echo >> $apachefile " " + echo >> $apachefile " Require all granted" + echo >> $apachefile " AllowOverride All" + echo >> $apachefile " " + echo >> $apachefile " DocumentRoot $dir/public" + echo >> $apachefile " ServerName $fqdn" + echo >> $apachefile " ErrorLog "\${APACHE_LOG_DIR}"/error.log" + echo >> $apachefile " CustomLog "\${APACHE_LOG_DIR}"/access.log combined" + echo >> $apachefile "" + echo >> $hosts "127.0.0.1 $hostname $fqdn" + a2ensite $fqdn.conf - #Modify the Snipe-It files necessary for a production environment. - replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php - cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $dir/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php - cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php - replace "'false'," "true," -- $dir/app/config/production/app.php - cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php + #Change permissions on directories + sudo chmod -R 755 $dir/app/storage + sudo chmod -R 755 $dir/app/private_uploads + sudo chmod -R 755 $dir/public/uploads + sudo chown -R www-data:www-data /var/www/ + echo "## Finished permission changes." - #Install / configure composer - curl -sS https://getcomposer.org/installer | php - mv composer.phar /usr/local/bin/composer - cd $dir/ - composer install --no-dev --prefer-source - php artisan app:install --env=production + #Modify the Snipe-It files necessary for a production environment. + replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php + cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php + replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php + replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php + replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $dir/app/config/production/database.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php + cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php + replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php + replace "'false'," "true," -- $dir/app/config/production/app.php + cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php - service apache2 restart -else -##################################### Install for Centos/Redhat ############################################## + #Install / configure composer + curl -sS https://getcomposer.org/installer | php + mv composer.phar /usr/local/bin/composer + cd $dir/ + composer install --no-dev --prefer-source + php artisan app:install --env=production - #Make directories so we can create a new apache vhost - apachefile=/etc/httpd/conf.d/snipe-it.conf + service apache2 restart + ;; - #Allow us to get the mysql engine - sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm - sudo yum -y install httpd mysql-server wget git unzip + [c6] ) + ##################################### Install for Centos/Redhat 6 ############################################## - wget https://github.com/snipe/snipe-it/archive/$file - sudo unzip $file -d /var/www/ + #Make directories so we can create a new apache vhost + apachefile=/etc/httpd/conf.d/snipe-it.conf - sudo /sbin/service mysqld start + #Allow us to get the mysql engine + sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm + sudo yum -y install httpd mysql-server wget git unzip - #Create MySQL accounts - echo "## Create MySQL accounts" - mysqladmin -u root password $mysqlrootpw - echo "" - echo " ***Your Current ROOT password is---> $mysqlrootpw" - echo " ***Use $mysqlrootpw at the following prompt for root login***" - echo "" - - /usr/bin/mysql_secure_installation + wget https://github.com/snipe/snipe-it/archive/$file + sudo unzip $file -d /var/www/ - #Install PHP stuff. - sudo yum -y install php php-mysql php-bcmath.x86_64 php-cli.x86_64 php-common.x86_64 php-embedded.x86_64 php-gd.x86_64 php-mbstring - wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm - rpm -ivh epel-release-7-5.noarch.rpm - yum install -y --enablerepo="epel" php-mcrypt + sudo /sbin/service mysqld start - #Create the new virtual host in Apache. - echo >> $apachefile "" - echo >> $apachefile "" - echo >> $apachefile "" - echo >> $apachefile "ServerAdmin webmaster@localhost" - echo >> $apachefile " " - echo >> $apachefile " Require all granted" - echo >> $apachefile " AllowOverride All" - echo >> $apachefile " Options +Indexes" - echo >> $apachefile " " - echo >> $apachefile " DocumentRoot $dir/public" - echo >> $apachefile " ServerName $fqdn" - echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" - echo >> $apachefile " CustomLog /var/log/access.log combined" - echo >> $apachefile "" - - echo "## Setup hosts file."; - echo >> $hosts "127.0.0.1 $hostname $fqdn" - sudo ln -s $apachefile $apachefileen + #Create MySQL accounts + echo "## Create MySQL accounts" + mysqladmin -u root password $mysqlrootpw + echo "" + echo " ***Your Current ROOT password is---> $mysqlrootpw" + echo " ***Use $mysqlrootpw at the following prompt for root login***" + echo "" + + /usr/bin/mysql_secure_installation - #Enable rewrite and vhost - echo >> $apachecfg "LoadModule rewrite_module modules/mod_rewrite.so" - echo >> $apachecfg "IncludeOptional sites-enabled/*.conf" + #Install PHP stuff. + sudo yum -y install php php-mysql php-bcmath.x86_64 php-cli.x86_64 php-common.x86_64 php-embedded.x86_64 php-gd.x86_64 php-mbstring + wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm + rpm -ivh epel-release-7-5.noarch.rpm + yum install -y --enablerepo="epel" php-mcrypt - #Change permissions on directories - sudo chmod -R 755 $dir/app/storage - sudo chmod -R 755 $dir/app/private_uploads - sudo chmod -R 755 $dir/public/uploads - sudo chown -R apache:apache /var/www/ + #Create the new virtual host in Apache. + echo >> $apachefile "" + echo >> $apachefile "" + echo >> $apachefile "" + echo >> $apachefile "ServerAdmin webmaster@localhost" + echo >> $apachefile " " + echo >> $apachefile " Require all granted" + echo >> $apachefile " AllowOverride All" + echo >> $apachefile " Options +Indexes" + echo >> $apachefile " " + echo >> $apachefile " DocumentRoot $dir/public" + echo >> $apachefile " ServerName $fqdn" + echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" + echo >> $apachefile " CustomLog /var/log/access.log combined" + echo >> $apachefile "" + + echo "## Setup hosts file."; + echo >> $hosts "127.0.0.1 $hostname $fqdn" + sudo ln -s $apachefile $apachefileen - service httpd restart + #Enable rewrite and vhost + echo >> $apachecfg "LoadModule rewrite_module modules/mod_rewrite.so" + echo >> $apachecfg "IncludeOptional sites-enabled/*.conf" - #Modify the Snipe-It files necessary for a production environment. - replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php - cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $dir/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php - cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php - cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php + #Change permissions on directories + sudo chmod -R 755 $dir/app/storage + sudo chmod -R 755 $dir/app/private_uploads + sudo chmod -R 755 $dir/public/uploads + sudo chown -R apache:apache /var/www/ - #Install / configure composer - cd $dir - sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql - curl -sS https://getcomposer.org/installer | php - php composer.phar install --no-dev --prefer-source - php artisan app:install --env=production + service httpd restart - #Add SELinux and firewall exception/rules. You'll have to allow 443 if you want ssl connectivity. - chcon -R -h -t httpd_sys_script_rw_t $dir/ - firewall-cmd --zone=public --add-port=80/tcp --permanent - firewall-cmd --reload + #Modify the Snipe-It files necessary for a production environment. + replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php + cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php + replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php + replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php + replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $dir/app/config/production/database.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php + cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php + replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php + cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php - service httpd restart -fi + #Install / configure composer + cd $dir + sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql + curl -sS https://getcomposer.org/installer | php + php composer.phar install --no-dev --prefer-source + php artisan app:install --env=production + + #Add SELinux and firewall exception/rules. You'll have to allow 443 if you want ssl connectivity. + chcon -R -h -t httpd_sys_script_rw_t $dir/ + firewall-cmd --zone=public --add-port=80/tcp --permanent + firewall-cmd --reload + + service httpd restart + ;; + + [c7] + ##################################### Install for Centos/Redhat 7 ############################################## + + #Make directories so we can create a new apache vhost + apachefile=/etc/httpd/conf.d/snipe-it.conf + + #Allow us to get the mysql engine + echo "## Add IUS repo and install mariaDB and a few other packages."; + rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm > /dev/null + yum -y install httpd mariadb-server wget git unzip epel-release > /dev/null + + echo "## Download Snipe-IT from githut and put it in the web directory."; + + wget https://github.com/snipe/snipe-it/archive/$file &> /dev/null + unzip -qo master.zip -d /tmp/ + cp -Rv /tmp/snipe-it-master $webdir/$name + + #Change permissions on directories + sudo chmod -R 755 $webdir/$name/app/storage + sudo chmod -R 755 $webdir/$name/app/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R apache:apache $webdir/$name + + echo "## Start the mariaDB server."; + #/sbin/service mysqld start + systemctl enable mariadb.service + systemctl restart mariadb.service + + #Create MySQL accounts + echo "## Create MySQL accounts" + mysqladmin -u root password $mysqlrootpw + echo "" + echo " ***Your Current ROOT password is---> $mysqlrootpw" + echo " ***Use $mysqlrootpw at the following prompt for root login***" + echo "" + + /usr/bin/mysql_secure_installation + + #Install PHP stuff. + echo "## Install PHP Stuff"; + PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" + + yum -y install $PACKAGES > /dev/null + rpm --query --queryformat " " $PACKAGES + + #Create the new virtual host in Apache and enable rewrite + echo "## Create the new virtual host in Apache."; + + echo >> $apachefile "" + echo >> $apachefile "" + echo >> $apachefile "LoadModule rewrite_module modules/mod_rewrite.so" + echo >> $apachefile "" + echo >> $apachefile "" + echo >> $apachefile "ServerAdmin webmaster@localhost" + echo >> $apachefile " " + echo >> $apachefile " Require all granted" + echo >> $apachefile " AllowOverride All" + echo >> $apachefile " Options +Indexes" + echo >> $apachefile " " + echo >> $apachefile " DocumentRoot $webdir/$name/public" + echo >> $apachefile " ServerName $fqdn" + echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" + echo >> $apachefile " CustomLog /var/log/access.log combined" + echo >> $apachefile "" + + echo "## Setup hosts file."; + echo >> $hosts "127.0.0.1 $hostname $fqdn" + + systemctl enable httpd.service + systemctl restart httpd.service + # /sbin/service httpd restart + + #Modify the Snipe-It files necessary for a production environment. + replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php + replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php + replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php + replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php + cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php + cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + + #Install / configure composer + cd $webdir/$name + sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql + curl -sS https://getcomposer.org/installer | php + php composer.phar install --no-dev --prefer-source + php artisan app:install --env=production + + #Add SELinux and firewall exception/rules. You'll have to allow 443 if you want ssl connectivity. + # chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ + # firewall-cmd --zone=public --add-port=80/tcp --permanent + # firewall-cmd --reload + + systemctl restart httpd.service + # service httpd restart + ;; +esac echo "" echo "" From 34530b209f8215cd3d31552de685fe1577a3bee1 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 22:54:26 -0400 Subject: [PATCH 06/32] working on case statement --- install.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 468fd6db25..a364493ec2 100755 --- a/install.sh +++ b/install.sh @@ -124,9 +124,8 @@ echo "" chown root:root $passwordfile $creatstufffile chmod 700 $passwordfile $createstufffile -if [[ $distro == "u" ]]; then case $distro in - [u] ) + u ) ##################################### Install for Debian/ubuntu ############################################## #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. @@ -196,8 +195,7 @@ case $distro in service apache2 restart ;; - - [c6] ) + c6 ) ##################################### Install for Centos/Redhat 6 ############################################## #Make directories so we can create a new apache vhost @@ -286,8 +284,7 @@ case $distro in service httpd restart ;; - - [c7] + c7 ) ##################################### Install for Centos/Redhat 7 ############################################## #Make directories so we can create a new apache vhost @@ -378,7 +375,7 @@ case $distro in php composer.phar install --no-dev --prefer-source php artisan app:install --env=production - #Add SELinux and firewall exception/rules. You'll have to allow 443 if you want ssl connectivity. + #Add SELinux and firewall exception/rules. Youll have to allow 443 if you want ssl connectivity. # chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ # firewall-cmd --zone=public --add-port=80/tcp --permanent # firewall-cmd --reload From da17603be19df0d8bf1dbfd238c9f0e61cbbf239 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 29 Oct 2015 23:41:22 -0400 Subject: [PATCH 07/32] use tmp dir and set mariadb root pass use /tmp/snipeit for working with files and clean that up at the end. also use mysql_secure_installation to set the root password instead of setting it and making the user input it again. --- install.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index a364493ec2..b00833b9bb 100755 --- a/install.sh +++ b/install.sh @@ -132,7 +132,7 @@ case $distro in apachefile=/etc/apache2/sites-available/$fqdn.conf sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip - wget https://github.com/snipe/snipe-it/archive/$file + wget -P /tmp/snipeit/ https://github.com/snipe/snipe-it/archive/$file sudo unzip $file -d /var/www/ #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. @@ -298,10 +298,10 @@ case $distro in echo "## Download Snipe-IT from githut and put it in the web directory."; wget https://github.com/snipe/snipe-it/archive/$file &> /dev/null - unzip -qo master.zip -d /tmp/ - cp -Rv /tmp/snipe-it-master $webdir/$name + unzip -qo master.zip -d /tmp/snipeit/ + cp -R /tmp/snipeit/snipe-it-master $webdir/$name - #Change permissions on directories + # Change permissions on directories sudo chmod -R 755 $webdir/$name/app/storage sudo chmod -R 755 $webdir/$name/app/private_uploads sudo chmod -R 755 $webdir/$name/public/uploads @@ -309,19 +309,22 @@ case $distro in echo "## Start the mariaDB server."; #/sbin/service mysqld start + # Makde mariaDB start on boot and restart the daemon systemctl enable mariadb.service systemctl restart mariadb.service - #Create MySQL accounts - echo "## Create MySQL accounts" - mysqladmin -u root password $mysqlrootpw - echo "" - echo " ***Your Current ROOT password is---> $mysqlrootpw" - echo " ***Use $mysqlrootpw at the following prompt for root login***" - echo "" - + # Have user set own root password when securing install + # and just set the snipeit database user at the beginning /usr/bin/mysql_secure_installation + #Create MySQL accounts + # echo "## Create MySQL accounts" + # mysqladmin -u root password $mysqlrootpw + # echo "" + # echo " ***Your Current ROOT password is---> $mysqlrootpw" + # echo " ***Use $mysqlrootpw at the following prompt for root login***" + # echo "" + #Install PHP stuff. echo "## Install PHP Stuff"; PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" @@ -352,9 +355,9 @@ case $distro in echo "## Setup hosts file."; echo >> $hosts "127.0.0.1 $hostname $fqdn" + # Make apache start on boot and restart the daemon systemctl enable httpd.service systemctl restart httpd.service - # /sbin/service httpd restart #Modify the Snipe-It files necessary for a production environment. replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php @@ -375,13 +378,13 @@ case $distro in php composer.phar install --no-dev --prefer-source php artisan app:install --env=production +#TODO detect if SELinux and firewall are enabled to decide what to do #Add SELinux and firewall exception/rules. Youll have to allow 443 if you want ssl connectivity. # chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ # firewall-cmd --zone=public --add-port=80/tcp --permanent # firewall-cmd --reload systemctl restart httpd.service - # service httpd restart ;; esac @@ -429,4 +432,7 @@ echo "" echo " ***$si should now be installed. open up http://$fqdn in a web browser to verify.***" echo "" echo "" +echo "## Cleaning up..." +rm -rf /tmp/snipeit/ +echo "## Done!" sleep 1 From 7e6d142c1ff43f5d545c3a9271a6dabfe6ee48b1 Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 30 Oct 2015 00:00:07 -0400 Subject: [PATCH 08/32] Moving more stuff to the tmp dir --- install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index b00833b9bb..a8eae35a49 100755 --- a/install.sh +++ b/install.sh @@ -79,7 +79,7 @@ case $setpw in [yY] | [yY][Ee][Ss] ) mysqlrootpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" - echo " I'm putting this into /root/mysqlpasswords ... " + echo " I'm putting this into /tmp/snipeit/mysqlpasswords ... " echo " PLEASE REMOVE that file after you have recorded the passwords somewhere safe!" ans="yes" ;; @@ -100,8 +100,8 @@ random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)" #createstuff.sql will be injected to the database during install. mysqlpasswords.txt is a file that will contain the root and snipeit user passwords. #Again, this file should be removed, which will be a prompt at the end of the script. -createstufffile=/root/createstuff.sql -passwordfile=/root/mysqlpasswords.txt +createstufffile=/tmp/snipeit/createstuff.sql +passwordfile=/tmp/snipeit/mysqlpasswords.txt echo >> $createstufffile "CREATE DATABASE snipeit;" echo >> $createstufffile "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" @@ -116,7 +116,7 @@ echo " * MySQL USER (snipeit) password: $mysqluserpw *" echo " * 32 bit random string: $random32 *" echo " ************************************************************" echo "" -echo " These passwords have been exported to /root/mysqlpasswords.txt..." +echo " These passwords have been exported to /tmp/snipeit/mysqlpasswords.txt..." echo " I recommend You delete this file for security purposes" echo "" @@ -142,7 +142,7 @@ case $distro in #Create MySQL accounts echo "## Create MySQL accounts" sudo mysqladmin -u root password $mysqlrootpw - sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql + sudo mysql -u root -p$mysqlrootpw < /tmp/snipeit/createstuff.sql #Enable mcrypt and rewrite sudo php5enmod mcrypt @@ -272,7 +272,7 @@ case $distro in #Install / configure composer cd $dir - sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql + sudo mysql -u root -p$mysqlrootpw < /tmp/snipeit/createstuff.sql curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production @@ -373,7 +373,7 @@ case $distro in #Install / configure composer cd $webdir/$name - sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql + mysql -u root -p < /tmp/snipeit/createstuff.sql curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production From 800100c0cc6e4e6c87005e5ee591b36242738020 Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 30 Oct 2015 21:26:59 -0400 Subject: [PATCH 09/32] working on centos 6 switch case --- install.sh | 241 ++++++++++++++++++++++++++--------------------------- 1 file changed, 119 insertions(+), 122 deletions(-) diff --git a/install.sh b/install.sh index a8eae35a49..9aaffcf0dc 100755 --- a/install.sh +++ b/install.sh @@ -14,23 +14,24 @@ # credit where it's due. Thanks! # ###################################################### -#First things first, let's set some variables and find our distro. # ensure running as root if [ "$(id -u)" != "0" ]; then exec sudo "$0" "$@" fi +#First things first, let's set some variables and find our distro. clear si="Snipe-IT" hostname="$(hostname)" +fqdn="$(hostname --fqdn)" hosts=/etc/hosts distro="$(cat /proc/version)" file=master.zip -#TODO replace dir with webdir and name -dir=/var/www/snipe-it-master webdir=/var/www/html name="snipeit" +tmp=/tmp/$name ans=default +mkdir $tmp echo " _____ _ __________ @@ -48,7 +49,7 @@ 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 detected." + echo " The installer has detected Ubuntu/Debian as the OS." distro=u ;; *centos*) @@ -62,15 +63,16 @@ case $distro in esac #Get your FQDN. -echo "" -echo " $si install script - Installing $ans" -echo "" -echo -n " Q. What is the FQDN of your server? (example: www.yourserver.com): " + +echo -n " Q. What is the FQDN of your server? ($fqdn): " read fqdn +if [ -z "$fqdn" ]; then + fqdn="$(hostname --fqdn)" +fi +echo " Setting to $fqdn" echo "" #Do you want to set your own passwords, or have me generate random ones? -ans=default until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do echo -n " Q. Do you want me to automatically create the MySQL root & user passwords? (y/n) " read setpw @@ -79,15 +81,17 @@ case $setpw in [yY] | [yY][Ee][Ss] ) mysqlrootpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" - echo " I'm putting this into /tmp/snipeit/mysqlpasswords ... " + echo " I'm putting this into $tmp/mysqlpasswords ... " echo " PLEASE REMOVE that file after you have recorded the passwords somewhere safe!" ans="yes" ;; [nN] | [n|N][O|o] ) echo -n " Q. What do you want your root PW to be?" read -s mysqlrootpw + echo "" echo -n " Q. What do you want your snipeit user PW to be?" read -s mysqluserpw + echo "" ans="no" ;; *) echo " Invalid answer. Please type y or n" @@ -100,11 +104,11 @@ random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)" #createstuff.sql will be injected to the database during install. mysqlpasswords.txt is a file that will contain the root and snipeit user passwords. #Again, this file should be removed, which will be a prompt at the end of the script. -createstufffile=/tmp/snipeit/createstuff.sql -passwordfile=/tmp/snipeit/mysqlpasswords.txt +dbSetup=$tmp/db_setup.sql +passwordfile=$tmp/mysqlpasswords.txt -echo >> $createstufffile "CREATE DATABASE snipeit;" -echo >> $createstufffile "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" +echo >> $dbSetup "CREATE DATABASE snipeit;" +echo >> $dbSetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" echo >> $passwordfile "MySQL Passwords..." echo >> $passwordfile "Root: $mysqlrootpw" echo >> $passwordfile "User (snipeit): $mysqluserpw" @@ -116,7 +120,7 @@ echo " * MySQL USER (snipeit) password: $mysqluserpw *" echo " * 32 bit random string: $random32 *" echo " ************************************************************" echo "" -echo " These passwords have been exported to /tmp/snipeit/mysqlpasswords.txt..." +echo " These passwords have been exported to $tmp/mysqlpasswords.txt..." echo " I recommend You delete this file for security purposes" echo "" @@ -132,7 +136,7 @@ case $distro in apachefile=/etc/apache2/sites-available/$fqdn.conf sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip - wget -P /tmp/snipeit/ https://github.com/snipe/snipe-it/archive/$file + wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file sudo unzip $file -d /var/www/ #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. @@ -142,7 +146,7 @@ case $distro in #Create MySQL accounts echo "## Create MySQL accounts" sudo mysqladmin -u root password $mysqlrootpw - sudo mysql -u root -p$mysqlrootpw < /tmp/snipeit/createstuff.sql + sudo mysql -u root -p$mysqlrootpw < $tmp/createstuff.sql #Enable mcrypt and rewrite sudo php5enmod mcrypt @@ -154,11 +158,11 @@ case $distro in echo >> $apachefile "" echo >> $apachefile "" echo >> $apachefile "ServerAdmin webmaster@localhost" - echo >> $apachefile " " + echo >> $apachefile " " echo >> $apachefile " Require all granted" echo >> $apachefile " AllowOverride All" echo >> $apachefile " " - echo >> $apachefile " DocumentRoot $dir/public" + echo >> $apachefile " DocumentRoot $webdir/$name/public" echo >> $apachefile " ServerName $fqdn" echo >> $apachefile " ErrorLog "\${APACHE_LOG_DIR}"/error.log" echo >> $apachefile " CustomLog "\${APACHE_LOG_DIR}"/access.log combined" @@ -167,29 +171,29 @@ case $distro in a2ensite $fqdn.conf #Change permissions on directories - sudo chmod -R 755 $dir/app/storage - sudo chmod -R 755 $dir/app/private_uploads - sudo chmod -R 755 $dir/public/uploads + sudo chmod -R 755 $webdir/$name/app/storage + sudo chmod -R 755 $webdir/$name/app/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads sudo chown -R www-data:www-data /var/www/ echo "## Finished permission changes." #Modify the Snipe-It files necessary for a production environment. - replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php - cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $dir/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php - cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php - replace "'false'," "true," -- $dir/app/config/production/app.php - cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php + replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php + replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php + replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php + replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php + cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php + replace "'false'," "true," -- $webdir/$name/app/config/production/app.php + cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php #Install / configure composer curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer - cd $dir/ + cd $webdir/$name/ composer install --no-dev --prefer-source php artisan app:install --env=production @@ -202,41 +206,73 @@ case $distro in apachefile=/etc/httpd/conf.d/snipe-it.conf #Allow us to get the mysql engine - sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm - sudo yum -y install httpd mysql-server wget git unzip + echo "## Add IUS repo and install mariaDB and a few other packages."; + mariadbRepo=/etc/yum.repos.d/MariaDB.repo + touch $mariadbRepo + 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 "gpgcheck=1" + echo >> $mariadbRepo "enable=1" - wget https://github.com/snipe/snipe-it/archive/$file - sudo unzip $file -d /var/www/ + wget -P $tmp/ https://centos6.iuscommunity.org/ius-release.rpm - sudo /sbin/service mysqld start + rpm -Uvh ius-release*.rpm > /dev/null + yum -y install httpd mariadb-server wget git unzip epel-release > /dev/null - #Create MySQL accounts - echo "## Create MySQL accounts" - mysqladmin -u root password $mysqlrootpw - echo "" - echo " ***Your Current ROOT password is---> $mysqlrootpw" - echo " ***Use $mysqlrootpw at the following prompt for root login***" - echo "" - + echo "## Download Snipe-IT from github and put it in the web directory."; + + wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null + unzip -qo $tmp/master.zip -d $tmp/ + cp -R $tmp/snipe-it-master $webdir/$name + + # Change permissions on directories + sudo chmod -R 755 $webdir/$name/app/storage + sudo chmod -R 755 $webdir/$name/app/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R apache:apache $webdir/$name + + + # Makde mariaDB start on boot and restart the daemon + echo "## Start the mariaDB server."; + chkconfig mysqld on + /sbin/service mysqld restart + + # Have user set own root password when securing install + # and just set the snipeit database user at the beginning /usr/bin/mysql_secure_installation - #Install PHP stuff. - sudo yum -y install php php-mysql php-bcmath.x86_64 php-cli.x86_64 php-common.x86_64 php-embedded.x86_64 php-gd.x86_64 php-mbstring - wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm - rpm -ivh epel-release-7-5.noarch.rpm - yum install -y --enablerepo="epel" php-mcrypt + #Create MySQL accounts + # echo "## Create MySQL accounts" + # mysqladmin -u root password $mysqlrootpw + # echo "" + # echo " ***Your Current ROOT password is---> $mysqlrootpw" + # echo " ***Use $mysqlrootpw at the following prompt for root login***" + # echo "" + + #Install PHP stuff. + echo "## Install PHP Stuff"; + PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" + + yum -y install $PACKAGES > /dev/null + rpm --query --queryformat " " $PACKAGES + + #Create the new virtual host in Apache and enable rewrite + echo "## Create the new virtual host in Apache."; - #Create the new virtual host in Apache. echo >> $apachefile "" echo >> $apachefile "" + echo >> $apachefile "LoadModule rewrite_module modules/mod_rewrite.so" + echo >> $apachefile "" echo >> $apachefile "" echo >> $apachefile "ServerAdmin webmaster@localhost" - echo >> $apachefile " " + echo >> $apachefile " " echo >> $apachefile " Require all granted" echo >> $apachefile " AllowOverride All" echo >> $apachefile " Options +Indexes" echo >> $apachefile " " - echo >> $apachefile " DocumentRoot $dir/public" + echo >> $apachefile " DocumentRoot $webdir/$name/public" echo >> $apachefile " ServerName $fqdn" echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" echo >> $apachefile " CustomLog /var/log/access.log combined" @@ -244,43 +280,34 @@ case $distro in echo "## Setup hosts file."; echo >> $hosts "127.0.0.1 $hostname $fqdn" - sudo ln -s $apachefile $apachefileen - #Enable rewrite and vhost - echo >> $apachecfg "LoadModule rewrite_module modules/mod_rewrite.so" - echo >> $apachecfg "IncludeOptional sites-enabled/*.conf" - - #Change permissions on directories - sudo chmod -R 755 $dir/app/storage - sudo chmod -R 755 $dir/app/private_uploads - sudo chmod -R 755 $dir/public/uploads - sudo chown -R apache:apache /var/www/ - - service httpd restart + # Make apache start on boot and restart the daemon + chkconfig httpd on + /sbin/service httpd start #Modify the Snipe-It files necessary for a production environment. - replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php - cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $dir/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php - cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php - cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php + replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php + replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php + replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php + replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php + cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php + replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php + cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php #Install / configure composer - cd $dir - sudo mysql -u root -p$mysqlrootpw < /tmp/snipeit/createstuff.sql + cd $webdir/$name + mysql -u root -p < $tmp/createstuff.sql curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production #Add SELinux and firewall exception/rules. You'll have to allow 443 if you want ssl connectivity. - chcon -R -h -t httpd_sys_script_rw_t $dir/ - firewall-cmd --zone=public --add-port=80/tcp --permanent - firewall-cmd --reload + # chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ + # firewall-cmd --zone=public --add-port=80/tcp --permanent + # firewall-cmd --reload service httpd restart ;; @@ -292,14 +319,15 @@ case $distro in #Allow us to get the mysql engine echo "## Add IUS repo and install mariaDB and a few other packages."; - rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm > /dev/null + wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm + rpm -Uvh ius-release.rpm > /dev/null yum -y install httpd mariadb-server wget git unzip epel-release > /dev/null - echo "## Download Snipe-IT from githut and put it in the web directory."; + echo "## Download Snipe-IT from github and put it in the web directory."; - wget https://github.com/snipe/snipe-it/archive/$file &> /dev/null - unzip -qo master.zip -d /tmp/snipeit/ - cp -R /tmp/snipeit/snipe-it-master $webdir/$name + wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null + unzip -qo $tmp/master.zip -d $tmp/ + cp -R $tmp/snipe-it-master $webdir/$name # Change permissions on directories sudo chmod -R 755 $webdir/$name/app/storage @@ -373,7 +401,7 @@ case $distro in #Install / configure composer cd $webdir/$name - mysql -u root -p < /tmp/snipeit/createstuff.sql + mysql -u root -p < $tmp/createstuff.sql curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production @@ -388,51 +416,20 @@ case $distro in ;; esac -echo "" -echo "" echo "" echo " ***I have no idea about your mail environment, so if you want email capability, open up the following***" -echo " nano -w $dir/app/config/production/mail.php" +echo " nano -w $webdir/$name/app/config/production/mail.php" echo " And edit the attributes appropriately." echo "" -echo "" sleep 1 echo "" - -ans=default -until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do -echo " Q. Shall I delete the password files I created? (Remember to record the passwords before deleting) (y/n)" -read setpw -case $setpw in - - [yY] | [yY][Ee][Ss] ) - rm $createstufffile - rm $passwordfile - echo " $createstufffile and $passwordfile files have been removed." - ans=yes - ;; - [nN] | [n|N][O|o] ) - echo " Ok, I won't remove the file. Please for the love of security, record the passwords and delete this file regardless." - echo " $si cannot be held responsible if this file is compromised!" - echo " From Snipe: I cannot encourage or even facilitate poor security practices, and still sleep the few, frantic hours I sleep at night." - ans=no - ;; - *) - echo " Please select a valid option" - ;; -esac -done - -echo "" -echo "" -echo " ***If you want mail capabilities, open $dir/app/config/production/mail.php and fill out the attributes***" -echo "" +echo " ***If you want mail capabilities, open $webdir/$name/app/config/production/mail.php and fill out the attributes***" echo "" echo " ***$si should now be installed. open up http://$fqdn in a web browser to verify.***" echo "" echo "" echo "## Cleaning up..." -rm -rf /tmp/snipeit/ +rm -rf $tmp/ echo "## Done!" sleep 1 From e35de9080665621f5771138c6605431c8d6de225 Mon Sep 17 00:00:00 2001 From: Walter Date: Sun, 1 Nov 2015 10:57:25 -0500 Subject: [PATCH 10/32] 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 11/32] 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 12/32] 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" From 5df26f9b0ae7708e2f221ee873126bf1d7cd91dc Mon Sep 17 00:00:00 2001 From: Walter Date: Tue, 3 Nov 2015 13:33:03 -0500 Subject: [PATCH 13/32] Fixed the ubuntu install portion that i broke --- install.sh | 123 +++++++++++++++++++++-------------------------------- 1 file changed, 49 insertions(+), 74 deletions(-) diff --git a/install.sh b/install.sh index 9aaffcf0dc..29165f0b3b 100755 --- a/install.sh +++ b/install.sh @@ -27,7 +27,6 @@ fqdn="$(hostname --fqdn)" hosts=/etc/hosts distro="$(cat /proc/version)" file=master.zip -webdir=/var/www/html name="snipeit" tmp=/tmp/$name ans=default @@ -74,22 +73,16 @@ echo "" #Do you want to set your own passwords, or have me generate random ones? until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do -echo -n " Q. Do you want me to automatically create the MySQL root & user passwords? (y/n) " +echo -n " Q. Do you want me to automatically create the snipe database user password? (y/n) " read setpw case $setpw in [yY] | [yY][Ee][Ss] ) - mysqlrootpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" - mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c8`)" - echo " I'm putting this into $tmp/mysqlpasswords ... " - echo " PLEASE REMOVE that file after you have recorded the passwords somewhere safe!" + mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c16`)" ans="yes" ;; [nN] | [n|N][O|o] ) - echo -n " Q. What do you want your root PW to be?" - read -s mysqlrootpw - echo "" - echo -n " Q. What do you want your snipeit user PW to be?" + echo -n " Q. What do you want your snipeit user password to be?" read -s mysqluserpw echo "" ans="no" @@ -102,51 +95,38 @@ done #Snipe says we need a new 32bit key, so let's create one randomly and inject it into the file random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)" -#createstuff.sql will be injected to the database during install. mysqlpasswords.txt is a file that will contain the root and snipeit user passwords. +#createstuff.sql will be injected to the database during install. #Again, this file should be removed, which will be a prompt at the end of the script. dbSetup=$tmp/db_setup.sql -passwordfile=$tmp/mysqlpasswords.txt echo >> $dbSetup "CREATE DATABASE snipeit;" echo >> $dbSetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" -echo >> $passwordfile "MySQL Passwords..." -echo >> $passwordfile "Root: $mysqlrootpw" -echo >> $passwordfile "User (snipeit): $mysqluserpw" -echo >> $passwordfile "32 bit random string: $random32" - -echo " ************************************************************" -echo " * MySQL ROOT password: $mysqlrootpw *" -echo " * MySQL USER (snipeit) password: $mysqluserpw *" -echo " * 32 bit random string: $random32 *" -echo " ************************************************************" -echo "" -echo " These passwords have been exported to $tmp/mysqlpasswords.txt..." -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 $dbSetup +chmod 700 $dbSetup case $distro in u ) ##################################### Install for Debian/ubuntu ############################################## + webdir=/var/www + #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. apachefile=/etc/apache2/sites-available/$fqdn.conf sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip - wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file - sudo unzip $file -d /var/www/ + # Get files and extract to web dir + wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null + unzip -qo $tmp/$file -d $tmp/ + cp -R $tmp/snipe-it-master $webdir/$name #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ sudo apt-get install -y php5 php5-mcrypt php5-curl php5-mysql php5-gd - #Create MySQL accounts - echo "## Create MySQL accounts" - sudo mysqladmin -u root password $mysqlrootpw - sudo mysql -u root -p$mysqlrootpw < $tmp/createstuff.sql + + ## TODO make sure apache is set to start on boot and go ahead and start it #Enable mcrypt and rewrite sudo php5enmod mcrypt @@ -190,6 +170,15 @@ case $distro in replace "'false'," "true," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + + echo "## Secure Mysql" + ## TODO make sure mysql is set to start on boot and go ahead and start it + + # Have user set own root password when securing install + # and just set the snipeit database user at the beginning + /usr/bin/mysql_secure_installation + sudo mysql -u root -p < $tmp/createstuff.sql + #Install / configure composer curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer @@ -202,7 +191,7 @@ case $distro in c6 ) ##################################### Install for Centos/Redhat 6 ############################################## - #Make directories so we can create a new apache vhost + webdir=/var/www/html apachefile=/etc/httpd/conf.d/snipe-it.conf #Allow us to get the mysql engine @@ -216,15 +205,21 @@ case $distro in echo >> $mariadbRepo "gpgcheck=1" echo >> $mariadbRepo "enable=1" + yum -y install wget > /dev/null wget -P $tmp/ https://centos6.iuscommunity.org/ius-release.rpm - rpm -Uvh ius-release*.rpm > /dev/null - yum -y install httpd mariadb-server wget git unzip epel-release > /dev/null + + #Install PHP and other needed stuff. + echo "## Install PHP and other needed stuff"; + PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" + + yum -y install $PACKAGES > /dev/null + rpm --query --queryformat " " $PACKAGES echo "## Download Snipe-IT from github and put it in the web directory."; wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null - unzip -qo $tmp/master.zip -d $tmp/ + unzip -qo $tmp/$file -d $tmp/ cp -R $tmp/snipe-it-master $webdir/$name # Change permissions on directories @@ -239,25 +234,9 @@ case $distro in chkconfig mysqld on /sbin/service mysqld restart - # Have user set own root password when securing install - # and just set the snipeit database user at the beginning + echo "## Start securing mariaDB server."; /usr/bin/mysql_secure_installation - #Create MySQL accounts - # echo "## Create MySQL accounts" - # mysqladmin -u root password $mysqlrootpw - # echo "" - # echo " ***Your Current ROOT password is---> $mysqlrootpw" - # echo " ***Use $mysqlrootpw at the following prompt for root login***" - # echo "" - - #Install PHP stuff. - echo "## Install PHP Stuff"; - PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" - - yum -y install $PACKAGES > /dev/null - rpm --query --queryformat " " $PACKAGES - #Create the new virtual host in Apache and enable rewrite echo "## Create the new virtual host in Apache."; @@ -285,6 +264,11 @@ case $distro in chkconfig httpd on /sbin/service httpd start + # Set timezone + $tzone = $(grep ZONE /etc/sysconfig/clock); + + if $tzone == + #Modify the Snipe-It files necessary for a production environment. replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php @@ -314,14 +298,21 @@ case $distro in c7 ) ##################################### Install for Centos/Redhat 7 ############################################## - #Make directories so we can create a new apache vhost + webdir=/var/www/html apachefile=/etc/httpd/conf.d/snipe-it.conf #Allow us to get the mysql engine echo "## Add IUS repo and install mariaDB and a few other packages."; + yum -y install wget > /dev/null wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm rpm -Uvh ius-release.rpm > /dev/null - yum -y install httpd mariadb-server wget git unzip epel-release > /dev/null + + #Install PHP stuff. + echo "## Install PHP Stuff"; + PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" + + yum -y install $PACKAGES > /dev/null + rpm --query --queryformat " " $PACKAGES echo "## Download Snipe-IT from github and put it in the web directory."; @@ -341,25 +332,9 @@ case $distro in systemctl enable mariadb.service systemctl restart mariadb.service - # Have user set own root password when securing install - # and just set the snipeit database user at the beginning + echo "## Start securing mariaDB server."; /usr/bin/mysql_secure_installation - #Create MySQL accounts - # echo "## Create MySQL accounts" - # mysqladmin -u root password $mysqlrootpw - # echo "" - # echo " ***Your Current ROOT password is---> $mysqlrootpw" - # echo " ***Use $mysqlrootpw at the following prompt for root login***" - # echo "" - - #Install PHP stuff. - echo "## Install PHP Stuff"; - PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" - - yum -y install $PACKAGES > /dev/null - rpm --query --queryformat " " $PACKAGES - #Create the new virtual host in Apache and enable rewrite echo "## Create the new virtual host in Apache."; From 958672dfd36d220ea242d7772626916c748063e3 Mon Sep 17 00:00:00 2001 From: Walter Date: Tue, 3 Nov 2015 14:12:21 -0500 Subject: [PATCH 14/32] Fixed missing vars and typos --- install.sh | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index 6feea83fa8..d8526a4f71 100755 --- a/install.sh +++ b/install.sh @@ -110,7 +110,7 @@ done #Snipe says we need a new 32bit key, so let's create one randomly and inject it into the file random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)" -#createstuff.sql will be injected to the database during install. +#db_setup.sql will be injected to the database during install. #Again, this file should be removed, which will be a prompt at the end of the script. dbSetup=$tmp/db_setup.sql @@ -118,13 +118,8 @@ echo >> $dbSetup "CREATE DATABASE snipeit;" echo >> $dbSetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" #Let us make it so only root can read the file. Again, this isn't best practice, so please remove these after the install. -<<<<<<< HEAD chown root:root $dbSetup chmod 700 $dbSetup -======= -chown root:root $passwordfile $dbSetup -chmod 700 $passwordfile $dbSetup ->>>>>>> origin/develop case $distro in debian) @@ -197,7 +192,7 @@ case $distro in # Have user set own root password when securing install # and just set the snipeit database user at the beginning /usr/bin/mysql_secure_installation - sudo mysql -u root -p < $tmp/createstuff.sql + sudo mysql -u root -p < $tmp/$dbsetup #Install / configure composer curl -sS https://getcomposer.org/installer | php @@ -287,7 +282,7 @@ case $distro in # Set timezone $tzone = $(grep ZONE /etc/sysconfig/clock); - if $tzone == + # if $tzone == #Modify the Snipe-It files necessary for a production environment. replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php @@ -303,7 +298,7 @@ case $distro in #Install / configure composer cd $webdir/$name - mysql -u root -p < $tmp/createstuff.sql + mysql -u root -p < $tmp/$dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production @@ -325,7 +320,7 @@ case $distro in echo "## Add IUS repo and install mariaDB and a few other packages."; yum -y install wget > /dev/null wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm - rpm -Uvh ius-release.rpm > /dev/null + rpm -Uvh $tmp/ius-release.rpm > /dev/null #Install PHP stuff. echo "## Install PHP Stuff"; @@ -396,7 +391,7 @@ case $distro in #Install / configure composer cd $webdir/$name - mysql -u root -p < $tmp/createstuff.sql + mysql -u root -p < $tmp/$dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production From 0d1544c3d65bf27a3e64e8ec258fb8dfaf961438 Mon Sep 17 00:00:00 2001 From: Walter Date: Tue, 3 Nov 2015 16:29:18 -0500 Subject: [PATCH 15/32] Fixing some package issues and syntax errors --- install.sh | 77 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/install.sh b/install.sh index d8526a4f71..878cc2ad4f 100755 --- a/install.sh +++ b/install.sh @@ -18,19 +18,30 @@ if [ "$(id -u)" != "0" ]; then exec sudo "$0" "$@" fi - #First things first, let's set some variables and find our distro. clear + +name="snipeit" si="Snipe-IT" hostname="$(hostname)" fqdn="$(hostname --fqdn)" +ans=default hosts=/etc/hosts file=master.zip -name="snipeit" tmp=/tmp/$name -ans=default + +rm -rf $tmp/ mkdir $tmp +function isinstalled { + if yum list installed "$@" >/dev/null 2>&1; then + true + else + false + fi +} + + # Lets find what distro we are using and what version distro="$(cat /proc/version)" if grep -q centos <<<$distro; then @@ -112,14 +123,13 @@ random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)" #db_setup.sql will be injected to the database during install. #Again, this file should be removed, which will be a prompt at the end of the script. -dbSetup=$tmp/db_setup.sql - -echo >> $dbSetup "CREATE DATABASE snipeit;" -echo >> $dbSetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" +dbsetup=$tmp/db_setup.sql +echo >> $dbsetup "CREATE DATABASE snipeit;" +echo >> $dbsetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" #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 $dbSetup -chmod 700 $dbSetup +chown root:root $dbsetup +chmod 700 $dbsetup case $distro in debian) @@ -180,7 +190,7 @@ case $distro in replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'https://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php replace "'false'," "true," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php @@ -192,7 +202,9 @@ case $distro in # Have user set own root password when securing install # and just set the snipeit database user at the beginning /usr/bin/mysql_secure_installation - sudo mysql -u root -p < $tmp/$dbsetup + + echo -n "## Input your MySQL/MariaDB root password: " + sudo mysql -u root -p < $dbsetup #Install / configure composer curl -sS https://getcomposer.org/installer | php @@ -278,9 +290,9 @@ case $distro in # Make apache start on boot and restart the daemon chkconfig httpd on /sbin/service httpd start - + ##TODO get timezone and set it in file # Set timezone - $tzone = $(grep ZONE /etc/sysconfig/clock); + $tzone=$(grep ZONE /etc/sysconfig/clock); # if $tzone == @@ -292,13 +304,14 @@ case $distro in replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'https://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php #Install / configure composer cd $webdir/$name - mysql -u root -p < $tmp/$dbsetup + echo -n "## Input your MySQL/MariaDB root password: " + mysql -u root -p < $dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production @@ -317,18 +330,26 @@ case $distro in apachefile=/etc/httpd/conf.d/snipe-it.conf #Allow us to get the mysql engine + echo "" echo "## Add IUS repo and install mariaDB and a few other packages."; yum -y install wget > /dev/null - wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm + wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm > /dev/null rpm -Uvh $tmp/ius-release.rpm > /dev/null #Install PHP stuff. echo "## Install PHP Stuff"; PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" - yum -y install $PACKAGES > /dev/null - rpm --query --queryformat " " $PACKAGES + for p in $PACKAGES;do + if isinstalled $p;then + echo " ##" $p "Installed" + else + echo -n " ##" $p "Installing... " + yum -y install $p > /dev/null + fi + done; + echo "" echo "## Download Snipe-IT from github and put it in the web directory."; wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null @@ -342,7 +363,6 @@ case $distro in sudo chown -R apache:apache $webdir/$name echo "## Start the mariaDB server."; - #/sbin/service mysqld start # Makde mariaDB start on boot and restart the daemon systemctl enable mariadb.service systemctl restart mariadb.service @@ -376,6 +396,11 @@ case $distro in # Make apache start on boot and restart the daemon systemctl enable httpd.service systemctl restart httpd.service + ##TODO get timezone and set it in file + # Set timezone + $tzone=$(grep ZONE /etc/sysconfig/clock); + + # if $tzone == #Modify the Snipe-It files necessary for a production environment. replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php @@ -385,13 +410,14 @@ case $distro in replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'https://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php #Install / configure composer cd $webdir/$name - mysql -u root -p < $tmp/$dbsetup + echo -n "## Input your MySQL/MariaDB root password: " + mysql -u root -p < $dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production @@ -406,17 +432,10 @@ case $distro in ;; esac -echo "" -echo " ***I have no idea about your mail environment, so if you want email capability, open up the following***" -echo " nano -w $webdir/$name/app/config/production/mail.php" -echo " And edit the attributes appropriately." -echo "" -sleep 1 - echo "" echo " ***If you want mail capabilities, open $webdir/$name/app/config/production/mail.php and fill out the attributes***" echo "" -echo " ***$si should now be installed. open up http://$fqdn in a web browser to verify.***" +echo " ***Open http://$fqdn to login to Snipe-IT.***" echo "" echo "" echo "## Cleaning up..." From f3de39efd6d1abd5deb79524a70e476d4f51ba3e Mon Sep 17 00:00:00 2001 From: Walter Date: Wed, 4 Nov 2015 09:06:48 -0500 Subject: [PATCH 16/32] syncing centos 6 and centos 7 wasnt replacing production.yourserver.com with the fdqn. took out http:// changed .conf file name to $name.conf instead of $fdqn.conf --- install.sh | 60 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/install.sh b/install.sh index 878cc2ad4f..48b108bd01 100755 --- a/install.sh +++ b/install.sh @@ -75,11 +75,11 @@ case $distro in ;; *centos6*|*redhat6*) echo " The installer has detected $distro $distVersion as the OS." - distro=redhat6 + distro=centos6 ;; *centos7*|*redhat7*) echo " The installer has detected $distro $distVersion as the OS." - distro=redhat7 + distro=centos7 ;; *) echo " The installer was unable to determine your OS. Exiting for safety." @@ -138,7 +138,7 @@ case $distro in webdir=/var/www #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. - apachefile=/etc/apache2/sites-available/$fqdn.conf + apachefile=/etc/apache2/sites-available/$name.conf sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip # Get files and extract to web dir @@ -173,7 +173,7 @@ case $distro in echo >> $apachefile " CustomLog "\${APACHE_LOG_DIR}"/access.log combined" echo >> $apachefile "" echo >> $hosts "127.0.0.1 $hostname $fqdn" - a2ensite $fqdn.conf + a2ensite $name.conf #Change permissions on directories sudo chmod -R 755 $webdir/$name/app/storage @@ -188,9 +188,9 @@ case $distro in replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'https://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php replace "'false'," "true," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php @@ -215,13 +215,14 @@ case $distro in service apache2 restart ;; - redhat6 ) + centos6 ) ##################################### Install for Centos/Redhat 6 ############################################## webdir=/var/www/html - apachefile=/etc/httpd/conf.d/snipe-it.conf + apachefile=/etc/httpd/conf.d/$name.conf #Allow us to get the mysql engine + echo "" echo "## Add IUS repo and install mariaDB and a few other packages."; mariadbRepo=/etc/yum.repos.d/MariaDB.repo touch $mariadbRepo @@ -233,16 +234,23 @@ case $distro in echo >> $mariadbRepo "enable=1" yum -y install wget > /dev/null - wget -P $tmp/ https://centos6.iuscommunity.org/ius-release.rpm - rpm -Uvh ius-release*.rpm > /dev/null + wget -P $tmp/ https://centos6.iuscommunity.org/ius-release.rpm > /dev/null + rpm -Uvh $tmp/ius-release*.rpm > /dev/null #Install PHP and other needed stuff. echo "## Install PHP and other needed stuff"; PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" - yum -y install $PACKAGES > /dev/null - rpm --query --queryformat " " $PACKAGES + for p in $PACKAGES;do + if isinstalled $p;then + echo " ##" $p "Installed" + else + echo -n " ##" $p "Installing... " + yum -y install $p > /dev/null + fi + done; + echo "" echo "## Download Snipe-IT from github and put it in the web directory."; wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null @@ -255,8 +263,7 @@ case $distro in sudo chmod -R 755 $webdir/$name/public/uploads sudo chown -R apache:apache $webdir/$name - - # Makde mariaDB start on boot and restart the daemon + # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; chkconfig mysqld on /sbin/service mysqld restart @@ -302,9 +309,9 @@ case $distro in replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'https://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php @@ -316,28 +323,29 @@ case $distro in php composer.phar install --no-dev --prefer-source php artisan app:install --env=production - #Add SELinux and firewall exception/rules. You'll have to allow 443 if you want ssl connectivity. +#TODO detect if SELinux and firewall are enabled to decide what to do + #Add SELinux and firewall exception/rules. Youll have to allow 443 if you want ssl connectivity. # chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ # firewall-cmd --zone=public --add-port=80/tcp --permanent # firewall-cmd --reload service httpd restart ;; - redhat7 ) + centos7 ) ##################################### Install for Centos/Redhat 7 ############################################## webdir=/var/www/html - apachefile=/etc/httpd/conf.d/snipe-it.conf + apachefile=/etc/httpd/conf.d/$name.conf #Allow us to get the mysql engine echo "" echo "## Add IUS repo and install mariaDB and a few other packages."; yum -y install wget > /dev/null wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm > /dev/null - rpm -Uvh $tmp/ius-release.rpm > /dev/null + rpm -Uvh $tmp/ius-release*.rpm > /dev/null - #Install PHP stuff. - echo "## Install PHP Stuff"; + #Install PHP and other needed stuff. + echo "## Install PHP and other needed stuff"; PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" for p in $PACKAGES;do @@ -353,7 +361,7 @@ case $distro in echo "## Download Snipe-IT from github and put it in the web directory."; wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null - unzip -qo $tmp/master.zip -d $tmp/ + unzip -qo $tmp/$file -d $tmp/ cp -R $tmp/snipe-it-master $webdir/$name # Change permissions on directories @@ -362,8 +370,8 @@ case $distro in sudo chmod -R 755 $webdir/$name/public/uploads sudo chown -R apache:apache $webdir/$name + # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; - # Makde mariaDB start on boot and restart the daemon systemctl enable mariadb.service systemctl restart mariadb.service @@ -408,9 +416,9 @@ case $distro in replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php - replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/database.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'https://production.yourserver.com'," "'http://$fqdn'," -- $webdir/$name/app/config/production/app.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php From 037cda36b2c6d824556da89e7d30683ff1929ea4 Mon Sep 17 00:00:00 2001 From: Walter Date: Wed, 4 Nov 2015 09:17:16 -0500 Subject: [PATCH 17/32] formatting --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 48b108bd01..56aa93327d 100755 --- a/install.sh +++ b/install.sh @@ -299,7 +299,7 @@ case $distro in /sbin/service httpd start ##TODO get timezone and set it in file # Set timezone - $tzone=$(grep ZONE /etc/sysconfig/clock); + # $tzone=$(grep ZONE /etc/sysconfig/clock); # if $tzone == @@ -317,7 +317,7 @@ case $distro in #Install / configure composer cd $webdir/$name - echo -n "## Input your MySQL/MariaDB root password: " + echo "## Input your MySQL/MariaDB root password: " mysql -u root -p < $dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source @@ -406,7 +406,7 @@ case $distro in systemctl restart httpd.service ##TODO get timezone and set it in file # Set timezone - $tzone=$(grep ZONE /etc/sysconfig/clock); + # $tzone=$(grep ZONE /etc/sysconfig/clock); # if $tzone == @@ -424,7 +424,7 @@ case $distro in #Install / configure composer cd $webdir/$name - echo -n "## Input your MySQL/MariaDB root password: " + echo "## Input your MySQL/MariaDB root password " mysql -u root -p < $dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source From c7057f550fabaa5c7292f7bd48aa6108b0973180 Mon Sep 17 00:00:00 2001 From: Walter Date: Wed, 4 Nov 2015 10:08:04 -0500 Subject: [PATCH 18/32] removed a var --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 56aa93327d..7a74a7071a 100755 --- a/install.sh +++ b/install.sh @@ -74,11 +74,11 @@ case $distro in distro=debian ;; *centos6*|*redhat6*) - echo " The installer has detected $distro $distVersion as the OS." + echo " The installer has detected $distro as the OS." distro=centos6 ;; *centos7*|*redhat7*) - echo " The installer has detected $distro $distVersion as the OS." + echo " The installer has detected $distro as the OS." distro=centos7 ;; *) @@ -234,7 +234,7 @@ case $distro in echo >> $mariadbRepo "enable=1" yum -y install wget > /dev/null - wget -P $tmp/ https://centos6.iuscommunity.org/ius-release.rpm > /dev/null + wget -P $tmp/ https://centos6.iuscommunity.org/ius-release.rpm &> /dev/null rpm -Uvh $tmp/ius-release*.rpm > /dev/null #Install PHP and other needed stuff. @@ -341,7 +341,7 @@ case $distro in echo "" echo "## Add IUS repo and install mariaDB and a few other packages."; yum -y install wget > /dev/null - wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm > /dev/null + wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm &> /dev/null rpm -Uvh $tmp/ius-release*.rpm > /dev/null #Install PHP and other needed stuff. From 56b50468d2bc14d33dbad17357664cd68937ee00 Mon Sep 17 00:00:00 2001 From: Walter Date: Wed, 4 Nov 2015 16:01:25 -0500 Subject: [PATCH 19/32] fixed packages for centos6 --- install.sh | 69 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/install.sh b/install.sh index 7a74a7071a..486f5ba1eb 100755 --- a/install.sh +++ b/install.sh @@ -219,17 +219,18 @@ case $distro in ##################################### Install for Centos/Redhat 6 ############################################## webdir=/var/www/html - apachefile=/etc/httpd/conf.d/$name.conf + +##TODO make sure the repo doesnt exhist isnt already in there #Allow us to get the mysql engine echo "" - echo "## Add IUS repo and install mariaDB and a few other packages."; + echo "## Add IUS and mariaDB repos."; mariadbRepo=/etc/yum.repos.d/MariaDB.repo touch $mariadbRepo 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-MariaD6" + echo >> $mariadbRepo "baseurl = http://yum.mariadb.org/10.1/centos6-amd64" + echo >> $mariadbRepo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" echo >> $mariadbRepo "gpgcheck=1" echo >> $mariadbRepo "enable=1" @@ -239,16 +240,17 @@ case $distro in #Install PHP and other needed stuff. echo "## Install PHP and other needed stuff"; - PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" + PACKAGES="epel-release httpd MariaDB-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" - for p in $PACKAGES;do - if isinstalled $p;then + for p in $PACKAGES;do + if isinstalled $p;then echo " ##" $p "Installed" else echo -n " ##" $p "Installing... " yum -y install $p > /dev/null + echo ""; fi - done; + done; echo "" echo "## Download Snipe-IT from github and put it in the web directory."; @@ -265,14 +267,16 @@ case $distro in # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; - chkconfig mysqld on - /sbin/service mysqld restart + chkconfig mysql on + /sbin/service mysql restart echo "## Start securing mariaDB server."; /usr/bin/mysql_secure_installation +##TODO make sure the apachefile doesnt exhist isnt already in there #Create the new virtual host in Apache and enable rewrite echo "## Create the new virtual host in Apache."; + apachefile=/etc/httpd/conf.d/$name.conf echo >> $apachefile "" echo >> $apachefile "" @@ -291,6 +295,7 @@ case $distro in echo >> $apachefile " CustomLog /var/log/access.log combined" echo >> $apachefile "" +##TODO make sure hosts file doesnt already contain this info echo "## Setup hosts file."; echo >> $hosts "127.0.0.1 $hostname $fqdn" @@ -335,27 +340,27 @@ case $distro in ##################################### Install for Centos/Redhat 7 ############################################## webdir=/var/www/html - apachefile=/etc/httpd/conf.d/$name.conf #Allow us to get the mysql engine echo "" - echo "## Add IUS repo and install mariaDB and a few other packages."; + echo "## Add IUS and mariaDB repos."; yum -y install wget > /dev/null wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm &> /dev/null rpm -Uvh $tmp/ius-release*.rpm > /dev/null #Install PHP and other needed stuff. echo "## Install PHP and other needed stuff"; - PACKAGES="php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt httpd mariadb-server git unzip epel-release" + PACKAGES="epel-release httpd mariadb-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" - for p in $PACKAGES;do - if isinstalled $p;then + for p in $PACKAGES;do + if isinstalled $p;then echo " ##" $p "Installed" else echo -n " ##" $p "Installing... " yum -y install $p > /dev/null + echo ""; fi - done; + done; echo "" echo "## Download Snipe-IT from github and put it in the web directory."; @@ -376,11 +381,16 @@ case $distro in systemctl restart mariadb.service echo "## Start securing mariaDB server."; + echo ""; + echo ""; /usr/bin/mysql_secure_installation - #Create the new virtual host in Apache and enable rewrite - echo "## Create the new virtual host in Apache."; +##TODO make sure the apachefile doesnt exhist isnt already in there + #Create the new virtual host in Apache and enable rewrite + apachefile=/etc/httpd/conf.d/$name.conf + + echo "## Create the new virtual host in Apache."; echo >> $apachefile "" echo >> $apachefile "" echo >> $apachefile "LoadModule rewrite_module modules/mod_rewrite.so" @@ -397,29 +407,34 @@ case $distro in echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" echo >> $apachefile " CustomLog /var/log/access.log combined" echo >> $apachefile "" - + +##TODO make sure this isnt already in there echo "## Setup hosts file."; echo >> $hosts "127.0.0.1 $hostname $fqdn" + + echo "## Start the apache server."; # Make apache start on boot and restart the daemon systemctl enable httpd.service systemctl restart httpd.service - ##TODO get timezone and set it in file +##TODO get timezone and set it in file # Set timezone # $tzone=$(grep ZONE /etc/sysconfig/clock); # if $tzone == #Modify the Snipe-It files necessary for a production environment. - replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + echo "## Modify the Snipe-It files necessary for a production environment."; + + replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php > /dev/null cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php + replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php > /dev/null + replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php > /dev/null + replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php > /dev/null + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php > /dev/null cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php + replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php > /dev/null + replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php > /dev/null cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php #Install / configure composer From b856e7f2c65dac260a1181b14bccdf10ad282ecc Mon Sep 17 00:00:00 2001 From: Michael T Date: Wed, 4 Nov 2015 15:55:41 -0700 Subject: [PATCH 20/32] Make Model column a hyperlink to access the model page. --- app/controllers/admin/AssetsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 1ee6989d7d..43b86c6953 100755 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -1211,7 +1211,7 @@ class AssetsController extends AdminController 'name' => ''.$asset->name.'', 'asset_tag' => ''.$asset->asset_tag.'', 'serial' => $asset->serial, - 'model' => ($asset->model) ? $asset->model->name : 'No model', + 'model' => ($asset->model) ? link_to('/hardware/models/'.$asset->model->id.'/view', $asset->model->name, array('target'=>'_blank')) : 'No model', 'status' => ($asset->assigneduser) ? link_to('../admin/users/'.$asset->assigned_to.'/view', $asset->assigneduser->fullName()) : (($asset->assetstatus) ? $asset->assetstatus->name : ''), 'location' => (($asset->assigneduser) && ($asset->assigneduser->userloc!='')) ? link_to('admin/settings/locations/'.$asset->assigneduser->userloc->id.'/edit', $asset->assigneduser->userloc->name) : (($asset->defaultLoc!='') ? link_to('admin/settings/locations/'.$asset->defaultLoc->id.'/edit', $asset->defaultLoc->name) : ''), 'category' => (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '', From 11c2fcd0942b5f1d0326af513b64ecc1672cf4a6 Mon Sep 17 00:00:00 2001 From: Michael T Date: Wed, 4 Nov 2015 16:10:27 -0700 Subject: [PATCH 21/32] Remove new window target --- app/controllers/admin/AssetsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 43b86c6953..c2de106483 100755 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -1211,7 +1211,7 @@ class AssetsController extends AdminController 'name' => ''.$asset->name.'', 'asset_tag' => ''.$asset->asset_tag.'', 'serial' => $asset->serial, - 'model' => ($asset->model) ? link_to('/hardware/models/'.$asset->model->id.'/view', $asset->model->name, array('target'=>'_blank')) : 'No model', + 'model' => ($asset->model) ? link_to('/hardware/models/'.$asset->model->id.'/view', $asset->model->name) : 'No model', 'status' => ($asset->assigneduser) ? link_to('../admin/users/'.$asset->assigned_to.'/view', $asset->assigneduser->fullName()) : (($asset->assetstatus) ? $asset->assetstatus->name : ''), 'location' => (($asset->assigneduser) && ($asset->assigneduser->userloc!='')) ? link_to('admin/settings/locations/'.$asset->assigneduser->userloc->id.'/edit', $asset->assigneduser->userloc->name) : (($asset->defaultLoc!='') ? link_to('admin/settings/locations/'.$asset->defaultLoc->id.'/edit', $asset->defaultLoc->name) : ''), 'category' => (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '', From e54bbcd37fa5271d096302c36003c4277df5141e Mon Sep 17 00:00:00 2001 From: Walter Date: Wed, 4 Nov 2015 21:14:19 -0500 Subject: [PATCH 22/32] working on debian installer --- install.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 486f5ba1eb..7dd7c5a751 100755 --- a/install.sh +++ b/install.sh @@ -135,30 +135,32 @@ case $distro in debian) ##################################### Install for Debian/ubuntu ############################################## - webdir=/var/www + webdir=/var/www/html #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. apachefile=/etc/apache2/sites-available/$name.conf - sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get install -y git unzip + + echo "## Install packages." + sudo apt-get install -y git unzip php5 php5-mcrypt php5-curl php5-mysql php5-gd > /dev/null + #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ > /dev/null # Get files and extract to web dir + echo "## Download snipeit and extract to web directory." wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null unzip -qo $tmp/$file -d $tmp/ cp -R $tmp/snipe-it-master $webdir/$name - #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ - sudo apt-get install -y php5 php5-mcrypt php5-curl php5-mysql php5-gd - - ## TODO make sure apache is set to start on boot and go ahead and start it #Enable mcrypt and rewrite + echo "## Enabled mcrypt and rewrite" sudo php5enmod mcrypt sudo a2enmod rewrite sudo ls -al /etc/apache2/mods-enabled/rewrite.load #Create a new virtual host for Apache. + echo "## Create Virtual host for apache." echo >> $apachefile "" echo >> $apachefile "" echo >> $apachefile "" @@ -172,10 +174,13 @@ case $distro in echo >> $apachefile " ErrorLog "\${APACHE_LOG_DIR}"/error.log" echo >> $apachefile " CustomLog "\${APACHE_LOG_DIR}"/access.log combined" echo >> $apachefile "" + + echo "## Setup hosts file." echo >> $hosts "127.0.0.1 $hostname $fqdn" a2ensite $name.conf #Change permissions on directories + echo "## Set permissionson web directory." sudo chmod -R 755 $webdir/$name/app/storage sudo chmod -R 755 $webdir/$name/app/private_uploads sudo chmod -R 755 $webdir/$name/public/uploads @@ -183,6 +188,7 @@ case $distro in echo "## Finished permission changes." #Modify the Snipe-It files necessary for a production environment. + echo "## Modify the Snipe-It files necessary for a production environment." replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php @@ -207,12 +213,14 @@ case $distro in sudo mysql -u root -p < $dbsetup #Install / configure composer + echo "## Install and configure composer" curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer cd $webdir/$name/ composer install --no-dev --prefer-source php artisan app:install --env=production + echo "## restart apache." service apache2 restart ;; centos6 ) @@ -229,7 +237,7 @@ case $distro in touch $mariadbRepo echo >> $mariadbRepo "[mariadb]" echo >> $mariadbRepo "name = MariaDB" - echo >> $mariadbRepo "baseurl = http://yum.mariadb.org/10.1/centos6-amd64" + echo >> $mariadbRepo "baseurl = http://yum.mariadb.org/10.0/centos6-amd64" echo >> $mariadbRepo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" echo >> $mariadbRepo "gpgcheck=1" echo >> $mariadbRepo "enable=1" @@ -248,7 +256,7 @@ case $distro in else echo -n " ##" $p "Installing... " yum -y install $p > /dev/null - echo ""; + echo ""; fi done; From 61fc912c47dc52e46a54250e11fca691164bab01 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 5 Nov 2015 16:25:03 -0500 Subject: [PATCH 23/32] moving permisions block and some mysql stuff --- install.sh | 81 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index 7dd7c5a751..1a30e4767c 100755 --- a/install.sh +++ b/install.sh @@ -131,6 +131,8 @@ echo >> $dbsetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIF chown root:root $dbsetup chmod 700 $dbsetup +## TODO: Progress tracker on each step + case $distro in debian) ##################################### Install for Debian/ubuntu ############################################## @@ -138,14 +140,20 @@ case $distro in webdir=/var/www/html #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. + echo "Updaing ubuntu." + echo "" apachefile=/etc/apache2/sites-available/$name.conf + sudo apt-get update > /dev/null + sudo apt-get -y upgrade > /dev/null + sudo apt-get install -y git unzip > /dev/null echo "## Install packages." - sudo apt-get install -y git unzip php5 php5-mcrypt php5-curl php5-mysql php5-gd > /dev/null + sudo apt-get install -y git unzip php5 php5-mcrypt php5-curl php5-mysql php5-gd php5-ldap > /dev/null #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ > /dev/null # Get files and extract to web dir + echo "" echo "## Download snipeit and extract to web directory." wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file &> /dev/null unzip -qo $tmp/$file -d $tmp/ @@ -155,9 +163,9 @@ case $distro in #Enable mcrypt and rewrite echo "## Enabled mcrypt and rewrite" - sudo php5enmod mcrypt - sudo a2enmod rewrite - sudo ls -al /etc/apache2/mods-enabled/rewrite.load + sudo php5enmod mcrypt > /dev/null + sudo a2enmod rewrite > /dev/null + sudo ls -al /etc/apache2/mods-enabled/rewrite.load > /dev/null #Create a new virtual host for Apache. echo "## Create Virtual host for apache." @@ -177,7 +185,7 @@ case $distro in echo "## Setup hosts file." echo >> $hosts "127.0.0.1 $hostname $fqdn" - a2ensite $name.conf + a2ensite $name.conf > /dev/null #Change permissions on directories echo "## Set permissionson web directory." @@ -185,33 +193,41 @@ case $distro in sudo chmod -R 755 $webdir/$name/app/private_uploads sudo chmod -R 755 $webdir/$name/public/uploads sudo chown -R www-data:www-data /var/www/ - echo "## Finished permission changes." + # echo "## Finished permission changes." #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." + echo " Setting up bootstrap file." replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php + + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php replace "'false'," "true," -- $webdir/$name/app/config/production/app.php + + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + ## TODO make sure mysql is set to start on boot and go ahead and start it + + + echo "## Input your MySQL/MariaDB root password: " + sudo mysql -u root < $dbsetup echo "## Secure Mysql" - ## TODO make sure mysql is set to start on boot and go ahead and start it # Have user set own root password when securing install # and just set the snipeit database user at the beginning /usr/bin/mysql_secure_installation - echo -n "## Input your MySQL/MariaDB root password: " - sudo mysql -u root -p < $dbsetup - #Install / configure composer echo "## Install and configure composer" curl -sS https://getcomposer.org/installer | php @@ -248,7 +264,7 @@ case $distro in #Install PHP and other needed stuff. echo "## Install PHP and other needed stuff"; - PACKAGES="epel-release httpd MariaDB-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" + PACKAGES="epel-release httpd MariaDB-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt php56u-ldap" for p in $PACKAGES;do if isinstalled $p;then @@ -267,16 +283,13 @@ case $distro in unzip -qo $tmp/$file -d $tmp/ cp -R $tmp/snipe-it-master $webdir/$name - # Change permissions on directories - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R apache:apache $webdir/$name - # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; chkconfig mysql on /sbin/service mysql restart + + echo "## Input your MySQL/MariaDB root password: " + mysql -u root < $dbsetup echo "## Start securing mariaDB server."; /usr/bin/mysql_secure_installation @@ -317,6 +330,8 @@ case $distro in # if $tzone == #Modify the Snipe-It files necessary for a production environment. + echo "## Modify the Snipe-It files necessary for a production environment."; + replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php @@ -328,12 +343,19 @@ case $distro in replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + # Change permissions on directories + sudo chmod -R 755 $webdir/$name/app/storage + sudo chmod -R 755 $webdir/$name/app/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R apache:apache $webdir/$name + #Install / configure composer + echo "## Configure composer" cd $webdir/$name - echo "## Input your MySQL/MariaDB root password: " - mysql -u root -p < $dbsetup curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source + + echo "## Install Snipe-IT" php artisan app:install --env=production #TODO detect if SELinux and firewall are enabled to decide what to do @@ -358,7 +380,7 @@ case $distro in #Install PHP and other needed stuff. echo "## Install PHP and other needed stuff"; - PACKAGES="epel-release httpd mariadb-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt" + PACKAGES="epel-release httpd mariadb-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt php56u-ldap" for p in $PACKAGES;do if isinstalled $p;then @@ -377,17 +399,14 @@ case $distro in unzip -qo $tmp/$file -d $tmp/ cp -R $tmp/snipe-it-master $webdir/$name - # Change permissions on directories - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R apache:apache $webdir/$name - # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; systemctl enable mariadb.service systemctl restart mariadb.service + echo "## Input your MySQL/MariaDB root password " + mysql -u root < $dbsetup + echo "## Start securing mariaDB server."; echo ""; echo ""; @@ -445,10 +464,16 @@ case $distro in replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php > /dev/null cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + + # Change permissions on directories + sudo chmod -R 755 $webdir/$name/app/storage + sudo chmod -R 755 $webdir/$name/app/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R apache:apache $webdir/$name + #Install / configure composer cd $webdir/$name - echo "## Input your MySQL/MariaDB root password " - mysql -u root -p < $dbsetup + curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source php artisan app:install --env=production From 5d5882ea5b75090612d067a5aa9571b5ae133915 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 5 Nov 2015 21:40:51 -0500 Subject: [PATCH 24/32] moved the permissions changes to the end --- install.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 1a30e4767c..3f5b2edede 100755 --- a/install.sh +++ b/install.sh @@ -140,16 +140,16 @@ case $distro in webdir=/var/www/html #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. - echo "Updaing ubuntu." + echo "## Updaing ubuntu" echo "" apachefile=/etc/apache2/sites-available/$name.conf sudo apt-get update > /dev/null sudo apt-get -y upgrade > /dev/null - sudo apt-get install -y git unzip > /dev/null echo "## Install packages." sudo apt-get install -y git unzip php5 php5-mcrypt php5-curl php5-mysql php5-gd php5-ldap > /dev/null #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. + echo "## Settup LAMP." sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ > /dev/null # Get files and extract to web dir @@ -187,14 +187,6 @@ case $distro in echo >> $hosts "127.0.0.1 $hostname $fqdn" a2ensite $name.conf > /dev/null - #Change permissions on directories - echo "## Set permissionson web directory." - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R www-data:www-data /var/www/ - # echo "## Finished permission changes." - #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up bootstrap file." @@ -218,6 +210,13 @@ case $distro in ## TODO make sure mysql is set to start on boot and go ahead and start it + #Change permissions on directories + echo "## Set permissionson web directory." + sudo chmod -R 755 $webdir/$name/app/storage + sudo chmod -R 755 $webdir/$name/app/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R www-data:www-data /var/www/ + # echo "## Finished permission changes." echo "## Input your MySQL/MariaDB root password: " sudo mysql -u root < $dbsetup From c94ece29254c1308ae144b9720a9cdc48dc83473 Mon Sep 17 00:00:00 2001 From: Walter Date: Thu, 5 Nov 2015 21:42:20 -0500 Subject: [PATCH 25/32] changed replace for sed command --- install.sh | 62 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/install.sh b/install.sh index 3f5b2edede..347be2d61d 100755 --- a/install.sh +++ b/install.sh @@ -190,20 +190,19 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up bootstrap file." - replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php + sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php + sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php + sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php - replace "'false'," "true," -- $webdir/$name/app/config/production/app.php + sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php + sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php + sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php @@ -329,17 +328,23 @@ case $distro in # if $tzone == #Modify the Snipe-It files necessary for a production environment. - echo "## Modify the Snipe-It files necessary for a production environment."; + echo "## Modify the Snipe-It files necessary for a production environment." + echo " Setting up bootstrap file." + sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php - replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php - replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php + sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php + sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php + sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php + + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php + sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php + sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php + sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php + + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php # Change permissions on directories @@ -450,19 +455,24 @@ case $distro in # if $tzone == #Modify the Snipe-It files necessary for a production environment. - echo "## Modify the Snipe-It files necessary for a production environment."; + echo "## Modify the Snipe-It files necessary for a production environment." + echo " Setting up bootstrap file." + sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php - replace "'www.yourserver.com'" "'$hostname'" -- $webdir/$name/bootstrap/start.php > /dev/null + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - replace "'snipeit_laravel'," "'snipeit'," -- $webdir/$name/app/config/production/database.php > /dev/null - replace "'travis'," "'snipeit'," -- $webdir/$name/app/config/production/database.php > /dev/null - replace " 'password' => ''," " 'password' => '$mysqluserpw'," -- $webdir/$name/app/config/production/database.php > /dev/null - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/database.php > /dev/null - cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - replace "'production.yourserver.com'," "'$fqdn'," -- $webdir/$name/app/config/production/app.php > /dev/null - replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $webdir/$name/app/config/production/app.php > /dev/null - cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php + sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php + sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php + echo " Setting up app file." + cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php + sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php + sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php + sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php + + echo " Setting up mail file." + cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php # Change permissions on directories sudo chmod -R 755 $webdir/$name/app/storage From 62cee46a83d9d9dcf9e12884563918bab0adb61a Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 6 Nov 2015 08:30:51 -0500 Subject: [PATCH 26/32] update webdir for debian and fix the error logs --- install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 347be2d61d..13ef744cfe 100755 --- a/install.sh +++ b/install.sh @@ -137,7 +137,7 @@ case $distro in debian) ##################################### Install for Debian/ubuntu ############################################## - webdir=/var/www/html + webdir=/var/www #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. echo "## Updaing ubuntu" @@ -179,8 +179,8 @@ case $distro in echo >> $apachefile " " echo >> $apachefile " DocumentRoot $webdir/$name/public" echo >> $apachefile " ServerName $fqdn" - echo >> $apachefile " ErrorLog "\${APACHE_LOG_DIR}"/error.log" - echo >> $apachefile " CustomLog "\${APACHE_LOG_DIR}"/access.log combined" + echo >> $apachefile " ErrorLog /var/log/apache2/snipeIT.error.log" + echo >> $apachefile " CustomLog /var/log/apache2/access.log combined" echo >> $apachefile "" echo "## Setup hosts file." @@ -310,7 +310,7 @@ case $distro in echo >> $apachefile " " echo >> $apachefile " DocumentRoot $webdir/$name/public" echo >> $apachefile " ServerName $fqdn" - echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" + echo >> $apachefile " ErrorLog /var/log/httpd/snipeIT.error.log" echo >> $apachefile " CustomLog /var/log/access.log combined" echo >> $apachefile "" @@ -435,7 +435,7 @@ case $distro in echo >> $apachefile " " echo >> $apachefile " DocumentRoot $webdir/$name/public" echo >> $apachefile " ServerName $fqdn" - echo >> $apachefile " ErrorLog /var/log/httpd/snipe.error.log" + echo >> $apachefile " ErrorLog /var/log/httpd/snipeIT.error.log" echo >> $apachefile " CustomLog /var/log/access.log combined" echo >> $apachefile "" From fc6bb7f056a42c1eb8983e93d78c76dc0070fc17 Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 6 Nov 2015 09:02:51 -0500 Subject: [PATCH 27/32] sets the timezone automatically --- install.sh | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/install.sh b/install.sh index 13ef744cfe..dca29195f1 100755 --- a/install.sh +++ b/install.sh @@ -140,6 +140,7 @@ case $distro in webdir=/var/www #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. + echo "" echo "## Updaing ubuntu" echo "" apachefile=/etc/apache2/sites-available/$name.conf @@ -189,22 +190,26 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up bootstrap file." + echo " Setting up Timezone." + $tzone=$(cat /etc/timezone); + sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php + + echo " Setting up bootstrap file." sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php - echo " Setting up database file." + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php - echo " Setting up app file." + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php - echo " Setting up mail file." + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php ## TODO make sure mysql is set to start on boot and go ahead and start it @@ -319,32 +324,33 @@ case $distro in echo >> $hosts "127.0.0.1 $hostname $fqdn" # Make apache start on boot and restart the daemon + echo "## Start the apache server."; chkconfig httpd on /sbin/service httpd start - ##TODO get timezone and set it in file - # Set timezone - # $tzone=$(grep ZONE /etc/sysconfig/clock); - - # if $tzone == #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up bootstrap file." + echo " Setting up Timezone." + $tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); + sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php + + + echo " Setting up bootstrap file." sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php - echo " Setting up database file." + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php - echo " Setting up app file." + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php - echo " Setting up mail file." + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php # Change permissions on directories @@ -448,30 +454,29 @@ case $distro in # Make apache start on boot and restart the daemon systemctl enable httpd.service systemctl restart httpd.service -##TODO get timezone and set it in file - # Set timezone - # $tzone=$(grep ZONE /etc/sysconfig/clock); - - # if $tzone == #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up bootstrap file." + echo " Setting up Timezone." + $tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); + sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php + + echo " Setting up bootstrap file." sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php - echo " Setting up database file." + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php - echo " Setting up app file." + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php - echo " Setting up mail file." + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php # Change permissions on directories From ca1384504a6a3802cea8bacc7fce2413f65a3681 Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 6 Nov 2015 10:03:58 -0500 Subject: [PATCH 28/32] fixed tzone variable assignment --- install.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index dca29195f1..b844242820 100755 --- a/install.sh +++ b/install.sh @@ -191,7 +191,7 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up Timezone." - $tzone=$(cat /etc/timezone); + tzone=$(cat /etc/timezone); sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php echo " Setting up bootstrap file." @@ -331,10 +331,9 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up Timezone." - $tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); + tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php - echo " Setting up bootstrap file." sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php @@ -458,7 +457,7 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up Timezone." - $tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); + tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php echo " Setting up bootstrap file." From a47a4e83e2fb90fb7e6d55c34ca9d515f4316c7e Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 6 Nov 2015 11:53:07 -0500 Subject: [PATCH 29/32] fixed issues with sed command and / --- install.sh | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index b844242820..7bffa037fa 100755 --- a/install.sh +++ b/install.sh @@ -192,22 +192,22 @@ case $distro in echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up Timezone." tzone=$(cat /etc/timezone); - sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php + sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php echo " Setting up bootstrap file." - sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php + sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php - sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php - sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php + sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php + sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php + sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php - sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php - sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php + sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php + sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php + sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php @@ -332,22 +332,22 @@ case $distro in echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up Timezone." tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); - sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php + sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php echo " Setting up bootstrap file." - sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php + sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php - sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php - sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php + sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php + sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php + sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php - sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php - sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php + sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php + sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php + sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php @@ -458,22 +458,22 @@ case $distro in echo "## Modify the Snipe-It files necessary for a production environment." echo " Setting up Timezone." tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); - sed -i "s/UTC/$tzone/g" $webdir/$name/app/config/app.php + sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php echo " Setting up bootstrap file." - sed -i "s/www.yourserver.com/$hostname/g" $webdir/$name/bootstrap/start.php + sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s/snipeit_laravel/snipeit/g" $webdir/$name/app/config/production/database.php - sed -i "s/travis/snipeit/g" $webdir/$name/app/config/production/database.php - sed -i "s/password' => ''/password' => '$mysqluserpw'/g" $webdir/$name/app/config/production/database.php + sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php + sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php + sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s/production.yourserver.com/$fqdn/g" $webdir/$name/app/config/production/app.php - sed -i "s/Change_this_key_or_snipe_will_get_ya/$random32/g" $webdir/$name/app/config/production/app.php - sed -i "s/false/true/g" $webdir/$name/app/config/production/app.php + sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php + sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php + sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php From 9f43b6af9f355f6d8de6b5b9689ffdb6904fd5eb Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 6 Nov 2015 15:17:54 -0500 Subject: [PATCH 30/32] fixed apache config file --- install.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index 7bffa037fa..148343fb86 100755 --- a/install.sh +++ b/install.sh @@ -190,26 +190,26 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up Timezone." + echo " Setting up Timezone." tzone=$(cat /etc/timezone); sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php - echo " Setting up bootstrap file." + echo " Setting up bootstrap file." sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php - echo " Setting up database file." + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - echo " Setting up app file." + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - echo " Setting up mail file." + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php ## TODO make sure mysql is set to start on boot and go ahead and start it @@ -289,7 +289,7 @@ case $distro in # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; chkconfig mysql on - /sbin/service mysql restart + /sbin/service mysql start echo "## Input your MySQL/MariaDB root password: " mysql -u root < $dbsetup @@ -309,7 +309,7 @@ case $distro in echo >> $apachefile "" echo >> $apachefile "ServerAdmin webmaster@localhost" echo >> $apachefile " " - echo >> $apachefile " Require all granted" + echo >> $apachefile " Allow From All" echo >> $apachefile " AllowOverride All" echo >> $apachefile " Options +Indexes" echo >> $apachefile " " @@ -330,26 +330,26 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up Timezone." + echo " Setting up Timezone." tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php - echo " Setting up bootstrap file." + echo " Setting up bootstrap file." sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php - echo " Setting up database file." + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - echo " Setting up app file." + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - echo " Setting up mail file." + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php # Change permissions on directories @@ -411,7 +411,7 @@ case $distro in # Make mariaDB start on boot and restart the daemon echo "## Start the mariaDB server."; systemctl enable mariadb.service - systemctl restart mariadb.service + systemctl start mariadb.service echo "## Input your MySQL/MariaDB root password " mysql -u root < $dbsetup @@ -434,7 +434,7 @@ case $distro in echo >> $apachefile "" echo >> $apachefile "ServerAdmin webmaster@localhost" echo >> $apachefile " " - echo >> $apachefile " Require all granted" + echo >> $apachefile " Allow From All" echo >> $apachefile " AllowOverride All" echo >> $apachefile " Options +Indexes" echo >> $apachefile " " @@ -456,26 +456,26 @@ case $distro in #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up Timezone." + echo " Setting up Timezone." tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php - echo " Setting up bootstrap file." + echo " Setting up bootstrap file." sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php - echo " Setting up database file." + echo " Setting up database file." cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - echo " Setting up app file." + echo " Setting up app file." cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - echo " Setting up mail file." + echo " Setting up mail file." cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php # Change permissions on directories From 250880c6f38fd5a2ec1d3b638910d6378ccd130e Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 7 Nov 2015 15:39:03 -0800 Subject: [PATCH 31/32] Include default text in status label helper --- app/helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers.php b/app/helpers.php index 4c1fece3ed..a643c5f830 100755 --- a/app/helpers.php +++ b/app/helpers.php @@ -39,7 +39,7 @@ function suppliersList() { } function statusLabelList() { - $statuslabel_list = Statuslabel::orderBy('name', 'asc') + $statuslabel_list = array('' => Lang::get('general.select_statuslabel')) + Statuslabel::orderBy('name', 'asc') ->lists('name', 'id'); return $statuslabel_list; } From 306d8ebaf72076cbccadae7d214eed68276d65f5 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 7 Nov 2015 15:40:25 -0800 Subject: [PATCH 32/32] Fixes #1317 - regression issue in bulk delete --- app/config/version.php | 4 ++-- app/controllers/admin/UsersController.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/config/version.php b/app/config/version.php index 0bad2deb6c..789b9589c9 100644 --- a/app/config/version.php +++ b/app/config/version.php @@ -1,5 +1,5 @@ 'v2.0-394', - 'hash_version' => 'v2.0-394-g14ba5a3', + 'app_version' => 'v2.0.5-pre', + 'hash_version' => 'v2.0.5-pre-3-gc1961c0', ); \ No newline at end of file diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index 34ac9af339..d719fcdc7d 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -43,7 +43,7 @@ class UsersController extends AdminController { 'first_name' => 'required|alpha_space|min:2', 'last_name' => 'required|alpha_space|min:2', 'location_id' => 'numeric', - 'username' => 'required|min:2|unique:users,username', + 'username' => 'required|min:2|unique:users,username, ', 'email' => 'email|unique:users,email', 'password' => 'required|min:6', 'password_confirm' => 'required|min:6|same:password', @@ -486,8 +486,8 @@ class UsersController extends AdminController { if ((!Input::has('edit_user')) || (count(Input::has('edit_user')) == 0)) { return Redirect::back()->with('error', 'No users selected'); } else { - $statuslabel_list = array('' => Lang::get('general.select_statuslabel')) + Statuslabel::orderBy('name', 'asc')->lists('name', 'id'); - $user_raw_array = Input::get('edit_user'); + $statuslabel_list = statusLabelList(); + $user_raw_array = array_keys(Input::get('edit_user')); $users = User::whereIn('id', $user_raw_array)->with('groups')->get(); return View::make('backend/users/confirm-bulk-delete', compact('users', 'statuslabel_list')); }