1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00

Merge pull request #39 from YunoHost-Apps/package_upgrade

Normalization from example_ynh
This commit is contained in:
Maniack Crudelis 2019-05-13 19:28:12 +02:00 committed by GitHub
commit ec1554e65d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 164 additions and 160 deletions

View file

@ -32,9 +32,9 @@ AJAX interface to allow users to manage their own calendars and shared ones.
#### Supported architectures #### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/agendav%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/agendav/) * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/agendav%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/agendav/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/agendav%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/agendav/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/agendav%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/agendav/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/agendav%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/agendav/) * Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/agendav%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/agendav/)
## Limitations ## Limitations
@ -48,6 +48,7 @@ AJAX interface to allow users to manage their own calendars and shared ones.
* Report a bug: https://github.com/YunoHost-Apps/agendav_ynh/issues * Report a bug: https://github.com/YunoHost-Apps/agendav_ynh/issues
* AgenDAV website: http://agendav.org/ * AgenDAV website: http://agendav.org/
* AgenDAV repository: https://github.com/agendav/agendav/
* YunoHost website: https://yunohost.org/ * YunoHost website: https://yunohost.org/
--- ---

View file

@ -23,16 +23,7 @@
port_already_use=0 port_already_use=0
change_url=1 change_url=1
;;; Levels ;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
Level 4=1
Level 5=auto Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none

View file

