Switch from geting folder count in /var/www to using SiteCount variable stored in /etc/ICTM/sites.count, installer.sh has static 1, AppendCMS gets the file an increments it by one. Fallback is build in for systems without sites.count
41 lines
1.7 KiB
Bash
41 lines
1.7 KiB
Bash
#Creating DB
|
|
db_name="fc_$SiteCount"
|
|
db_user="fc_$SiteCount"
|
|
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/frontcontroller/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"
|
|
usermod -a -G www-data "$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
|