1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/leed_ynh.git synced 2024-09-03 19:26:32 +02:00

Normalization from example_ynh

This commit is contained in:
Maniack Crudelis 2019-05-20 23:09:08 +02:00
parent 1c433f4c41
commit 73ebbb924e
11 changed files with 138 additions and 145 deletions

View file

@ -39,9 +39,9 @@ Not supported.
#### Supported architectures
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/)
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/)
## Limitations
@ -51,6 +51,7 @@ Not supported.
* Report a bug: https://github.com/YunoHost-Apps/leed_ynh/issues
* Leed website: http://leed.idleman.fr/
* Leed repository: http://git.idleman.fr/LeedRSS/Leed
* YunoHost website: https://yunohost.org/
---

View file

@ -39,9 +39,9 @@ Non supportée.
#### Architectures supportées.
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/)
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/)
## Informations additionnelles
@ -49,6 +49,7 @@ Non supportée.
* Reporter un bug: https://github.com/YunoHost-Apps/leed_ynh/issues
* Site de Leed: http://leed.idleman.fr/
* Dépôt de Leed: http://git.idleman.fr/LeedRSS/Leed
* Site de YunoHost: https://yunohost.org/
---

View file

@ -78,7 +78,11 @@
"en": "Is it a public website ?",
"fr": "Est-ce un site public ?"
},
"default": false
"default": false,
"help": {
"en": "A public Leed will be accessible for third party apps. By turning on 'anonymous readers' in Leed configuration, you can made your feeds public.",
"fr": "Un Leed public sera accessible pour les applications tierces. En autorisant 'la lecture anonyme' dans la configuration de Leed, vous pouvez rendre vos flux publics."
}
}
]
}

View file

@ -26,11 +26,11 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
is_public_old=$(ynh_app_setting_get $app is_public)
is_public_old=$(ynh_app_setting_get --app=$app --key=is_public)
if [ $is_public -eq $is_public_old ]
then
ynh_die "is_public is already set as $is_public." 0
ynh_die --message="is_public is already set as $is_public." 0
fi
#=================================================
@ -38,6 +38,7 @@ fi
#=================================================
# MOVE TO PUBLIC OR PRIVATE
#=================================================
if [ $is_public -eq 0 ]; then
public_private="private"
else
@ -47,27 +48,27 @@ ynh_script_progression --message="Moving the application to $public_private..."
if [ $is_public -eq 0 ]
then
ynh_app_setting_delete $app unprotected_uris
ynh_app_setting_delete --app=$app --key=unprotected_uris
# Set the action.php script public for the cron task
ynh_app_setting_set $app skipped_uris "/action.php"
ynh_app_setting_set --app=$app --key=skipped_uris --value="/action.php"
else
ynh_app_setting_delete $app skipped_uris
ynh_app_setting_set $app unprotected_uris "/"
ynh_app_setting_delete --app=$app --key=skipped_uris
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
ynh_script_progression --message="Reconfiguring SSOwat..."
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Regen ssowat configuration
yunohost app ssowatconf
# Update the config of the app
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

View file

@ -23,9 +23,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# STANDARD BACKUP STEPS
@ -35,28 +35,28 @@ db_name=$(ynh_app_setting_get $app db_name)
ynh_script_progression --message="Backing up the main app directory..."
CHECK_SIZE "$final_path"
ynh_backup "$final_path"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP NGINX 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 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
#=================================================
ynh_script_progression --message="Backing up the MySQL database..." --weight=2
ynh_mysql_dump_db "$db_name" > db.sql
ynh_mysql_dump_db --database="$db_name" > db.sql
CHECK_SIZE "db.sql"
#=================================================
@ -64,8 +64,8 @@ CHECK_SIZE "db.sql"
#=================================================
ynh_script_progression --message="Backing up fail2ban configuration"
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
@ -74,7 +74,7 @@ ynh_backup "/etc/fail2ban/filter.d/$app.conf"
#=================================================
ynh_script_progression --message="Backing up cron file"
ynh_backup "/etc/cron.d/$app"
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT

View file

