diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f248394..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[po] diff --git a/conf/settings.php b/conf/settings.php index 9173926..141bdb0 100644 --- a/conf/settings.php +++ b/conf/settings.php @@ -20,9 +20,9 @@ $app['proxies'] = []; // Database settings $app['db.options'] = [ - 'dbname' => '__DBNAME__', - 'user' => '__DBUSER__', - 'password' => '__DBPASS__', + 'dbname' => '__DB_NAME__', + 'user' => '__DB_USER__', + 'password' => '__DB_PWD__', 'host' => 'localhost', 'driver' => 'pdo_mysql' ]; @@ -31,7 +31,7 @@ $app['db.options'] = [ $app['csrf.secret'] = '__ENCRYPTKEY__'; // Log path -$app['log.path'] = '__LOGDIR__/'; +$app['log.path'] = '/var/log/__APP__/'; // Base URL $app['caldav.baseurl'] = '__CALDAV_BASEURL__'; diff --git a/manifest.json b/manifest.json index 4f53c9d..abe3701 100644 --- a/manifest.json +++ b/manifest.json @@ -12,7 +12,7 @@ "license": "GPL-3.0", "website": "http://agendav.org", "demo": "https://demo.yunohost.org/agendav/", - "admindoc": "http://docs.agendav.org", + "admindoc": "https://agendav.readthedocs.io/", "code": "https://github.com/agendav/agendav" }, "license": "GPL-3.0", diff --git a/scripts/_common.sh b/scripts/_common.sh index 23c6a7b..92977e3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,10 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +php_dependencies="php$YNH_DEFAULT_PHP_VERSION-ctype php$YNH_DEFAULT_PHP_VERSION-curl php$YNH_DEFAULT_PHP_VERSION-mbstring php$YNH_DEFAULT_PHP_VERSION-mcrypt php$YNH_DEFAULT_PHP_VERSION-tokenizer php$YNH_DEFAULT_PHP_VERSION-xml php$YNH_DEFAULT_PHP_VERSION-xmlreader php$YNH_DEFAULT_PHP_VERSION-xmlwriter php$YNH_DEFAULT_PHP_VERSION-mysql" -# dependencies used by the app -pkg_dependencies="php${YNH_PHP_VERSION}-cli" +# dependencies used by the app (must be on a single line) +pkg_dependencies="$php_dependencies" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 31711d4..f231b75 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/change_url b/scripts/change_url index 58c7fa5..1160e7e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -81,7 +81,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 657d863..ee469cf 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -29,7 +32,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -74,7 +77,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies @@ -89,7 +92,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." +ynh_script_progression --message="Creating a MySQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -112,7 +115,7 @@ chown -R $app:www-data "$final_path" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." +ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config @@ -144,23 +147,9 @@ timezone=$(cat /etc/timezone) caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) caldav_url="https://${caldav_domain}${caldav_path%/}" +caldav_baseurl="${caldav_url}${caldav_baseurl}" -conf_path="${final_path}/web/config/settings.php" -cp ../conf/settings.php "$conf_path" - -logdir=/var/log/$app - -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path" -ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path" -ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path" -ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path" -ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path" -ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path" - -ynh_store_file_checksum --file="$conf_path" +ynh_add_config --template="../conf/settings.php" --destination="${final_path}/web/config/settings.php" #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) @@ -172,10 +161,6 @@ ynh_script_progression --message="Initialising AgenDAV..." --weight=3 php${phpversion} agendavcli migrations:migrate --no-interaction ) -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - chown -R $app:www-data $final_path # Only agendav user should write here @@ -191,10 +176,10 @@ chmod -R 750 ${final_path}/web/config/ #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --weight=1 -mkdir -p $logdir -chown -R $app: $logdir +mkdir -p /var/log/$app +chown -R $app: /var/log/$app # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -202,7 +187,7 @@ ynh_use_logrotate #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -210,4 +195,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of AgenDAV completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 4d9af1e..ad052e3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -24,7 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -32,7 +32,7 @@ ynh_remove_logrotate #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." +ynh_script_progression --message="Removing the MySQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -48,7 +48,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -64,7 +64,7 @@ ynh_remove_fpm_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -74,7 +74,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression --message="Removing various files..." --weight=1 ynh_secure_remove --file="/var/log/$app" @@ -83,7 +83,7 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username=$app diff --git a/scripts/restore b/scripts/restore index 364f7a4..9de5c66 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -34,7 +37,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -52,7 +55,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" @@ -75,7 +78,7 @@ chmod -R 750 ${final_path}/web/config/ #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -90,7 +93,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -106,7 +109,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 mkdir -p /var/log/$app chown -R $app: /var/log/$app diff --git a/scripts/upgrade b/scripts/upgrade index 78c102a..25ab373 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -26,7 +26,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) @@ -49,7 +49,7 @@ ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If db_name doesn't exist, create it if [ -z "$db_name" ]; then @@ -70,14 +70,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # GET THE CALDAV APP #================================================= @@ -101,16 +93,24 @@ else ynh_die --message="Please install Baïkal or Radicale before AgenDAV." fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path"--keep="web/config/settings.php" fi chmod 750 "$final_path" @@ -120,14 +120,14 @@ chown -R $app:www-data "$final_path" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config @@ -135,7 +135,7 @@ ynh_add_fpm_config #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -157,42 +157,20 @@ timezone=$(cat /etc/timezone) caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) caldav_url="https://${caldav_domain}${caldav_path%/}" +caldav_baseurl="${caldav_url}${caldav_baseurl}" -conf_path="${final_path}/web/config/settings.php" - -ynh_backup_if_checksum_is_different --file="$conf_path" - -cp ../conf/settings.php "$conf_path" - -logdir=/var/log/$app - -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path" -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path" -ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path" -ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path" -ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path" -ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path" -ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path" - -ynh_store_file_checksum --file="$conf_path" +ynh_add_config --template="../conf/settings.php" --destination="${final_path}/web/config/settings.php" #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) #================================================= -ynh_script_progression --message="Upgrading AgenDAV..." +ynh_script_progression --message="Upgrading AgenDAV..." --weight=1 ( cd $final_path php${phpversion} agendavcli migrations:migrate --no-interaction ) -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - chown -R $app:www-data $final_path # Only agendav user should write here @@ -210,8 +188,8 @@ chmod -R 750 ${final_path}/web/config/ #================================================= ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2 -mkdir -p $logdir -chown -R $app: $logdir +mkdir -p /var/log/$app +chown -R $app: /var/log/$app # Use logrotate to manage application logfile(s) ynh_use_logrotate --non-append @@ -219,7 +197,7 @@ ynh_use_logrotate --non-append #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload