-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathchange_url
99 lines (74 loc) · 3.96 KB
/
change_url
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
if [ $change_domain -eq 1 ]
then
# Check if .well-known is available for this domain
if is_url_handled --domain="$new_domain" --path="/.well-known/caldav" || is_url_handled --domain="$new_domain" --path="/.well-known/carddav"
then
ynh_print_warn "Another app already uses the domain $new_domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book."
# Remove lines about .well-known/carddav and caldav with sed.
sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
fi
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
ynh_script_progression "Applying $app specific modifications..."
if [ $change_domain -eq 1 ]
then
# Change the trusted domain
exec_occ config:system:set trusted_domains 1 --value=$new_domain
# Change hostname for activity notifications
exec_occ config:system:set overwrite.cli.url --value="https://${new_domain}${new_path}"
# Reload PHP-FPM, necessary for force Nextcloud to re-read config.php, cf opcache.revalidate_freq
ynh_systemctl --service=php${php_version}-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_config_add --template="notify_push.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/notify_push.conf"
ynh_systemctl --service=nginx --action=reload
case $YNH_ARCH in
amd64) arch="x86_64";;
arm64) arch="aarch64";;
armel|armhf) arch="armv7";;
esac
ynh_config_add --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
ynh_config_add_systemd --service="${app}-notify-push-watcher" --template="watcher.service"
systemctl enable --now ${app}-notify-push-watcher.path
ynh_config_add_systemd --service="${app}-notify-push"
count=0
while ! ynh_exec_as_app php${php_version} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]]
do
sleep 1
count=$((count + 1))
done
ynh_systemctl --service="${app}-notify-push" --action=restart --wait_until="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 "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${php_version} $install_dir/occ notify_push:self-test\" to verify that everything is green."
fi
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression "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_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Change of URL completed for $app"