mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Fix various installer issues. (#4096)
* Various installer fixes. * CentOS 6 related fixes.
This commit is contained in:
parent
862543428b
commit
26423c5c02
120
snipeit.sh
120
snipeit.sh
|
@ -54,6 +54,7 @@ progress () {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Used for Debian and Ubuntu
|
||||||
vhenvfile () {
|
vhenvfile () {
|
||||||
find /etc/apache2/mods-enabled -maxdepth 1 -name 'rewrite.load' >/dev/null 2>&1
|
find /etc/apache2/mods-enabled -maxdepth 1 -name 'rewrite.load' >/dev/null 2>&1
|
||||||
apachefile=/etc/apache2/sites-available/$name.conf
|
apachefile=/etc/apache2/sites-available/$name.conf
|
||||||
|
@ -74,16 +75,16 @@ vhenvfile () {
|
||||||
echo >> $hosts "127.0.0.1 $hostname $fqdn"
|
echo >> $hosts "127.0.0.1 $hostname $fqdn"
|
||||||
log "a2ensite $name.conf"
|
log "a2ensite $name.conf"
|
||||||
|
|
||||||
cat > "$webdir/$name/.env" <<-EOF
|
cp $webdir/$name/.env.example $webdir/$name/.env
|
||||||
#Created By Snipe-it Installer
|
|
||||||
APP_TIMEZONE=$(cat /etc/timezone)
|
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
|
||||||
DB_HOST=localhost
|
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$(cat /etc/timezone)',' $webdir/$name/.env
|
||||||
DB_DATABASE=snipeit
|
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' $webdir/$name/.env
|
||||||
DB_USERNAME=snipeit
|
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' $webdir/$name/.env
|
||||||
DB_PASSWORD=$mysqluserpw
|
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' $webdir/$name/.env
|
||||||
APP_URL=http://$fqdn
|
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
|
||||||
APP_KEY=$random32
|
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
|
||||||
EOF
|
sed -i 's,^\(APP_KEY=\).*,\1'$$random32',' $webdir/$name/.env
|
||||||
}
|
}
|
||||||
|
|
||||||
perms () {
|
perms () {
|
||||||
|
@ -173,7 +174,7 @@ echo ""
|
||||||
|
|
||||||
#Do you want to set your own passwords, or have me generate random ones?
|
#Do you want to set your own passwords, or have me generate random ones?
|
||||||
until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do
|
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
|
read setpw
|
||||||
|
|
||||||
case $setpw in
|
case $setpw in
|
||||||
|
@ -306,7 +307,7 @@ case $distro in
|
||||||
webdir=/var/www/html
|
webdir=/var/www/html
|
||||||
#Allow us to get the mysql engine
|
#Allow us to get the mysql engine
|
||||||
echo ""
|
echo ""
|
||||||
echo "## Adding IUS, epel-release and mariaDB repos.";
|
echo "## Adding IUS, epel-release and mariaDB repositories.";
|
||||||
mariadbRepo=/etc/yum.repos.d/MariaDB.repo
|
mariadbRepo=/etc/yum.repos.d/MariaDB.repo
|
||||||
touch "$mariadbRepo"
|
touch "$mariadbRepo"
|
||||||
{
|
{
|
||||||
|
@ -322,25 +323,23 @@ case $distro in
|
||||||
log "wget -P "$tmp/" https://centos6.iuscommunity.org/ius-release.rpm"
|
log "wget -P "$tmp/" https://centos6.iuscommunity.org/ius-release.rpm"
|
||||||
log "rpm -Uvh "$tmp/ius-release*.rpm""
|
log "rpm -Uvh "$tmp/ius-release*.rpm""
|
||||||
|
|
||||||
#Install PHP and other needed stuff.
|
#Install PHP and other needed stuff
|
||||||
echo "## Installing PHP and other needed stuff";
|
echo "## Installing PHP and other requirements.";
|
||||||
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"
|
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
|
for p in $PACKAGES;do
|
||||||
if isinstalled "$p"; then
|
if isinstalled "$p"; then
|
||||||
echo " ## $p already installed"
|
echo " ## $p already installed"
|
||||||
else
|
else
|
||||||
echo -n " ## installing $p ... "
|
echo -n " ## Installing $p ... "
|
||||||
log "yum -y install $p"
|
log "yum -y install $p"
|
||||||
echo "";
|
echo "";
|
||||||
fi
|
fi
|
||||||
done;
|
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"
|
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
|
||||||
unzip -qo $tmp/$file -d $tmp/
|
|
||||||
cp -R $tmp/$fileName $webdir/$name
|
|
||||||
|
|
||||||
# Make mariaDB start on boot and restart the daemon
|
# Make mariaDB start on boot and restart the daemon
|
||||||
echo "## Starting the mariaDB server.";
|
echo "## Starting the mariaDB server.";
|
||||||
|
@ -387,17 +386,16 @@ case $distro in
|
||||||
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
|
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
|
||||||
echo "## Configuring .env file."
|
echo "## Configuring .env file."
|
||||||
|
|
||||||
cat > $webdir/$name/.env <<-EOF
|
cp $webdir/$name/.env.example $webdir/$name/.env
|
||||||
#Created By Snipe-it Installer
|
|
||||||
APP_TIMEZONE=$tzone
|
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
|
||||||
DB_HOST=localhost
|
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$tzone',' $webdir/$name/.env
|
||||||
DB_DATABASE=snipeit
|
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' $webdir/$name/.env
|
||||||
DB_USERNAME=snipeit
|
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' $webdir/$name/.env
|
||||||
DB_PASSWORD=$mysqluserpw
|
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' $webdir/$name/.env
|
||||||
APP_URL=http://$fqdn
|
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
|
||||||
APP_KEY=$random32
|
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
|
||||||
DB_DUMP_PATH='/usr/bin'
|
sed -i 's,^\(APP_KEY=\).*,\1'$$random32',' $webdir/$name/.env
|
||||||
EOF
|
|
||||||
|
|
||||||
echo "## Configure composer"
|
echo "## Configure composer"
|
||||||
cd $webdir/$name
|
cd $webdir/$name
|
||||||
|
@ -417,8 +415,12 @@ case $distro in
|
||||||
fi
|
fi
|
||||||
|
|
||||||
service httpd restart
|
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
|
elif [[ "$version" =~ ^7 ]]; then
|
||||||
##################################### Install for Centos/Redhat 7 ##############################################
|
##################################### Install for Centos/Redhat 7 ##############################################
|
||||||
|
@ -426,26 +428,26 @@ case $distro in
|
||||||
webdir=/var/www/html
|
webdir=/var/www/html
|
||||||
|
|
||||||
#Allow us to get the mysql engine
|
#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 "yum -y install wget epel-release"
|
||||||
log "wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm"
|
log "wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm"
|
||||||
log "rpm -Uvh $tmp/ius-release*.rpm"
|
log "rpm -Uvh $tmp/ius-release*.rpm"
|
||||||
|
|
||||||
#Install PHP and other needed stuff.
|
#Install PHP and other requirements
|
||||||
echo "## Installing PHP and other needed stuff";
|
echo "## Installing PHP and other requirements.";
|
||||||
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"
|
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
|
for p in $PACKAGES;do
|
||||||
if isinstalled "$p"; then
|
if isinstalled "$p"; then
|
||||||
echo " ## $p already installed"
|
echo " ## $p already installed"
|
||||||
else
|
else
|
||||||
echo -n " ## installing $p ... "
|
echo -n " ## Installing $p ... "
|
||||||
log "yum -y install $p"
|
log "yum -y install $p"
|
||||||
echo "";
|
echo "";
|
||||||
fi
|
fi
|
||||||
done;
|
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"
|
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
|
||||||
|
|
||||||
|
@ -500,20 +502,16 @@ case $distro in
|
||||||
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
|
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
|
||||||
echo "## Configuring .env file."
|
echo "## Configuring .env file."
|
||||||
|
|
||||||
cat > $webdir/$name/.env <<-EOF
|
cp $webdir/$name/.env.example $webdir/$name/.env
|
||||||
#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
|
|
||||||
|
|
||||||
|
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
|
#Install / configure composer
|
||||||
cd $webdir/$name
|
cd $webdir/$name
|
||||||
|
@ -521,14 +519,13 @@ case $distro in
|
||||||
curl -sS https://getcomposer.org/installer | php
|
curl -sS https://getcomposer.org/installer | php
|
||||||
php composer.phar install --no-dev --prefer-source
|
php composer.phar install --no-dev --prefer-source
|
||||||
|
|
||||||
|
#Set permissions
|
||||||
perms
|
perms
|
||||||
chown -R apache:apache $webdir/$name
|
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
|
#Check if SELinux is enforcing
|
||||||
if [ "$(getenforce)" == "Enforcing" ]; then
|
if [ "$(getenforce)" == "Enforcing" ]; then
|
||||||
#Add SELinux and firewall exception/rules.
|
#Add SELinux and firewall exception/rules
|
||||||
#Required for ldap integration
|
#Required for ldap integration
|
||||||
setsebool -P httpd_can_connect_ldap on
|
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
|
#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
|
fi
|
||||||
|
|
||||||
systemctl restart httpd.service
|
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
|
else
|
||||||
echo "Unable to Handle Centos Version #. Version Found: " $version
|
echo "Unable to Handle Centos Version #. Version Found: " $version
|
||||||
|
@ -546,7 +550,7 @@ case $distro in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo ""
|
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 ""
|
||||||
echo " ***Open http://$fqdn to login to Snipe-IT.***"
|
echo " ***Open http://$fqdn to login to Snipe-IT.***"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
Loading…
Reference in a new issue