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
74 lines
3.4 KiB
Bash
74 lines
3.4 KiB
Bash
#PHP Pool
|
|
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/nextcloud/Fpm-Pool.conf-unconfigured -o "$phpPoolDir"/"$sitename".conf
|
|
sed -i -e 's/PHPver/'$phpver'/g' -e 's/SITEname/'$sitename'/g' -e 's/DOMAINname/'$domain'/g' "$phpPoolDir"/$sitename.conf
|
|
groupadd "$sitename"
|
|
useradd -g "$sitename" "$sitename"
|
|
usermod -a -G www-data "$sitename"
|
|
mkdir -p /var/www/"$domain"/html/data
|
|
|
|
#Getting Nextcloud
|
|
curl --retry 7 --retry-delay 5 -s http://mirror.nxdi.nl/resources/nextcloud/latest.tar.bz2 -o /tmp/nextcloud.tar.bz2
|
|
tar jxf /tmp/nextcloud.tar.bz2 -C /tmp
|
|
cp -a /tmp/nextcloud/. /var/www/"$domain"/html
|
|
touch /var/www/"$domain"/html/data/nextcloud.log > $OUTPUT 2>&1
|
|
|
|
#Creating DB
|
|
db_name="nextcloud_$SiteCount"
|
|
db_user="nextcloud_$SiteCount"
|
|
db_pass=$(tr -dc 'A-Za-z0-9!#%()*+,-.:;<=>?@[]^_{|}~' </dev/urandom | head -c 30 ; echo)
|
|
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
|
|
|
|
#Configuring Nextcloud
|
|
cat <<EOF > /var/www/$domain/html/config/autoconfig.php
|
|
<?php
|
|
\$AUTOCONFIG = array(
|
|
"dbtype" => "mysql",
|
|
"dbname" => "${db_name}",
|
|
"dbuser" => "${db_user}",
|
|
"dbpass" => "${db_pass}",
|
|
"dbhost" => "127.0.0.1",
|
|
"dbtableprefix" => "",
|
|
"simpleSignUpLink.shown" => false,
|
|
"directory" => "/var/www/$domain/html/data",
|
|
);
|
|
EOF
|
|
|
|
#Setting Permsissions
|
|
chown "$sitename":"$sitename" -R /var/www/"$domain"/html
|
|
|
|
if [ "$shortdist" = "el8" ]; then
|
|
#Setting SeLiux perms for centos
|
|
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/$domain/html(/.*)?" > $OUTPUT 2>&1
|
|
restorecon -r /var/www/ > $OUTPUT 2>&1
|
|
fi
|
|
|
|
#Enable PHP-ACPU on CLI
|
|
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] || [ "$shortdist" = "deb11" ] ; then
|
|
if ! grep -Fxq "apc.enable_cli=1" /etc/php/${phpver}/mods-available/apcu.ini; then
|
|
echo "apc.enable_cli=1" >> /etc/php/${phpver}/mods-available/apcu.ini
|
|
fi
|
|
elif [ "$shortdist" = "el8" ]; then
|
|
sed -i "/apc.enable_cli/c\apc.enable_cli=1" /etc/opt/remi/php${phpver//.}/php.d/40-apcu.ini
|
|
fi
|
|
|
|
#PHP 8.0 Settings
|
|
if [ "$phpVerBranch" = "8x" ]; then
|
|
sed -i "/opcache.enable/c\php_admin_value[opcache.enable] = 1" "$phpPoolDir"/"$sitename".conf
|
|
fi
|
|
|
|
#Makeing nextcloud Finalize script and setting login Notice
|
|
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/nextcloud/nextcloud-init.sh -o ~/NextcloudInit-"$sitename".sh
|
|
sed -i -e 's/DOMAINname/'$domain'/' -e 's/SITEname/'$sitename'/' ~/NextcloudInit-"$sitename".sh
|
|
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/nextcloud/MotdNextCloud -o /etc/update-motd.d/51-nextnotice-"${sitename//_}"
|
|
sed -i -e 's/SITEname/'$sitename'/' /etc/update-motd.d/51-nextnotice-"${sitename//_}"
|
|
chmod +x /etc/update-motd.d/51-nextnotice-"${sitename//_}"
|
|
|
|
|
|
#fail2ban
|
|
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/config/fail2ban/Jails/nextcloud_unconfigured -o /etc/fail2ban/jail.d/"$sitename"-nextcloud.local
|
|
sed -i 's/DOMain/'$domain'/' /etc/fail2ban/jail.d/"$sitename"-nextcloud.local
|
|
|
|
systemctl reload "$phpFPMService" |