mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-12 16:44:08 -08:00
Fix various installer issues. (#4096)
* Various installer fixes. * CentOS 6 related fixes.
This commit is contained in:
parent
862543428b
commit
26423c5c02
122
snipeit.sh
122
snipeit.sh
|
@ -54,6 +54,7 @@ progress () {
|
|||
done
|
||||
}
|
||||
|
||||
#Used for Debian and Ubuntu
|
||||
vhenvfile () {
|
||||
find /etc/apache2/mods-enabled -maxdepth 1 -name 'rewrite.load' >/dev/null 2>&1
|
||||
apachefile=/etc/apache2/sites-available/$name.conf
|
||||
|
@ -74,16 +75,16 @@ vhenvfile () {
|
|||
echo >> $hosts "127.0.0.1 $hostname $fqdn"
|
||||
log "a2ensite $name.conf"
|
||||
|
||||
cat > "$webdir/$name/.env" <<-EOF
|
||||
#Created By Snipe-it Installer
|
||||
APP_TIMEZONE=$(cat /etc/timezone)
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=snipeit
|
||||
DB_USERNAME=snipeit
|
||||
DB_PASSWORD=$mysqluserpw
|
||||
APP_URL=http://$fqdn
|
||||
APP_KEY=$random32
|
||||
EOF
|
||||
cp $webdir/$name/.env.example $webdir/$name/.env
|
||||
|
||||
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$(cat /etc/timezone)',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_KEY=\).*,\1'$$random32',' $webdir/$name/.env
|
||||
}
|
||||
|
||||
perms () {
|
||||
|
@ -173,7 +174,7 @@ 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 snipe database user password? (y/n) "
|
||||
echo -n " Q. Do you want to automatically create the database user password? (y/n) "
|
||||
read setpw
|
||||
|
||||
case $setpw in
|
||||
|
@ -306,7 +307,7 @@ case $distro in
|
|||
webdir=/var/www/html
|
||||
#Allow us to get the mysql engine
|
||||
echo ""
|
||||
echo "## Adding IUS, epel-release and mariaDB repos.";
|
||||
echo "## Adding IUS, epel-release and mariaDB repositories.";
|
||||
mariadbRepo=/etc/yum.repos.d/MariaDB.repo
|
||||
touch "$mariadbRepo"
|
||||
{
|
||||
|
@ -322,25 +323,23 @@ case $distro in
|
|||
log "wget -P "$tmp/" https://centos6.iuscommunity.org/ius-release.rpm"
|
||||
log "rpm -Uvh "$tmp/ius-release*.rpm""
|
||||
|
||||
#Install PHP and other needed stuff.
|
||||
echo "## Installing PHP and other needed stuff";
|
||||
PACKAGES="httpd MariaDB-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt php56u-ldap"
|
||||
#Install PHP and other needed stuff
|
||||
echo "## Installing PHP and other requirements.";
|
||||
PACKAGES="httpd mariadb-server git unzip php71u php71u-mysqlnd php71u-bcmath php71u-cli php71u-common php71u-embedded php71u-gd php71u-mbstring php71u-mcrypt php71u-ldap php71u-json php71u-simplexml"
|
||||
|
||||
for p in $PACKAGES;do
|
||||
if isinstalled "$p"; then
|
||||
echo " ## $p already installed"
|
||||
else
|
||||
echo -n " ## installing $p ... "
|
||||
echo -n " ## Installing $p ... "
|
||||
log "yum -y install $p"
|
||||
echo "";
|
||||
fi
|
||||
done;
|
||||
|
||||
echo -e "\n## Downloading Snipe-IT from github and putting it in the web directory.";
|
||||
echo -e "\n## Cloning Snipe-IT from github to the web directory.";
|
||||
|
||||
log "wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file"
|
||||
unzip -qo $tmp/$file -d $tmp/
|
||||
cp -R $tmp/$fileName $webdir/$name
|
||||
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
|
||||
|
||||
# Make mariaDB start on boot and restart the daemon
|
||||
echo "## Starting the mariaDB server.";
|
||||
|
@ -387,17 +386,16 @@ case $distro in
|
|||
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
|
||||
echo "## Configuring .env file."
|
||||
|
||||
cat > $webdir/$name/.env <<-EOF
|
||||
#Created By Snipe-it Installer
|
||||
APP_TIMEZONE=$tzone
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=snipeit
|
||||
DB_USERNAME=snipeit
|
||||
DB_PASSWORD=$mysqluserpw
|
||||
APP_URL=http://$fqdn
|
||||
APP_KEY=$random32
|
||||
DB_DUMP_PATH='/usr/bin'
|
||||
EOF
|
||||
cp $webdir/$name/.env.example $webdir/$name/.env
|
||||
|
||||
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$tzone',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_KEY=\).*,\1'$$random32',' $webdir/$name/.env
|
||||
|
||||
echo "## Configure composer"
|
||||
cd $webdir/$name
|
||||
|
@ -417,8 +415,12 @@ case $distro in
|
|||
fi
|
||||
|
||||
service httpd restart
|
||||
php artisan key:generate
|
||||
php artisan passport:install
|
||||
|
||||
echo "## Generating the application key."
|
||||
php artisan key:generate --force
|
||||
|
||||
echo "## Artisan Migrate."
|
||||
php artisan migrate --force
|
||||
|
||||
elif [[ "$version" =~ ^7 ]]; then
|
||||
##################################### Install for Centos/Redhat 7 ##############################################
|
||||
|
@ -426,26 +428,26 @@ case $distro in
|
|||
webdir=/var/www/html
|
||||
|
||||
#Allow us to get the mysql engine
|
||||
echo -e "\n## Add IUS, epel-release and mariaDB repos.";
|
||||
echo -e "\n## Adding IUS, epel-release and mariaDB repositories.";
|
||||
log "yum -y install wget epel-release"
|
||||
log "wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm"
|
||||
log "rpm -Uvh $tmp/ius-release*.rpm"
|
||||
|
||||
#Install PHP and other needed stuff.
|
||||
echo "## Installing PHP and other needed stuff";
|
||||
PACKAGES="httpd mariadb-server git unzip php56u php56u-mysqlnd php56u-bcmath php56u-cli php56u-common php56u-embedded php56u-gd php56u-mbstring php56u-mcrypt php56u-ldap"
|
||||
#Install PHP and other requirements
|
||||
echo "## Installing PHP and other requirements.";
|
||||
PACKAGES="httpd mariadb-server git unzip php71u php71u-mysqlnd php71u-bcmath php71u-cli php71u-common php71u-embedded php71u-gd php71u-mbstring php71u-mcrypt php71u-ldap php71u-json php71u-simplexml"
|
||||
|
||||
for p in $PACKAGES;do
|
||||
if isinstalled "$p"; then
|
||||
echo " ## $p already installed"
|
||||
else
|
||||
echo -n " ## installing $p ... "
|
||||
echo -n " ## Installing $p ... "
|
||||
log "yum -y install $p"
|
||||
echo "";
|
||||
fi
|
||||
done;
|
||||
|
||||
echo -e "\n## Downloading Snipe-IT from github and put it in the web directory.";
|
||||
echo -e "\n## Cloning Snipe-IT from github to the web directory.";
|
||||
|
||||
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
|
||||
|
||||
|
@ -488,7 +490,7 @@ case $distro in
|
|||
echo "</VirtualHost>"
|
||||
} >> "$apachefile"
|
||||
|
||||
##TODO make sure this isnt already in there
|
||||
##TODO make sure this isnt already in there
|
||||
echo "## Setting up hosts file.";
|
||||
echo >> $hosts "127.0.0.1 $hostname $fqdn"
|
||||
|
||||
|
@ -500,20 +502,16 @@ case $distro in
|
|||
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
|
||||
echo "## Configuring .env file."
|
||||
|
||||
cat > $webdir/$name/.env <<-EOF
|
||||
#Created By Snipe-it Installer
|
||||
APP_TIMEZONE=$tzone
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=snipeit
|
||||
DB_USERNAME=snipeit
|
||||
DB_PASSWORD=$mysqluserpw
|
||||
APP_URL=http://$fqdn
|
||||
APP_KEY=$random32
|
||||
DB_DUMP_PATH='/usr/bin'
|
||||
EOF
|
||||
|
||||
# Change permissions on directories
|
||||
cp $webdir/$name/.env.example $webdir/$name/.env
|
||||
|
||||
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$tzone',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' $webdir/$name/.env
|
||||
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
|
||||
sed -i 's,^\(APP_KEY=\).*,\1'$$random32',' $webdir/$name/.env
|
||||
|
||||
#Install / configure composer
|
||||
cd $webdir/$name
|
||||
|
@ -521,14 +519,13 @@ case $distro in
|
|||
curl -sS https://getcomposer.org/installer | php
|
||||
php composer.phar install --no-dev --prefer-source
|
||||
|
||||
#Set permissions
|
||||
perms
|
||||
chown -R apache:apache $webdir/$name
|
||||
# Make SeLinux happy
|
||||
chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/
|
||||
|
||||
#Check if SELinux is enforcing
|
||||
if [ "$(getenforce)" == "Enforcing" ]; then
|
||||
#Add SELinux and firewall exception/rules.
|
||||
#Add SELinux and firewall exception/rules
|
||||
#Required for ldap integration
|
||||
setsebool -P httpd_can_connect_ldap on
|
||||
#Sets SELinux context type so that scripts running in the web server process are allowed read/write access
|
||||
|
@ -536,8 +533,15 @@ case $distro in
|
|||
fi
|
||||
|
||||
systemctl restart httpd.service
|
||||
php artisan key:generate
|
||||
php artisan passport:install
|
||||
|
||||
echo "## Generating the application key."
|
||||
php artisan key:generate --force
|
||||
|
||||
echo "## Artisan Migrate."
|
||||
php artisan migrate --force
|
||||
|
||||
echo "## Creating scheduler cron."
|
||||
(crontab -l ; echo "* * * * * /usr/bin/php $webdir/$name/artisan schedule:run >> /dev/null 2>&1") | crontab -
|
||||
|
||||
else
|
||||
echo "Unable to Handle Centos Version #. Version Found: " $version
|
||||
|
@ -546,7 +550,7 @@ case $distro in
|
|||
esac
|
||||
|
||||
echo ""
|
||||
echo " ***If you want mail capabilities, edit $webdir/$name/.env and edit based on .env.example***"
|
||||
echo " ***If you want mail capabilities, edit $webdir/$name/.env***"
|
||||
echo ""
|
||||
echo " ***Open http://$fqdn to login to Snipe-IT.***"
|
||||
echo ""
|
||||
|
|
Loading…
Reference in a new issue