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:
parent
8e4e9add78
commit
2a0cd8bfd8
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@ tools/__pycache__/
|
|||||||
externals/
|
externals/
|
||||||
.env
|
.env
|
||||||
.vagrant
|
.vagrant
|
||||||
api/docs/api-docs.html
|
api/docs/api-docs.html
|
||||||
|
*.code-workspace
|
||||||
|
1309
CHANGELOG.md
1309
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@ -79,7 +79,7 @@ This is a challenge faced by everyone who runs their own mail server, with or wi
|
|||||||
Contributing and Development
|
Contributing and Development
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
Mail-in-a-Box is an open source project. Your contributions and pull requests are welcome. See [CONTRIBUTING](CONTRIBUTING.md) to get started.
|
Mail-in-a-Box is an open source project. Your contributions and pull requests are welcome. See [CONTRIBUTING](CONTRIBUTING.md) to get started.
|
||||||
|
|
||||||
|
|
||||||
The Acknowledgements
|
The Acknowledgements
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
@ -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()
|
||||||
|
@ -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")
|
||||||
|
@ -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 {
|
||||||
|
@ -124,7 +124,7 @@ chmod a+r /var/lib/mailinabox/mozilla-autoconfig.xml
|
|||||||
|
|
||||||
# Create a generic mta-sts.txt file which is exposed via the
|
# Create a generic mta-sts.txt file which is exposed via the
|
||||||
# nginx configuration at /.well-known/mta-sts.txt
|
# nginx configuration at /.well-known/mta-sts.txt
|
||||||
# more documentation is available on:
|
# more documentation is available on:
|
||||||
# https://www.uriports.com/blog/mta-sts-explained/
|
# https://www.uriports.com/blog/mta-sts-explained/
|
||||||
# default mode is "enforce". In /etc/mailinabox.conf change
|
# default mode is "enforce". In /etc/mailinabox.conf change
|
||||||
# "MTA_STS_MODE=testing" which means "Messages will be delivered
|
# "MTA_STS_MODE=testing" which means "Messages will be delivered
|
||||||
|
@ -41,7 +41,7 @@ if [ $needs_update == 1 ]; then
|
|||||||
mv /tmp/z-push/*/src /usr/local/lib/z-push
|
mv /tmp/z-push/*/src /usr/local/lib/z-push
|
||||||
rm -rf /tmp/z-push.zip /tmp/z-push
|
rm -rf /tmp/z-push.zip /tmp/z-push
|
||||||
|
|
||||||
# Create admin and top scripts with PHP_VER
|
# Create admin and top scripts with PHP_VER
|
||||||
rm -f /usr/sbin/z-push-{admin,top}
|
rm -f /usr/sbin/z-push-{admin,top}
|
||||||
echo '#!/bin/bash' > /usr/sbin/z-push-admin
|
echo '#!/bin/bash' > /usr/sbin/z-push-admin
|
||||||
echo php$PHP_VER /usr/local/lib/z-push/z-push-admin.php '"$@"' >> /usr/sbin/z-push-admin
|
echo php$PHP_VER /usr/local/lib/z-push/z-push-admin.php '"$@"' >> /usr/sbin/z-push-admin
|
||||||
@ -49,7 +49,7 @@ if [ $needs_update == 1 ]; then
|
|||||||
echo '#!/bin/bash' > /usr/sbin/z-push-top
|
echo '#!/bin/bash' > /usr/sbin/z-push-top
|
||||||
echo php$PHP_VER /usr/local/lib/z-push/z-push-top.php '"$@"' >> /usr/sbin/z-push-top
|
echo php$PHP_VER /usr/local/lib/z-push/z-push-top.php '"$@"' >> /usr/sbin/z-push-top
|
||||||
chmod 755 /usr/sbin/z-push-top
|
chmod 755 /usr/sbin/z-push-top
|
||||||
|
|
||||||
echo $VERSION > /usr/local/lib/z-push/version
|
echo $VERSION > /usr/local/lib/z-push/version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -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 "$@"
|
||||||
|
@ -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"
|
||||||
|
@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
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.
|
||||||
echo You can provide another user to unlock as the first argument of this script.
|
echo You can provide another user to unlock as the first argument of this script.
|
||||||
echo
|
echo
|
||||||
echo WARNING: you could break mail-in-a-box when fiddling around with Nextcloud\'s admin interface
|
echo WARNING: you could break mail-in-a-box when fiddling around with Nextcloud\'s admin interface
|
||||||
echo If in doubt, press CTRL-C to cancel.
|
echo If in doubt, press CTRL-C to cancel.
|
||||||
echo
|
echo
|
||||||
echo Press enter to continue.
|
echo Press enter to continue.
|
||||||
read
|
read
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user