Skip to content

Commit

Permalink
Merge branch 'testing' into curl-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexAubin authored Aug 29, 2024
2 parents e9a7d0e + 047cfa3 commit 4553fd1
Show file tree
Hide file tree
Showing 18 changed files with 400 additions and 18 deletions.
3 changes: 2 additions & 1 deletion conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"verify_peer": false,
"verify_peer_name": false
}
}
},
"trusted_proxies": [ "127.0.0.1", "::1" ]
},
"apps": {
"user_ldap": {
Expand Down
2 changes: 2 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ location ^~ __PATH__/ {
try_files $uri / __PATH__/index.php$request_uri;
}

include conf.d/__DOMAIN__.d/__APP__.d/*.conf;

# show YunoHost panel access
include conf.d/yunohost_panel.conf.inc;
}
8 changes: 8 additions & 0 deletions conf/notify_push.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
location ^~ __PATH__/push/ {
proxy_pass http://unix:/var/run/__APP__/notify-push.sock:/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
13 changes: 13 additions & 0 deletions conf/systemd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description = Push daemon for Nextcloud clients

[Service]
Environment=SOCKET_PATH=/var/run/__APP__/notify-push.sock
Environment=ALLOW_SELF_SIGNED=true
ExecStart=__INSTALL_DIR__/apps/notify_push/bin/__ARCH__/notify_push __INSTALL_DIR__/config/config.php
Type=notify
User=__APP__
Group=__APP__

[Install]
WantedBy = multi-user.target
11 changes: 11 additions & 0 deletions conf/watcher.path
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Restart Push daemon for Nextcloud clients when it receives updates
Documentation=https://github.com/nextcloud/notify_push
PartOf=__APP__-notify-push-watcher.service

[Path]
PathModified=/var/www/nextcloud/apps/notify_push/bin/__ARCH__/notify_push
Unit=__APP__-notify-push-watcher.service

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions conf/watcher.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Restart Push daemon for Nextcloud clients when it receives updates
Documentation=https://github.com/nextcloud/notify_push
#Requires=__APP__-notify-push.service
After=__APP__-notify-push.service
StartLimitIntervalSec=10
StartLimitBurst=5

[Service]
Type=oneshot
ExecStartPre=/usr/bin/chmod u+x __INSTALL_DIR__/apps/notify_push/bin/__ARCH__/notify_push
ExecStart=/usr/bin/systemctl restart __APP__-notify-push.service

[Install]
WantedBy=multi-user.target
12 changes: 9 additions & 3 deletions config_panel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "Nextcloud configuration"
[main.maintenance.maintenance_mode]
ask = "Enable maintenance mode"
type = "boolean"
default = "0"
default = false

[main.maintenance.set_permissions_button]
ask.en = "Set permissions for all data (Can take up to several hours if users have a lot of data)"
Expand All @@ -22,8 +22,14 @@ name = "Nextcloud configuration"
[main.addressbook.system_addressbook_exposed]
ask = "Should there be a system address book listing all users, accessible by all users?"
type = "boolean"
yes = "yes"
no = "no"

[main.notify_push]
name = "Notify Push configuration"

[main.notify_push.enable_notify_push]
ask.en = "Configure the High Performance Backend?"
ask.fr = "Configurer le Backend Hautes Performances ?"
type = "boolean"

[main.php_fpm_config]
name = "PHP-FPM configuration"
Expand Down
4 changes: 4 additions & 0 deletions doc/ADMIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Alternatively, you may open a 'Nextcloud shell' with `sudo yunohost app shell __

ONLYOFFICE is an online rich text document editor which can be integrated in Nextcloud

#### High Performance Backend

High Performance Backend is an application on Nextcloud that should speed up the instance, more information here: https://github.com/nextcloud/notify_push#about

#### With YunoHost App (ARM64 support, better performance)

For better performance and ARM64 support (Raspberry Pi, OLinuXino...), install the [OnlyOffice YunoHost app](https://apps.yunohost.org/app/onlyoffice) and connect it to Nextcloud, see the tutorial in the [doc of onlyoffice_ynh package](https://github.com/YunoHost-Apps/onlyoffice_ynh/blob/master/README_fr.md#configuration-de-onlyoffice-server)
Expand Down
4 changes: 4 additions & 0 deletions doc/ADMIN_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Ou bien, vous pouvez ouvrir un "shell Nextcloud" avec `sudo yunohost app shell _

ONLYOFFICE est un éditeur de texte enrichi en ligne qui peut s'intégrer dans Nextcloud

#### Backend Hautes Performances

Le backend Hautes Performances est une application sur Nextcloud qui devrait accélérer l'instance, plus d'informations ici : https://github.com/nextcloud/notify_push#about

#### Avec l'application YunoHost (support ARM64, meilleures performances)

Pour de meilleures performances et le support de ARM64 (Raspberry Pi, OLinuXino...), installez l'[app YunoHost OnlyOffice](https://apps.yunohost.org/app/onlyoffice), puis connectez-la à Nextcloud : voir le tutoriel dans la [doc du paquet onlyoffice_ynh](https://github.com/YunoHost-Apps/onlyoffice_ynh/blob/master/README_fr.md#configuration-de-onlyoffice-server)
Expand Down
6 changes: 6 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ ram.runtime = "512M"
type = "boolean"
default = true

[install.enable_notify_push]
ask.en = "Configure the High Performance Backend?"
ask.fr = "Configurer le Backend Hautes Performances ?"
type = "boolean"
default = false

[resources]

[resources.sources]
Expand Down
20 changes: 19 additions & 1 deletion scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ ynh_backup --src_path="$install_dir"
ynh_backup --src_path="$data_dir" --is_big

#=================================================
# SYSTEM CONFIGURATION
# BACKUP THE NGINX CONFIGURATION
#=================================================

ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d"

#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================

# Backup the PHP-FPM configuration
Expand Down Expand Up @@ -59,6 +66,17 @@ ynh_print_info --message="Backing up the MySQL database..."

ynh_mysql_dump_db --database="$db_name" --default_character_set="utf8mb4" > db.sql

#=================================================
# BACKUP THE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
ynh_backup --src_path="/etc/systemd/system/${app}-notify-push.service"
ynh_backup --src_path="/etc/systemd/system/${app}-notify-push-watcher.service"
ynh_backup --src_path="/etc/systemd/system/${app}-notify-push-watcher.path"
fi

#=================================================
# END OF SCRIPT
#=================================================
Expand Down
50 changes: 48 additions & 2 deletions scripts/change_url
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,62 @@ then

# Reload PHP-FPM, necessary for force Nextcloud to re-read config.php, cf opcache.revalidate_freq
ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload

mv /etc/nginx/conf.d/$old_domain.d/$app.d /etc/nginx/conf.d/$new_domain.d/$app.d
fi

#=================================================
# CONFIGURE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
domain="$new_domain"
path_url="$new_path"

ynh_add_config --template="notify_push.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/notify_push.conf"

ynh_systemd_action --service_name=nginx --action=reload

case $YNH_ARCH in
amd64) arch="x86_64";;
arm64) arch="aarch64";;
armel|armhf) arch="armv7";;
esac

ynh_add_config --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
ynh_add_systemd_config --service="${app}-notify-push-watcher" --template="watcher.service"
systemctl enable --now ${app}-notify-push-watcher.path
ynh_add_systemd_config --service="${app}-notify-push"

count=0
while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]]
do
sleep 1
count=$((count + 1))
done

ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd" --action=restart

exec_occ config:app:set notify_push base_endpoint --value https://$domain${path_url%/}/push

if ! exec_occ notify_push:self-test; then
ynh_print_warn --message="The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \"systemctl restart ${app}-notify-push.service\", and run \"sudo -u $app php${phpversion} $install_dir/occ notify_push:self-test\" to verify that everything is green."
fi
fi

#=================================================
# SETUP SSOWAT
# GENERIC FINALISATION
#=================================================
ynh_script_progression --message="Configuring permissions..."
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."

# Temporary fix for the API permission (workaround for https://github.com/YunoHost/issues/issues/2294 )
ynh_permission_url --permission="api" --url="re:$new_domain\/.well-known\/.*" --auth_header="false" --clear_urls

ynh_systemd_action --service_name=nginx --action=reload

#=================================================
# END OF SCRIPT
#=================================================
Expand Down
84 changes: 76 additions & 8 deletions scripts/config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ ynh_abort_if_errors
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)

exec_occ() {
(cd "$install_dir" && ynh_exec_as "$app" \
php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
}

#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
Expand All @@ -39,8 +44,7 @@ get__maintenance_mode() {
}

get__system_addressbook_exposed() {
echo $(cd "$install_dir" && ynh_exec_as "$app" \
php${phpversion} --define apc.enable_cli=1 occ config:app:get dav system_addressbook_exposed)
echo $(exec_occ config:app:get dav system_addressbook_exposed)
}

get__fpm_footprint() {
Expand Down Expand Up @@ -73,24 +77,88 @@ get__fpm_free_footprint() {
set__maintenance_mode() {
if [ "$maintenance_mode" -eq "0" ]; then
# If maintenance_mode was set to 0, disable maintenance mode
(cd "$install_dir" && ynh_exec_as "$app" \
php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi maintenance:mode --off)
exec_occ maintenance:mode --off
ynh_print_info "Maintenance mode disabled"
elif [ "$maintenance_mode" -eq "1" ]; then
# If maintenance_mode was set to 1, enable maintenance mode
(cd "$install_dir" && ynh_exec_as "$app" \
php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi maintenance:mode --on)
exec_occ maintenance:mode --on
ynh_print_info "Maintenance mode enabled"
fi
ynh_app_setting_set --app=$app --key=maintenance_mode --value="$maintenance_mode"
}

set__system_addressbook_exposed() {
(cd "$install_dir" && ynh_exec_as "$app" \
php${phpversion} --define apc.enable_cli=1 occ config:app:set dav system_addressbook_exposed --value="$system_addressbook_exposed")
exec_occ config:app:set dav system_addressbook_exposed --value="$system_addressbook_exposed"
ynh_print_info "System addressbook is exposed: $system_addressbook_exposed"
}


set__enable_notify_push() {
if [ "$enable_notify_push" -eq "0" ]; then
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
ynh_secure_remove --file="$nginx_extra_conf_dir/notify_push.conf"
ynh_systemd_action --service_name="nginx" --action=reload

# If notify_push is enabled, disable it
if exec_occ app:list | awk '/Enabled/{f=1;next} f' | grep -q -w notify_push; then
exec_occ app:disable notify_push
fi

ynh_remove_systemd_config --service="${app}-notify-push"
systemctl disable --now "${app}-notify-push-watcher.path"
ynh_secure_remove --file="/etc/systemd/system/${app}-notify-push-watcher.path"
ynh_remove_systemd_config --service="${app}-notify-push-watcher"

ynh_print_info "Notify push disabled"
elif [ "$enable_notify_push" -eq "1" ]; then
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"

ynh_add_config --template="notify_push.conf" --destination="$nginx_extra_conf_dir/notify_push.conf"

ynh_systemd_action --service_name="nginx" --action=reload

# If notify_push is disabled, reenable it
if exec_occ app:list | awk '/Disabled/{f=1;next} f' | grep -q -w notify_push; then
exec_occ app:enable notify_push
# If notify_push is not installed, install it
elif ! exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w notify_push; then
exec_occ app:install notify_push
fi
exec_occ config:app:set notify_push base_endpoint --value https://$domain${path_url%/}/push

mkdir -p /var/run/$app/
chown $app: /var/run/$app/

case $YNH_ARCH in
amd64) arch="x86_64";;
arm64) arch="aarch64";;
armel|armhf) arch="armv7";;
esac

ynh_add_config --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
ynh_add_systemd_config --service="${app}-notify-push-watcher" --template="watcher.service"
systemctl enable --now ${app}-notify-push-watcher.path
ynh_add_systemd_config --service="${app}-notify-push"

count=0
while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]]
do
sleep 1
count=$((count + 1))
done

ynh_systemd_action --service_name="${app}-notify-push-watcher" --action=restart
ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd"

if ! exec_occ notify_push:self-test; then
ynh_print_warn --message="The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \"systemctl restart ${app}-notify-push.service\", and run \"sudo -u $app php${phpversion} $install_dir/occ notify_push:self-test\" to verify that everything is green."
fi
ynh_print_info "Notify push enabled"
fi
ynh_app_setting_set --app=$app --key=enable_notify_push --value="$enable_notify_push"
}

set__fpm_footprint() {
if [ "$fpm_footprint" != "specific" ]
then
Expand Down
Loading

0 comments on commit 4553fd1

Please sign in to comment.