Files
VPS-scripts_Web-V2/CMS/frontcontroller/conf.sh

41 lines
1.7 KiB
Bash

#Creating DB
db_suffix=`expr $(ls -l /var/www | grep -c ^d) - 1`
db_name="fc_$db_suffix"
db_user="fc_$db_suffix"
db_pass=$(tr -dc 'A-Za-z0-9!#%()*+,-.:;<=>?@[]^_{|}~' </dev/urandom | head -c 30 ; echo)
#Storing DB Credentials
echo "Database Name $db_name" > ~/DB_"$sitename"
echo "Database Username $db_user" >> ~/DB_"$sitename"
echo "Database Password $db_pass" >> ~/DB_"$sitename"
#Setting up Database
mysql -u root -p"$password" -e "CREATE DATABASE "$db_name" DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "CREATE USER '"$db_user"'@'localhost' IDENTIFIED BY '"$db_pass"';" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "GRANT ALL ON "$db_name".* TO '"$db_user"'@'localhost';" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "FLUSH PRIVILEGES;" > $OUTPUT 2>&1
#Creating webfolder
mkdir -p /var/www/"$domain"/public
#Ceating content
echo "<html><head></head><body>$webserv has been succsefully installed by the Wizard<br>Ready for FontControler installation</body></html>" > /var/www/$domain/public/index.html
#Setup PHP Pool
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/none/Fpm-Pool.conf-unconfigured -o "$phpPoolDir"/"$sitename".conf
sed -i -e 's/PHPver/'$phpver'/g' -e 's/SITEname/'$sitename'/g' -e 's/DOMAINname/'$domain'/' "$phpPoolDir"/$sitename.conf
groupadd "$sitename"
useradd -g "$sitename" "$sitename"
systemctl reload $phpFPMService
#Setting Permsissions
chown "$sitename":"$sitename" -R /var/www/"$domain"/
if [ "$shortdist" = "el8" ]; then
#Setting SeLiux perms for centos
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/$domain/(/.*)?" > $OUTPUT 2>&1
restorecon -r /var/www/ > $OUTPUT 2>&1
fi