Added tuning for Postgresql and Nextcloud for starter tier

This commit is contained in:
root 2024-02-22 15:46:10 +00:00
parent 8cc55958b4
commit a0c832a825
3 changed files with 58 additions and 4 deletions

View File

@ -1367,7 +1367,48 @@ get_appvars() {
# If COTURN_MATRIX_SECRET exists in turnserver.conf then use it, otherwise create the password
[[ $(grep static-auth-secret /federated/apps/coturn/data/etc/turnserver.conf 2>/dev/null | awk -F= '{ print $2 }') ]] && COTURN_MATRIX_SECRET=$(grep static-auth-secret /federated/apps/coturn/data/etc/turnserver.conf 2>/dev/null | awk -F= '{ print $2 }') || COTURN_MATRIX_SECRET=$(create_password);
# If LISTMONKPASS doesn't exist in /etc/federated then create it. Otherwise get it from /etc/federated
[[ ! $(grep LISTMONKPASS /etc/federated | awk -F\" '{ print $2 }') ]] && LISTMONKPASS=$(create_password) || LISTMONKPASS=$(grep LISTMONKPASS /etc/federated | awk -F\" '{ print $2 }')
# If gitea token file exists then set it as the variable. Otherwise create it. Used for caddy / gitea webhook
[[ -f "/federated/apps/gitea/.gitea.token.1" ]] && GITEA_TOKEN_1=$(cat /federated/apps/gitea/.gitea.token.1) || GITEA_TOKEN_1=$(create_password)
# If webhook file exists then set it as the variable. Otherwise create it. Used for caddy / gitea webhook
if [[ -f "/federated/apps/gitea/.webhook.secret" ]]; then
WEBHOOK_SECRET=$(cat /federated/apps/gitea/.webhook.secret)
else
WEBHOOK_SECRET=$(create_password)
echo "$WEBHOOK_SECRET" > /federated/apps/gitea/.webhook.secret
fi
# Get LDAP DOMAIN from ldap its self and setup variables for each part
LDAP_DOMAIN=$(docker exec ldap slapcat | grep "dn:" | head -1 | awk -F: '{ print $2 }')
# Setup LDAP_DOMAIN variable for domain or subdomain
LDAP_DOMAIN_ARRAY=(${LDAP_DOMAIN//,/ })
if [ "${#LDAP_DOMAIN_ARRAY[@]}" -eq "2" ]; then
LDAP_DOMAIN_FIRST=$(echo "${LDAP_DOMAIN_ARRAY[0]}" | awk -F= '{ print $2 }')
LDAP_DOMAIN_LAST=$(echo "${LDAP_DOMAIN_ARRAY[1]}" | awk -F= '{ print $2 }')
elif [ "${#LDAP_DOMAIN_ARRAY[@]}" -eq "3" ]; then
LDAP_DOMAIN_FIRST=$(echo "${LDAP_DOMAIN_ARRAY[0]}" | awk -F= '{ print $2 }')
LDAP_DOMAIN_MIDDLE=$(echo "${LDAP_DOMAIN_ARRAY[1]}" | awk -F= '{ print $2 }')
LDAP_DOMAIN_LAST=$(echo "${LDAP_DOMAIN_ARRAY[2]}" | awk -F= '{ print $2 }')
fi
# Set SMTP user based on if fcore exists
[[ $(docker exec ldap slapcat | grep fcore) ]] && SMTPUSER="fcore" || SMTPUSER="admin"
}
get_appvars_old() {
LDAP_SECRET=`cat /federated/apps/ldap/.ldap.secret`
EXTERNALIP=$(get_externalip);
MYSQL_ROOTPASSWORD=`cat /federated/apps/pdnsmysql/.env | grep MYSQL_ROOT_PASSWORD | awk -F= '{ print $2 }'`
# If ADMINPASS doesn't exist in /etc/federated then use nextcloud to get it. Otherwise get it from /etc/federated
[[ ! $(grep ADMINPASS /etc/federated | awk -F\" '{ print $2 }') ]] && ADMINPASS=$(cat /federated/apps/nextcloud/.nextcloud.secret) || ADMINPASS=$(grep ADMINPASS /etc/federated | awk -F\" '{ print $2 }')
# If COTURN_MATRIX_SECRET exists in turnserver.conf then use it, otherwise create the password
[[ $(grep static-auth-secret /federated/apps/coturn/data/etc/turnserver.conf 2>/dev/null | awk -F= '{ print $2 }') ]] && COTURN_MATRIX_SECRET=$(grep static-auth-secret /federated/apps/coturn/data/etc/turnserver.conf 2>/dev/null | awk -F= '{ print $2 }') || COTURN_MATRIX_SECRET=$(create_password);
# Set SMTP user based on if fcore exists
[[ $(docker exec ldap slapcat | grep fcore) ]] && SMTPUSER="fcore" || SMTPUSER="admin"
}

View File

@ -116,6 +116,12 @@ apc.gc_ttl=3600
apc.max_file_size=2M
EOF
if [[ "$BUNDLE" = "starter" ]]; then
sed -i "s/2048M/96M/g" /federated/apps/nextcloud/.env
sed -i "s/256/64/g" /federated/apps/nextcloud/data/usr/local/etc/php/conf.d/opcache-recommended.ini
sed -i "s/256M/64M/g" /federated/apps/nextcloud/data/usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
fi
cat > /federated/apps/nextcloud/data/configs.json <<EOF
{
"system": {

View File

@ -102,10 +102,17 @@ start_postgresql() {
start_service "postgresql" "nc -z 172.99.0.14 5432 &> /dev/null" "18"
# Tune PostgreSQL
sed -i "s#shared_buffers =.*#shared_buffers = 800MB#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s#max_connections =.*#max_connections = 400#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s/#work_mem =.*/work_mem = 16MB/g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s/#maintenance_work_mem =.*/maintenance_work_mem = 128MB/g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
if [[ "$BUNDLE" = "starter" ]]; then
sed -i "s#shared_buffers =.*#shared_buffers = 50MB#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s#max_connections =.*#max_connections = 400#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s/#work_mem =.*/work_mem = 4MB/g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s/#maintenance_work_mem =.*/maintenance_work_mem = 50MB/g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
else
sed -i "s#shared_buffers =.*#shared_buffers = 800MB#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s#max_connections =.*#max_connections = 400#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s/#work_mem =.*/work_mem = 16MB/g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
sed -i "s/#maintenance_work_mem =.*/maintenance_work_mem = 128MB/g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf
fi
# Restart PostgreSQL
/federated/bin/stop postgresql &> /dev/null