@ -26,16 +26,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
test -n "$old_path" || old_path="/"
test -n "$new_path" || new_path="/"
new_path=$(ynh_normalize_url_path $new_path)
old_path=$(ynh_normalize_url_path $old_path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -82,15 +73,12 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Store path_url setting
ynh_app_setting_set $app path_url "$path_url"
# Create a dedicated nginx config
ynh_add_nginx_config
fi
@ -99,11 +87,11 @@ fi
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -119,14 +107,14 @@ else
domain_path="$new_domain$new_path"
fi
ynh_replace_string "https://$old_domain${old_path}" "https://$domain_path" "/etc/cron.d/$app"
ynh_replace_string --match_string="https://$old_domain${old_path}" --replace_string="https://$domain_path" --target_file="/etc/cron.d/$app"
#=================================================
# UPDATE THE DATABASE
#=================================================
ynh_script_progression --message="Updating the database..."
ynh_mysql_execute_as_root "UPDATE leed_configuration SET value='$domain_path/' WHERE value LIKE '%${old_domain}%'" $app
ynh_mysql_execute_as_root --sql="UPDATE leed_configuration SET value='$domain_path/' WHERE value LIKE '%${old_domain}%'" --database=$app
#=================================================
# GENERIC FINALISATION
@ -135,7 +123,7 @@ ynh_mysql_execute_as_root "UPDATE leed_configuration SET value='$domain_path/' W
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# LOAD VALUES
@ -27,22 +27,22 @@ final_path=$(ynh_app_setting_get $app final_path)
# Otherwise, keep the value from the app config.
# is_public
old_is_public="$(ynh_app_setting_get $app is_public)"
old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)"
old_is_public=$(bool_to_true_false $old_is_public)
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
# Overwrite nginx configuration
old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)"
old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
# Overwrite php-fpm configuration
old_overwrite_phpfpm="$(ynh_app_setting_get $app overwrite_phpfpm)"
old_overwrite_phpfpm="$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)"
old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm)
overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
# Type of admin mail configuration
old_admin_mail_html="$(ynh_app_setting_get $app admin_mail_html)"
old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html)
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
@ -77,14 +77,14 @@ apply_config() {
# Set overwrite_nginx
overwrite_nginx=$(bool_to_01 $overwrite_nginx)
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
# Set overwrite_phpfpm
overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm)
ynh_app_setting_set $app overwrite_phpfpm "$overwrite_phpfpm"
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm"
# Set admin_mail_html
admin_mail_html=$(bool_to_01 $admin_mail_html)
ynh_app_setting_set $app admin_mail_html "$admin_mail_html"
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
}
#=================================================

View file

@ -35,26 +35,23 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Validating installation parameters..." --weight=2
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register $app $domain $path_url
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app language $language
ynh_app_setting_set $app domain $domain
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app overwrite_nginx "1"
ynh_app_setting_set $app overwrite_phpfpm "1"
ynh_app_setting_set $app admin_mail_html "1"
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
# STANDARD MODIFICATIONS
@ -63,18 +60,18 @@ ynh_app_setting_set $app admin_mail_html "1"
#=================================================
ynh_script_progression --message="Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
ynh_app_setting_set $app final_path $final_path
# Download, check integrity and uncompress the source from app.src
ynh_setup_source "$final_path"
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
@ -90,7 +87,7 @@ ynh_add_nginx_config
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a dedicated system user
ynh_system_user_create $app
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
@ -111,12 +108,12 @@ ynh_script_progression --message="Installing Leed with Curl..." --weight=5
chown -R $app: $final_path
# Set the app as temporarily public for curl call
ynh_app_setting_set $app unprotected_uris "/"
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
# Regen SSOwat configuration
yunohost app ssowatconf
# Reload Nginx
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
# Leed installation via curl
ynh_print_OFF
@ -134,10 +131,10 @@ code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT valu
#=================================================
ynh_script_progression --message="Setting up a cron file..."
ynh_replace_string "__ADMIN__" "$admin" ../conf/cron_leed
ynh_replace_string "__DOMAIN__" "$domain" ../conf/cron_leed
ynh_replace_string "__PATH__" "$path_url" ../conf/cron_leed
ynh_replace_string "__CODESYNC__" "$code_sync" ../conf/cron_leed
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file=../conf/cron_leed
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file=../conf/cron_leed
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/cron_leed
ynh_replace_string --match_string="__CODESYNC__" --replace_string="$code_sync" --target_file=../conf/cron_leed
cp ../conf/cron_leed /etc/cron.d/$app
#=================================================
@ -166,13 +163,13 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
ynh_script_progression --message="Configuring SSOwat..." --weight=2
# Make app private if necessary
ynh_app_setting_set $app is_public "$is_public"
ynh_app_setting_set --app=$app --key=is_public --value="$is_public"
if [ $is_public -eq 0 ];
then
# Remove the public access
ynh_app_setting_delete $app unprotected_uris
ynh_app_setting_delete --app=$app --key=unprotected_uris
# Set the action.php script public for the cron task
ynh_app_setting_set $app skipped_uris "/action.php"
ynh_app_setting_set --app=$app --key=skipped_uris --value="/action.php"
fi
#=================================================
@ -180,7 +177,7 @@ fi
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=3
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
@ -197,7 +194,7 @@ You can also find some specific actions for this app by using the experimental _
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/leed_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="install"
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=install
ynh_print_ON
#=================================================

View file

@ -16,9 +16,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get $app final_path)
ynh_script_progression --message="Removing the MySQL database..."
# 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
@ -36,7 +36,7 @@ ynh_mysql_remove_db $db_name $db_name
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove "$final_path"
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
@ -68,7 +68,7 @@ ynh_remove_fail2ban_config
# REMOVE THE CRON FILE
#=================================================
ynh_secure_remove "/etc/cron.d/$app"
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# GENERIC FINALISATION
@ -78,7 +78,7 @@ ynh_secure_remove "/etc/cron.d/$app"
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
# Delete dedicated system user
ynh_system_user_delete $app
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT

