1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-23 02:27:05 +00:00

Place the PHP version into a variable (#2307)

Also
- trims a few trailing whitespace characters
- gitignores VS code workspace
This commit is contained in:
Michael Heuberger 2023-10-01 18:13:27 +13:00
parent 8e4e9add78
commit 2a0cd8bfd8
13 changed files with 647 additions and 703 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ externals/
.env .env
.vagrant .vagrant
api/docs/api-docs.html api/docs/api-docs.html
*.code-workspace

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,6 @@
## your own --- please do not ask for help from us. ## your own --- please do not ask for help from us.
upstream php-fpm { upstream php-fpm {
server unix:/var/run/php/php8.0-fpm.sock; server unix:/var/run/php/php{{phpver}}-fpm.sock;
} }

View File

@ -12,7 +12,7 @@ import dateutil.parser, dateutil.relativedelta, dateutil.tz
import rtyaml import rtyaml
from exclusiveprocess import Lock from exclusiveprocess import Lock
from utils import load_environment, shell, wait_for_service from utils import load_environment, shell, wait_for_service, get_php_version
def backup_status(env): def backup_status(env):
# If backups are dissbled, return no status. # If backups are dissbled, return no status.
@ -262,6 +262,7 @@ def get_target_type(config):
def perform_backup(full_backup): def perform_backup(full_backup):
env = load_environment() env = load_environment()
php_fpm = f"php{get_php_version()}-fpm"
# Create an global exclusive lock so that the backup script # Create an global exclusive lock so that the backup script
# cannot be run more than one. # cannot be run more than one.
@ -297,7 +298,7 @@ def perform_backup(full_backup):
if quit: if quit:
sys.exit(code) sys.exit(code)
service_command("php8.0-fpm", "stop", quit=True) service_command(php_fpm, "stop", quit=True)
service_command("postfix", "stop", quit=True) service_command("postfix", "stop", quit=True)
service_command("dovecot", "stop", quit=True) service_command("dovecot", "stop", quit=True)
service_command("postgrey", "stop", quit=True) service_command("postgrey", "stop", quit=True)
@ -334,7 +335,7 @@ def perform_backup(full_backup):
service_command("postgrey", "start", quit=False) service_command("postgrey", "start", quit=False)
service_command("dovecot", "start", quit=False) service_command("dovecot", "start", quit=False)
service_command("postfix", "start", quit=False) service_command("postfix", "start", quit=False)
service_command("php8.0-fpm", "start", quit=False) service_command(php_fpm, "start", quit=False)
# Remove old backups. This deletes all backup data no longer needed # Remove old backups. This deletes all backup data no longer needed
# from more than 3 days ago. # from more than 3 days ago.

View File

@ -178,6 +178,10 @@ def wait_for_service(port, public, env, timeout):
return False return False
time.sleep(min(timeout/4, 1)) time.sleep(min(timeout/4, 1))
def get_php_version():
# Gets the version of PHP installed in the system.
return shell("check_output", ["/usr/bin/php", "-v"])[4:7]
if __name__ == "__main__": if __name__ == "__main__":
from web_update import get_web_domains from web_update import get_web_domains
env = load_environment() env = load_environment()

View File

@ -7,7 +7,7 @@ import os.path, re, rtyaml
from mailconfig import get_mail_domains from mailconfig import get_mail_domains
from dns_update import get_custom_dns_config, get_dns_zones from dns_update import get_custom_dns_config, get_dns_zones
from ssl_certificates import get_ssl_certificates, get_domain_ssl_files, check_certificate from ssl_certificates import get_ssl_certificates, get_domain_ssl_files, check_certificate
from utils import shell, safe_domain_name, sort_domains from utils import shell, safe_domain_name, sort_domains, get_php_version
def get_web_domains(env, include_www_redirects=True, include_auto=True, exclude_dns_elsewhere=True): def get_web_domains(env, include_www_redirects=True, include_auto=True, exclude_dns_elsewhere=True):
# What domains should we serve HTTP(S) for? # What domains should we serve HTTP(S) for?
@ -83,6 +83,7 @@ def do_web_update(env):
# Build an nginx configuration file. # Build an nginx configuration file.
nginx_conf = read_conf("nginx-top.conf") nginx_conf = read_conf("nginx-top.conf")
nginx_conf = re.sub("{{phpver}}", get_php_version(), nginx_conf)
# Load the templates. # Load the templates.
template0 = read_conf("nginx.conf") template0 = read_conf("nginx.conf")

View File

@ -4,6 +4,8 @@
# -o pipefail: don't ignore errors in the non-last command in a pipeline # -o pipefail: don't ignore errors in the non-last command in a pipeline
set -euo pipefail set -euo pipefail
# This global variable pinpoints the PHP version for the whole MiaB app
# Upgrade it only with care and tests. Nextcloud versions depend on it.
PHP_VER=8.0 PHP_VER=8.0
function hide_output { function hide_output {

View File

@ -1,3 +1,5 @@
#!/bin/bash #!/bin/bash
# This script has moved. # This script has moved.
# Yet, keep it for some users still calling it (backward compatibility)
management/cli.py "$@" management/cli.py "$@"

View File

@ -26,7 +26,7 @@ if [ ! -f $1/config.php ]; then
fi fi
echo "Restoring backup from $1" echo "Restoring backup from $1"
service php8.0-fpm stop service php$PHP_VER-fpm stop
# remove the current ownCloud/Nextcloud installation # remove the current ownCloud/Nextcloud installation
rm -rf /usr/local/lib/owncloud/ rm -rf /usr/local/lib/owncloud/
@ -45,5 +45,5 @@ chown www-data:www-data $STORAGE_ROOT/owncloud/config.php
sudo -u www-data php$PHP_VER /usr/local/lib/owncloud/occ maintenance:mode --off sudo -u www-data php$PHP_VER /usr/local/lib/owncloud/occ maintenance:mode --off
service php8.0-fpm start service php$PHP_VER-fpm start
echo "Done" echo "Done"

View File

@ -8,7 +8,7 @@
source /etc/mailinabox.conf # load global vars source /etc/mailinabox.conf # load global vars
ADMIN=$(./mail.py user admins | head -n 1) ADMIN=$(./management/cli.py user admins | head -n 1)
test -z "$1" || ADMIN=$1 test -z "$1" || ADMIN=$1
echo I am going to unlock admin features for $ADMIN. echo I am going to unlock admin features for $ADMIN.