@ -15,7 +15,7 @@
}, },
"multi_instance": false, "multi_instance": false,
"requirements": { "requirements": {
"yunohost": ">= 3.0.0" "yunohost": ">= 3.5.0"
}, },
"services": [ "services": [
"nginx", "nginx",

View file

@ -20,58 +20,61 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Backing up the main app directory..." ynh_script_progression --message="Backing up the main app directory..."
# Clean cache files before backup # Clean cache files before backup
ynh_secure_remove ${final_path}/web/var/cache/{profiler,twig}/* ynh_secure_remove --file=${final_path}/web/var/cache/profiler
ynh_secure_remove --file=${final_path}/web/var/cache/twig
mkdir -p ${final_path}/web/var/cache/{profiler,twig}
chown -R $app ${final_path}/web/var/cache/{profiler,twig}
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..." ynh_script_progression --message="Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up php-fpm configuration..." ynh_script_progression --message="Backing up php-fpm configuration..."
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the MySQL database..." ynh_script_progression --message="Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Backing up logrotate configuration..." ynh_script_progression --message="Backing up logrotate configuration..."
ynh_backup "/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -29,17 +29,13 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info "Validating installation parameters..." ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
agendav_app_check_installation() { agendav_app_check_installation() {
echo $(yunohost app list --installed -f "$1" | grep "id:") echo $(yunohost app list --installed -f "$1" | grep "id:")
@ -57,24 +53,24 @@ then
caldav_app=radicale caldav_app=radicale
caldav_baseurl=/ caldav_baseurl=/
else else
ynh_die "Please install Baikal or Radicale before AgenDAV." ynh_die --message="Please install Baikal or Radicale before AgenDAV."
fi fi
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..." ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set $app language $language ynh_app_setting_set --app=$app --key=language --value=$language
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_script_progression --message="Installing dependencies..." --weight=8
# Install dependencies # Install dependencies
ynh_install_app_dependencies php-cli ynh_install_app_dependencies php-cli
@ -82,24 +78,25 @@ ynh_install_app_dependencies php-cli
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Creating a MySQL database..." ynh_script_progression --message="Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db $db_name $db_name ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..." ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_setup_source "$final_path" # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring nginx web server..." ynh_script_progression --message="Configuring nginx web server..." --weight=3
# Copy and set nginx configuration # Copy and set nginx configuration
ynh_add_nginx_config ynh_add_nginx_config
@ -107,14 +104,15 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..." ynh_script_progression --message="Configuring system user..." --weight=2
ynh_system_user_create $app # Create a system user
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================ #================================================
ynh_print_info "Configuring php-fpm..." ynh_script_progression --message="Configuring php-fpm..."
# Copy and set php-fpm configuration # Copy and set php-fpm configuration
ynh_add_fpm_config ynh_add_fpm_config
@ -124,18 +122,18 @@ ynh_add_fpm_config
#================================================= #=================================================
# CREATE SETTINGS.PHP # CREATE SETTINGS.PHP
#================================================= #=================================================
ynh_print_info "Configuring agendav..." ynh_script_progression --message="Configuring agendav..." --weight=2
# Generate random encryption key # Generate random encryption key
encryptkey=$(ynh_string_random 24) encryptkey=$(ynh_string_random --length=24)
ynh_app_setting_set $app encryptkey "$encryptkey" ynh_app_setting_set --app=$app --key=encryptkey --value="$encryptkey"
# Copy and set AgenDAV configuration # Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
caldav_domain=$(ynh_app_setting_get $caldav_app domain) caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
caldav_path=$(ynh_app_setting_get $caldav_app path) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}" caldav_url="https://${caldav_domain}${caldav_path%/}"
conf_path="${final_path}/web/config/settings.php" conf_path="${final_path}/web/config/settings.php"
@ -143,26 +141,26 @@ cp ../conf/settings.php "$conf_path"
logdir=/var/log/$app logdir=/var/log/$app
ynh_replace_string "__DBUSER__" "${db_name}" "$conf_path" ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path"
ynh_replace_string "__DBPASS__" "${db_pwd}" "$conf_path" ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path"
ynh_replace_string "__DBNAME__" "${db_name}" "$conf_path" ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path"
ynh_replace_string "__ENCRYPTKEY__" "${encryptkey}" "$conf_path" ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path"
ynh_replace_string "__LOGDIR__" "${logdir}" "$conf_path" ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path"
ynh_replace_string "__TIMEZONE__" "$timezone" "$conf_path" ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path"
ynh_replace_string "__LANGUAGE__" "${language}" "$conf_path" ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path"
ynh_replace_string "__CALDAV_BASEURL__" "${caldav_url}${caldav_baseurl}" "$conf_path" ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path"
ynh_replace_string "__CALDAV_DOMAIN__" "${caldav_domain}" "$conf_path" ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_store_file_checksum "$conf_path" ynh_store_file_checksum --file="$conf_path"
#================================================= #=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
#================================================= #=================================================
ynh_print_info "Initialising agendav..." ynh_script_progression --message="Initialising agendav..." --weight=3
( (
cd $final_path cd $final_path
@ -172,7 +170,7 @@ ynh_print_info "Initialising agendav..."
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Configuring log rotation..." ynh_script_progression --message="Configuring log rotation..."
mkdir -p $logdir mkdir -p $logdir
chown -R $app: $logdir chown -R $app: $logdir
@ -199,12 +197,12 @@ chmod -R 750 ${final_path}/web/config/
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Installation of $app completed" ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,20 +12,20 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies" ynh_script_progression --message="Removing dependencies..." --weight=4
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -33,30 +33,30 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Removing the MySQL database" ynh_script_progression --message="Removing the MySQL database..."
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory" ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE LOG # REMOVE LOG
#================================================= #=================================================
ynh_print_info "Removing logs" ynh_script_progression --message="Removing logs..."
ynh_secure_remove "/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration" ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -64,7 +64,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing php-fpm configuration" ynh_script_progression --message="Removing php-fpm configuration..." --weight=2
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -72,7 +72,7 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing logrotate configuration" ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -82,13 +82,13 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user" ynh_script_progression --message="Removing the dedicated system user..."
# Remove the user account # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Removal of $app completed" ynh_script_progression --message="Removal of $app completed" --last

View file

@ -19,24 +19,24 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..." ynh_script_progression --message="Loading settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info "Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -44,22 +44,22 @@ test ! -d $final_path \
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
@ -79,18 +79,18 @@ chmod -R 750 ${final_path}/web/config/
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Restoring the MySQL database..." ynh_script_progression --message="Restoring the MySQL database..." --weight=2
db_pwd=$(ynh_app_setting_get $app mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
@ -100,20 +100,20 @@ logdir=/var/log/$app
mkdir -p $logdir mkdir -p $logdir
chown -R $app: $logdir chown -R $app: $logdir
ynh_restore_file "/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_print_info "Reloading nginx web server and php-fpm..." ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=2
systemctl reload php7.0-fpm ynh_systemd_action --service_name=php7.0-fpm --action=reload
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Restoration completed for $app" ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,40 +12,46 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get $app language) language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_print_info "Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0 ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0 is_public=0
fi fi
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z $db_name ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z $final_path ]; then if [ -z "$final_path" ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
#================================================= #=================================================
@ -68,13 +74,13 @@ then
caldav_app=radicale caldav_app=radicale
caldav_baseurl=/ caldav_baseurl=/
else else
ynh_die "Please install Baikal or Radicale before AgenDAV." ynh_die --message="Please install Baikal or Radicale before AgenDAV."
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..." ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=9
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -90,21 +96,26 @@ ynh_abort_if_errors
#================================================= #=================================================
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path --path_url=$path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Upgrading source files..."
ynh_setup_source "$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."0
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading nginx web server configuration..." ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
# Copy and set nginx configuration # Copy and set nginx configuration
ynh_add_nginx_config ynh_add_nginx_config
@ -112,7 +123,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..." --weight=5
# Install dependencies # Install dependencies
ynh_install_app_dependencies php-cli ynh_install_app_dependencies php-cli
@ -120,15 +131,15 @@ ynh_install_app_dependencies php-cli
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading php-fpm configuration..." ynh_script_progression --message="Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
@ -138,47 +149,47 @@ ynh_add_fpm_config
#================================================= #=================================================
# CREATE SETTINGS.PHP # CREATE SETTINGS.PHP
#================================================= #=================================================
ynh_print_info "Upgrading agendav configuration..." ynh_script_progression --message="Upgrading agendav configuration..." --weight=2
# Generate random encryption key # Generate random encryption key
encryptkey=$(ynh_app_setting_get $app encryptkey) encryptkey=$(ynh_app_setting_get --app=$app --key=encryptkey)
# Copy and set AgenDAV configuration # Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
caldav_domain=$(ynh_app_setting_get $caldav_app domain) caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
caldav_path=$(ynh_app_setting_get $caldav_app path) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}" caldav_url="https://${caldav_domain}${caldav_path%/}"
conf_path="${final_path}/web/config/settings.php" conf_path="${final_path}/web/config/settings.php"
ynh_backup_if_checksum_is_different "$conf_path" ynh_backup_if_checksum_is_different --file="$conf_path"
cp ../conf/settings.php "$conf_path" cp ../conf/settings.php "$conf_path"
logdir=/var/log/$app logdir=/var/log/$app
ynh_replace_string "__DBUSER__" "${db_name}" "$conf_path" ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path"
db_pwd=$(ynh_app_setting_get $app mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_replace_string "__DBPASS__" "${db_pwd}" "$conf_path" ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path"
ynh_replace_string "__DBNAME__" "${db_name}" "$conf_path" ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path"
ynh_replace_string "__ENCRYPTKEY__" "${encryptkey}" "$conf_path" ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path"
ynh_replace_string "__LOGDIR__" "${logdir}" "$conf_path" ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path"
ynh_replace_string "__TIMEZONE__" "$timezone" "$conf_path" ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path"
ynh_replace_string "__LANGUAGE__" "${language}" "$conf_path" ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path"
ynh_replace_string "__CALDAV_BASEURL__" "${caldav_url}${caldav_baseurl}" "$conf_path" ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path"
ynh_replace_string "__CALDAV_DOMAIN__" "${caldav_domain}" "$conf_path" ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_store_file_checksum "$conf_path" ynh_store_file_checksum --file="$conf_path"
#================================================= #=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
#================================================= #=================================================
ynh_print_info "Upgrading agendav..." ynh_script_progression --message="Upgrading agendav..."
( (
cd $final_path cd $final_path
@ -188,7 +199,7 @@ ynh_print_info "Upgrading agendav..."
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Upgrading logrotate configuration..." ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2
mkdir -p $logdir mkdir -p $logdir
chown -R $app: $logdir chown -R $app: $logdir
@ -215,12 +226,12 @@ chmod -R 750 ${final_path}/web/config/
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Upgrade of $app completed" ynh_script_progression --message="Upgrade of $app completed" --last