View file

@ -23,21 +23,21 @@ ynh_script_progression --message="Loading settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
admin=$(ynh_app_setting_get $app admin)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
admin=$(ynh_app_setting_get --app=$app --key=admin)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -52,23 +52,23 @@ ynh_maintenance_mode_ON
# 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
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file "$final_path"
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=3
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RECREATE THE DEDICATED USER
@ -76,21 +76,21 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create $app
ynh_system_user_create --username=$app
#=================================================
# 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"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the fail2ban configuration..." --weight=7
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
@ -99,7 +99,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban
# RESTORE THE CRON FILE
#=================================================
ynh_restore_file "/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RESTORE USER RIGHTS
@ -114,8 +114,8 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
#=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
ynh_systemd_action --action=reload --service_name=php7.0-fpm
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=php7.0-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
@ -136,7 +136,7 @@ You can also find some specific actions for this app by using the experimental _
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/leed_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="restore"
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=restore
#=================================================
# END OF SCRIPT

View file

@ -16,16 +16,17 @@ ynh_script_progression --message="Loading installation settings..." --weight=3
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
db_name=$(ynh_app_setting_get $app db_name)
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
#=================================================
# CHECK VERSION
@ -41,32 +42,32 @@ ynh_script_progression --message="Ensuring downward compatibility..."
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
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
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_make_valid_dbid $app)
ynh_app_setting_set $app db_name $db_name
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If is_public doesn't exist, create it
if [ -z "$is_public" ]; then
public_check=$(ynh_app_setting_get $app skipped_uris)
public_check=$(ynh_app_setting_get --app=$app --key=skipped_uris)
# If skipped_uris is empty, that was a public installation.
if [ -z "$public_check" ]; then
is_public=1
else
is_public=0
fi
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
else
# Fix is_public as a boolean
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
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
fi
fi
@ -74,19 +75,19 @@ fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi
# If overwrite_phpfpm doesn't exist, create it
if [ -z "$overwrite_phpfpm" ]; then
overwrite_phpfpm=1
ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
fi
# If admin_mail_html doesn't exist, create it
if [ -z "$admin_mail_html" ]; then
admin_mail_html=1
ynh_app_setting_set $app admin_mail_html $admin_mail_html
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
fi
#=================================================
@ -108,7 +109,7 @@ ynh_abort_if_errors
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -127,7 +128,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=3
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
@ -148,7 +149,7 @@ fi
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
@ -174,10 +175,10 @@ code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT valu
# SETUP CRON FILE FOR SYNCHRONISATION
#=================================================
ynh_replace_string "__ADMIN__" "$admin" ../conf/cron_leed
ynh_replace_string "__DOMAIN__" "$domain" ../conf/cron_leed
ynh_replace_string "__PATH__" "$path_url" ../conf/cron_leed
ynh_replace_string "__CODESYNC__" "$code_sync" ../conf/cron_leed
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file=../conf/cron_leed
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file=../conf/cron_leed
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/cron_leed
ynh_replace_string --match_string="__CODESYNC__" --replace_string="$code_sync" --target_file=../conf/cron_leed
cp ../conf/cron_leed /etc/cron.d/$app
#=================================================
@ -187,6 +188,8 @@ cp ../conf/cron_leed /etc/cron.d/$app
# Set permissions on app files
chown -R root: $final_path
# $app need write permissions in plugins, cache and updates
# Clear leed cache
ynh_secure_remove --file=$final_path/cache
mkdir -p $final_path/cache
chown -R $app $final_path/cache $final_path/plugins $final_path/updates
@ -197,10 +200,8 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading Leed with curl..." --weight=4
# Clear leed cache
ynh_secure_remove $final_path/cache/*
# Set the app as temporarily public for curl call
ynh_app_setting_set $app unprotected_uris "/"
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
# Regen SSOwat configuration
yunohost app ssowatconf
# Start the upgrade procedure of leed.
@ -223,12 +224,12 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app private if necessary
if [ $is_public -eq 0 ];
if [ $is_public -eq 0 ]
then
# Remove the public access
ynh_app_setting_delete $app unprotected_uris
ynh_app_setting_delete --app=$app --key=unprotected_uris
# Set the action.php script public for the cron task
ynh_app_setting_set $app skipped_uris "/action.php"
ynh_app_setting_set --app=$app --key=skipped_uris --value="/action.php"
fi
#=================================================
@ -236,7 +237,7 @@ fi
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
@ -265,7 +266,7 @@ If you're facing an issue or want to improve this app, please open a new issue i
Changelog since your last upgrade:
$(cat changelog)" > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="upgrade"
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=upgrade
#=================================================
# END OF SCRIPT