Merge branch 'develop'

This commit is contained in:
snipe 2017-10-06 22:59:01 -07:00
commit 4981077cb1
4 changed files with 1227 additions and 216 deletions

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,8 @@ class Kernel extends ConsoleKernel
Commands\Purge::class, Commands\Purge::class,
Commands\LdapSync::class, Commands\LdapSync::class,
Commands\FixDoubleEscape::class, Commands\FixDoubleEscape::class,
Commands\RecryptFromMcrypt::class Commands\RecryptFromMcrypt::class,
Commands\DemoData::class
]; ];
/** /**

View file

@ -168,8 +168,6 @@ class StatuslabelsController extends Controller
} }
} }
} }
$labels[]='Deployed';
$points[]=Asset::whereNotNull('assigned_to')->count();
$colors_array = array_merge($colors, Helper::chartColors()); $colors_array = array_merge($colors, Helper::chartColors());

View file

@ -8,7 +8,6 @@
# install process for Debian and CentOS # # install process for Debian and CentOS #
# based distributions. I assume you will be # # based distributions. I assume you will be #
# installing as a subdomain on a fresh OS install. # # installing as a subdomain on a fresh OS install. #
# Right now I'm not going to worry about SMTP setup #
# # # #
# Feel free to modify, but please give # # Feel free to modify, but please give #
# credit where it's due. Thanks! # # credit where it's due. Thanks! #
@ -28,9 +27,9 @@ fi
clear clear
name="snipeit" name="snipeit"
verbose="false"
hostname="$(hostname)" hostname="$(hostname)"
fqdn="$(hostname --fqdn)" fqdn="$(hostname --fqdn)"
ans=default
hosts=/etc/hosts hosts=/etc/hosts
spin[0]="-" spin[0]="-"
@ -50,8 +49,7 @@ progress () {
done done
} }
#Used for Debian and Ubuntu setvhdebian () {
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
{ {
@ -71,22 +69,37 @@ vhenvfile () {
log "a2ensite $name.conf" log "a2ensite $name.conf"
} }
perms () { setvhcentos () {
chmod_dirs=( "$webdir/$name/storage" ) apachefile=/etc/httpd/conf.d/$name.conf
chmod_dirs+=( "$webdir/$name/storage/private_uploads" ) {
chmod_dirs+=( "$webdir/$name/public/uploads" ) echo "<VirtualHost *:80>"
#Change permissions on directories echo "ServerAdmin webmaster@localhost"
for chmod_dir in "${chmod_dirs[@]}" echo " <Directory $webdir/$name/public>"
do echo " Allow From All"
chmod -R 755 "$chmod_dir" echo " AllowOverride All"
done echo " Options +Indexes"
echo " </Directory>"
echo " DocumentRoot $webdir/$name/public"
echo " ServerName $fqdn"
echo " ErrorLog /var/log/httpd/snipeIT.error.log"
echo " CustomLog /var/log/access.log combined"
echo "</VirtualHost>"
} >> "$apachefile"
} }
log () { log () {
if [ "$verbose" = true ]; then
eval "$@"
else
eval "$@" |& tee -a /var/log/snipeit-install.log >/dev/null 2>&1 eval "$@" |& tee -a /var/log/snipeit-install.log >/dev/null 2>&1
fi
} }
setenv () { installsnipeit () {
echo "* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
echo "* Configuring .env file."
cp $webdir/$name/.env.example $webdir/$name/.env cp $webdir/$name/.env.example $webdir/$name/.env
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
@ -96,12 +109,30 @@ setenv () {
sed -i 's,^\(DB_USERNAME=\).*,\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,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
}
installcomposer () { echo "* Installing and running composer."
cd $webdir/$name/ cd $webdir/$name/
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
echo "* Setting permissions."
chmod_dirs=( "$webdir/$name/storage" )
chmod_dirs+=( "$webdir/$name/storage/private_uploads" )
chmod_dirs+=( "$webdir/$name/public/uploads" )
for chmod_dir in "${chmod_dirs[@]}"
do
chmod -R 755 "$chmod_dir"
done
chown -R $ownergroup $webdir/$name
echo "* Generating the application key."
log "php artisan key:generate --force"
echo "* Artisan Migrate."
log "php artisan migrate --force"
echo "* Creating scheduler cron."
(crontab -l ; echo "* * * * * /usr/bin/php $webdir/$name/artisan schedule:run >> /dev/null 2>&1") | crontab -
} }
#CentOS Friendly f(x)s #CentOS Friendly f(x)s
@ -140,7 +171,7 @@ echo "
" "
echo "" echo ""
echo " Welcome to Snipe-IT Inventory Installer for Centos, Debian and Ubuntu!" echo " Welcome to Snipe-IT Inventory Installer for CentOS, Debian and Ubuntu!"
echo "" echo ""
shopt -s nocasematch shopt -s nocasematch
case $distro in case $distro in
@ -171,6 +202,7 @@ fi
echo " Setting to $fqdn" echo " Setting to $fqdn"
echo "" echo ""
ans=default
until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do
echo -n " Q. Do you want to automatically create the database user password? (y/n) " echo -n " Q. Do you want to automatically create the database user password? (y/n) "
read setpw read setpw
@ -201,6 +233,8 @@ case $distro in
if [[ "$version" =~ ^9 ]]; then if [[ "$version" =~ ^9 ]]; then
##################################### Install for Debian 9 ############################################## ##################################### Install for Debian 9 ##############################################
webdir=/var/www webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
echo "* Updating with apt-get update." echo "* Updating with apt-get update."
log "apt-get update" & pid=$! log "apt-get update" & pid=$!
@ -210,50 +244,31 @@ case $distro in
log "apt-get -y upgrade" & pid=$! log "apt-get -y upgrade" & pid=$!
progress progress
echo "* Installing httpd, PHP, MariaDB and other requirements." echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip" & pid=$! log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip" & pid=$!
progress progress
log "a2enmod rewrite" log "a2enmod rewrite"
echo "* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $webdir/$name" & pid=$!
progress
echo "* Configuring .env file."
tzone=$(cat /etc/timezone)
setenv
echo "* Creating the new virtual host in Apache." echo "* Creating the new virtual host in Apache."
vhenvfile setvhdebian
echo >> $hosts "127.0.0.1 $hostname $fqdn" echo >> $hosts "127.0.0.1 $hostname $fqdn"
a2ensite $name.conf
echo "* Securing MariaDB server."; echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation /usr/bin/mysql_secure_installation
echo "* Creating MariaDB Database/User." echo "* Creating MariaDB Database/User."
echo "* Please Input your MariaDB root password:" echo "* Please Input your MariaDB root password:"
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
echo "* Installing and running composer." installsnipeit
installcomposer
echo "* Setting permissions." echo "* Restarting Apache httpd."
perms log "service apache2 restart"
chown -R www-data:www-data "/var/www/$name"
service apache2 restart
echo "* Generating the application key."
php artisan key:generate --force
echo "* Artisan Migrate."
php artisan migrate --force
else else
echo "Unable to Handle Debian Version #. Version Found: " $version echo "Unsupported Debian version. Version found: " $version
return 1 return 1
fi fi
;; ;;
@ -261,6 +276,8 @@ case $distro in
if [[ "$version" =~ 1[6-7] ]]; then if [[ "$version" =~ 1[6-7] ]]; then
##################################### Install for Ubuntu 16-17 ############################################## ##################################### Install for Ubuntu 16-17 ##############################################
webdir=/var/www webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
echo "* Adding MariaDB repository." echo "* Adding MariaDB repository."
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8" log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8"
@ -268,14 +285,15 @@ case $distro in
echo "* Updating with apt-get update." echo "* Updating with apt-get update."
log "apt-get update" & pid=$! log "apt-get update" & pid=$!
[ -f /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock #https://wiki.debian.org/Teams/Dpkg/FAQ#Q:_What_can_be_done_when_the_dpkg_lock_is_held.3F
#[ -f /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock
progress progress
echo "* Upgrading packages with apt-get upgrade." echo "* Upgrading packages with apt-get upgrade."
log "apt-get -y upgrade" & pid=$! log "apt-get -y upgrade" & pid=$!
progress progress
echo "* Installing httpd, PHP, MariaDB and other requirements." echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip" & pid=$! log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip" & pid=$!
progress progress
@ -283,45 +301,29 @@ case $distro in
log "phpenmod mbstring" log "phpenmod mbstring"
log "a2enmod rewrite" log "a2enmod rewrite"
echo "* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $webdir/$name" & pid=$!
progress
echo "* Configuring .env file."
tzone=$(cat /etc/timezone)
setenv
echo "* Creating the new virtual host in Apache." echo "* Creating the new virtual host in Apache."
vhenvfile setvhdebian
echo "* Starting the MariaDB server."; echo "* Starting MariaDB."
service mysql status >/dev/null || service mysql start log "service mysql start"
echo "* Securing MariaDB server."; echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation /usr/bin/mysql_secure_installation
echo "* Creating MariaDB Database/User." echo "* Creating MariaDB Database/User."
echo "* Please Input your MariaDB root password:" echo "* Please Input your MariaDB root password:"
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
echo "* Installing and running composer." installsnipeit
installcomposer
echo "* Setting permissions." echo "* Restarting Apache httpd."
perms log "service apache2 restart"
chown -R www-data:www-data "/var/www/$name"
service apache2 restart
echo "* Generating the application key."
php artisan key:generate --force
echo "* Artisan Migrate."
php artisan migrate --force
elif [[ "$version" =~ 14 ]]; then elif [[ "$version" =~ 14 ]]; then
##################################### Install for Ubuntu 14 ############################################## ##################################### Install for Ubuntu 14 ##############################################
webdir=/var/www webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
echo "* Adding MariaDB and ppa:ondrej/php repositories." echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db" log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db"
@ -331,14 +333,15 @@ case $distro in
echo "* Updating with apt-get update." echo "* Updating with apt-get update."
log "apt-get update" & pid=$! log "apt-get update" & pid=$!
[ -f /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock #https://wiki.debian.org/Teams/Dpkg/FAQ#Q:_What_can_be_done_when_the_dpkg_lock_is_held.3F
#[ -f /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock
progress progress
echo "* Upgrading packages with apt-get upgrade." echo "* Upgrading packages with apt-get upgrade."
log "apt-get -y upgrade" & pid=$! log "apt-get -y upgrade" & pid=$!
progress progress
echo "* Installing httpd, PHP, MariaDB and other requirements." echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client php7.1 php7.1-mcrypt php7.1-curl php7.1-mysql php7.1-gd php7.1-ldap php7.1-zip php7.1-mbstring php7.1-xml php7.1-bcmath curl git unzip" & pid=$! log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client php7.1 php7.1-mcrypt php7.1-curl php7.1-mysql php7.1-gd php7.1-ldap php7.1-zip php7.1-mbstring php7.1-xml php7.1-bcmath curl git unzip" & pid=$!
progress progress
@ -346,53 +349,37 @@ case $distro in
log "phpenmod mbstring" log "phpenmod mbstring"
log "a2enmod rewrite" log "a2enmod rewrite"
echo "* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $webdir/$name" & pid=$!
progress
echo "* Configuring .env file."
tzone=$(cat /etc/timezone)
setenv
echo "* Creating the new virtual host in Apache." echo "* Creating the new virtual host in Apache."
vhenvfile setvhdebian
echo "* Starting the MariaDB server."; echo "* Starting MariaDB."
service mysql status >/dev/null || service mysql start log "service mysql start"
echo "* Securing MariaDB server."; echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation /usr/bin/mysql_secure_installation
echo "* Creating MariaDB Database/User." echo "* Creating MariaDB Database/User."
echo "* Please Input your MariaDB root password:" echo "* Please Input your MariaDB root password:"
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
echo "* Installing and running composer." installsnipeit
installcomposer
echo "* Setting permissions." echo "* Restarting Apache httpd."
perms log "service apache2 restart"
chown -R www-data:www-data "/var/www/$name"
service apache2 restart
echo "* Generating the application key."
php artisan key:generate --force
echo "* Artisan Migrate."
php artisan migrate --force
else else
echo "Unable to Handle Ubuntu Version #. Version Found: " $version echo "Unsupported Ubuntu version. Version found: " $version
return 1 return 1
fi fi
;; ;;
centos) centos)
if [[ "$version" =~ ^6 ]]; then if [[ "$version" =~ ^6 ]]; then
##################################### Install for Centos/Redhat 6 ############################################## ##################################### Install for CentOS/Redhat 6 ##############################################
webdir=/var/www/html webdir=/var/www/html
ownergroup=apache:apache
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
echo "* Adding IUS, epel-release and MariaDB repositories."; 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"
{ {
@ -408,7 +395,7 @@ case $distro in
log "yum -y install https://centos6.iuscommunity.org/ius-release.rpm" log "yum -y install https://centos6.iuscommunity.org/ius-release.rpm"
log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY" log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY"
echo "* Installing httpd, PHP, MariaDB and other requirements."; echo "* Installing Apache httpd, PHP, MariaDB 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" 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
@ -420,15 +407,11 @@ case $distro in
fi fi
done; done;
echo "* Cloning Snipe-IT from github to the web directory."; echo "* Setting MariaDB to start on boot and starting MariaDB."
log "git clone https://github.com/snipe/snipe-it $webdir/$name" log "chkconfig mysql on"
log "/sbin/service mysql start"
# Make mariaDB start on boot and restart the daemon echo "* Securing MariaDB."
echo "* Starting the MariaDB server.";
chkconfig mysql on
/sbin/service mysql start
echo "* Securing MariaDB server.";
/usr/bin/mysql_secure_installation /usr/bin/mysql_secure_installation
echo "* Creating MariaDB Database/User." echo "* Creating MariaDB Database/User."
@ -437,45 +420,11 @@ case $distro in
#Create the new virtual host in Apache and enable rewrite #Create the new virtual host in Apache and enable rewrite
echo "* Creating the new virtual host in Apache." echo "* Creating the new virtual host in Apache."
apachefile=/etc/httpd/conf.d/$name.conf setvhcentos
{ echo "* Setting up hosts file."
echo ""
echo ""
echo ""
echo "<VirtualHost *:80>"
echo "ServerAdmin webmaster@localhost"
echo " <Directory $webdir/$name/public>"
echo " Allow From All"
echo " AllowOverride All"
echo " Options +Indexes"
echo " </Directory>"
echo " DocumentRoot $webdir/$name/public"
echo " ServerName $fqdn"
echo " ErrorLog /var/log/httpd/snipeIT.error.log"
echo " CustomLog /var/log/access.log combined"
echo "</VirtualHost>"
} >> "$apachefile"
echo "* Setting up hosts file.";
echo >> $hosts "127.0.0.1 $hostname $fqdn" echo >> $hosts "127.0.0.1 $hostname $fqdn"
# Make apache start on boot and restart the daemon
echo "* Starting the apache server.";
chkconfig httpd on
/sbin/service httpd start
echo "* Configuring .env file."
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
setenv
echo "* Installing and running composer."
installcomposer
echo "* Setting permissions."
perms
chown -R apache:apache $webdir/$name
/sbin/service iptables status >/dev/null 2>&1 /sbin/service iptables status >/dev/null 2>&1
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo "* Configuring iptables." echo "* Configuring iptables."
@ -484,24 +433,24 @@ case $distro in
service iptables save service iptables save
fi fi
service httpd restart installsnipeit
echo "* Generating the application key." echo "* Setting Apache httpd to start on boot and starting service."
php artisan key:generate --force log "chkconfig httpd on"
log "/sbin/service httpd start"
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 ##############################################
webdir=/var/www/html webdir=/var/www/html
ownergroup=apache:apache
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
echo "* Adding IUS, epel-release and MariaDB repositories."; echo "* Adding IUS, epel-release and MariaDB repositories."
log "yum -y install wget epel-release" log "yum -y install wget epel-release"
log "yum -y install https://centos7.iuscommunity.org/ius-release.rpm" log "yum -y install https://centos7.iuscommunity.org/ius-release.rpm"
log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY" log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY"
echo "* Installing httpd, PHP, MariaDB and other requirements."; echo "* Installing Apache httpd, PHP, MariaDB 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" 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
@ -513,15 +462,11 @@ case $distro in
fi fi
done; done;
echo "* Cloning Snipe-IT from github to the web directory."; echo "* Setting MariaDB to start on boot and starting MariaDB."
log "git clone https://github.com/snipe/snipe-it $webdir/$name" log "systemctl enable mariadb.service"
log "systemctl start mariadb.service"
#Make mariaDB start on boot and restart the daemon echo "* Securing MariaDB."
echo "* Starting the MariaDB server.";
systemctl enable mariadb.service
systemctl start mariadb.service
echo "* Securing MariaDB server.";
/usr/bin/mysql_secure_installation /usr/bin/mysql_secure_installation
echo "* Creating MariaDB Database/User." echo "* Creating MariaDB Database/User."
@ -531,46 +476,13 @@ case $distro in
#TODO make sure the apachefile doesnt exist isnt already in there #TODO make sure the apachefile doesnt exist isnt already in there
#Create the new virtual host in Apache and enable rewrite #Create the new virtual host in Apache and enable rewrite
echo "* Creating the new virtual host in Apache." echo "* Creating the new virtual host in Apache."
apachefile="/etc/httpd/conf.d/$name.conf" setvhcentos
{
echo ""
echo ""
echo "LoadModule rewrite_module modules/mod_rewrite.so"
echo ""
echo "<VirtualHost *:80>"
echo "ServerAdmin webmaster@localhost"
echo " <Directory $webdir/$name/public>"
echo " Allow From All"
echo " AllowOverride All"
echo " Options +Indexes"
echo " </Directory>"
echo " DocumentRoot $webdir/$name/public"
echo " ServerName $fqdn"
echo " ErrorLog /var/log/httpd/snipeIT.error.log"
echo " CustomLog /var/log/access.log combined"
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 "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn" echo >> $hosts "127.0.0.1 $hostname $fqdn"
echo "* Starting the apache server."; installsnipeit
systemctl enable httpd.service
systemctl restart httpd.service
echo "* Configuring .env file."
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
setenv
echo "* Installing and running composer."
installcomposer
echo "* Setting permissions."
perms
chown -R apache:apache $webdir/$name
#Check if SELinux is enforcing #Check if SELinux is enforcing
if [ "$(getenforce)" == "Enforcing" ]; then if [ "$(getenforce)" == "Enforcing" ]; then
@ -581,19 +493,12 @@ case $distro in
chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/
fi fi
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
log "systemctl restart httpd.service" log "systemctl restart httpd.service"
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 "Unsupported CentOS version. Version found: " $version
return 1 return 1
fi fi
esac esac