1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 11:06:51 +00:00 committed by GitHub
commit 3862889702
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 77 additions and 202 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -1,4 +0,0 @@
; Additional php.ini defines, specific to this pool of workers.
php_admin_value[upload_max_filesize] = 50M
php_admin_value[post_max_size] = 50M

View file

@ -12,7 +12,7 @@ location __PATH__/ {
try_files $uri __PATH__/__PATH__/index.php$is_args$args;
location ~ ^__PATH__/index\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
fastcgi_index index.php;
include fastcgi_params;

View file

@ -18,7 +18,8 @@ demo = "https://demo.yunohost.org/agendav"
admindoc = "https://agendav.readthedocs.io"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = false
ldap = true
@ -55,6 +56,7 @@ ram.runtime = "10M"
[resources.system_user]
[resources.install_dir]
group = "www-data:r-x"
[resources.permissions]
main.url = "/"

View file

@ -1,11 +1,7 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
_ynh_agendav_find_caldav_app() {
@ -21,16 +17,8 @@ _ynh_agendav_find_caldav_app() {
caldav_app="${installed_baikal[0]}"
caldav_baseurl=/
else
ynh_die --message="Please install Baïkal or Radicale before AgenDAV."
ynh_die "Please install Baïkal or Radicale before AgenDAV."
fi
echo -e "$caldav_app $caldav_baseurl"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,59 +1,50 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
# Clean cache files before backup
ynh_secure_remove --file="$install_dir/web/var/cache/profiler"
ynh_secure_remove --file="$install_dir/web/var/cache/twig"
ynh_safe_rm "$install_dir/web/var/cache/profiler"
ynh_safe_rm "$install_dir/web/var/cache/twig"
mkdir -p "$install_dir/web/var/cache/"{profiler,twig}
chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig}
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
ynh_mysql_dump_db > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,25 +1,17 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -17,47 +11,44 @@ caldav_info=$(_ynh_agendav_find_caldav_app)
caldav_app="$(cut -d " " -f 1 <<< "$caldav_info")"
caldav_baseurl="$(cut -d " " -f 2 <<< "$caldav_info")"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
mkdir -p "/var/log/$app"
chown -R "$app:" "/var/log/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "/var/log/$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_script_progression "Adding $app's configuration..."
# Generate random encryption key
encryptkey=$(ynh_string_random --length=24)
ynh_app_setting_set --app="$app" --key=encryptkey --value="$encryptkey"
ynh_app_setting_set --key=encryptkey --value="$encryptkey"
# Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone)
@ -67,20 +58,19 @@ caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_baseurl="${caldav_url}${caldav_baseurl}"
ynh_add_config --template="../conf/settings.php" --destination="${install_dir}/web/config/settings.php"
ynh_config_add --template="settings.php" --destination="${install_dir}/web/config/settings.php"
#=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
#=================================================
ynh_script_progression --message="Initialising $app..." --weight=3
ynh_script_progression "Initialising $app..."
(
cd "$install_dir" || ynh_die
"php$phpversion" agendavcli migrations:migrate --no-interaction
"php$php_version" agendavcli migrations:migrate --no-interaction
)
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
# Only agendav user should write here
chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig}
@ -93,4 +83,4 @@ chmod -R 750 "$install_dir/web/config/"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,34 +1,29 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
# REMOVE SYSTEMD SERVICE
# REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
ynh_script_progression "Removing system configurations related to $app..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
ynh_config_remove_phpfpm
ynh_secure_remove --file="/var/log/$app"
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,16 +7,14 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
chown -R "$app:www-data" "$install_dir"
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
# Only agendav user should write here
chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig}
@ -34,38 +26,36 @@ chmod -R 750 "$install_dir/web/config/"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
ynh_mysql_db_shell < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
mkdir -p "/var/log/$app"
chown -R "$app:" "/var/log/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service="php$php_version-fpm" --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,20 +1,8 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# GET THE CALDAV APP
#=================================================
@ -27,41 +15,39 @@ caldav_baseurl="$(cut -d " " -f 2 <<< "$caldav_info")"
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep="web/config/settings.php"
fi
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
mkdir -p "/var/log/$app"
chown -R "$app:" "/var/log/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "/var/log/$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --non-append
ynh_config_add_logrotate
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_script_progression "Updating configuration..."
# Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone)
@ -71,20 +57,19 @@ caldav_path=$(ynh_app_setting_get --app="$caldav_app" --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_baseurl="${caldav_url}${caldav_baseurl}"
ynh_add_config --template="../conf/settings.php" --destination="${install_dir}/web/config/settings.php"
ynh_config_add --template="settings.php" --destination="${install_dir}/web/config/settings.php"
#=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
#=================================================
ynh_script_progression --message="Upgrading $app..." --weight=1
ynh_script_progression "Upgrading $app..."
(
cd "$install_dir" || ynh_die
"php$phpversion" agendavcli migrations:migrate --no-interaction
"php$php_version" agendavcli migrations:migrate --no-interaction
)
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
# Only agendav user should write here
chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig}
@ -94,10 +79,9 @@ chown -R "$app:www-data" "$install_dir/web/config/"
chmod -R 750 "$install_dir/web/config/"
# FIXME: Should cleanup all the chmods.
chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"

View file

@ -1,53 +0,0 @@
--- a/web/app/controllers.php
+++ b/web/app/controllers.php
@@ -58,14 +58,20 @@ $controllers->before(function(Request $request, Silex\Application $app) {
// processing the request
if ($app['session']->has('username')) {
$username = $app['session']->get('username');
- $preferences = $app['preferences.repository']->userPreferences($username);
- $app['user.preferences'] = $preferences;
- $app['user.timezone'] = $preferences->get('timezone');
-
- // Set application language
- $request->setLocale($preferences->get('language'));
- $app['translator']->setLocale($preferences->get('language'));
- return;
+ // Clear user session if HTTP authentication changed
+ if (isset($_SERVER['PHP_AUTH_USER'])
+ && $username != $_SERVER['PHP_AUTH_USER']) {
+ $app['session']->clear();
+ } else {
+ $preferences = $app['preferences.repository']->userPreferences($username);
+ $app['user.preferences'] = $preferences;
+ $app['user.timezone'] = $preferences->get('timezone');
+
+ // Set application language
+ $request->setLocale($preferences->get('language'));
+ $app['translator']->setLocale($preferences->get('language'));
+ return;
+ }
}
if ($request->isXmlHttpRequest()) {
diff --git a/web/src/Controller/Authentication.php b/web/src/Controller/Authentication.php
index deebb751..134cc9a8 100644
--- a/web/src/Controller/Authentication.php
+++ b/web/src/Controller/Authentication.php
@@ -34,9 +34,14 @@ class Authentication
$success = false;
$template_vars = [];
- if ($request->isMethod('POST')) {
- $user = $request->request->get('user');
- $password = $request->request->get('password');
+ if ($request->isMethod('POST') || isset($_SERVER['PHP_AUTH_USER'])) {
+ if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
+ $user = $_SERVER['PHP_AUTH_USER'];
+ $password = $_SERVER['PHP_AUTH_PW'];
+ } else {
+ $user = $request->request->get('user');
+ $password = $request->request->get('password');
+ }
if (empty($user) || empty($password)) {
$template_vars['error'] = $app['translator']->trans('messages.error_empty_fields');