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

Merge pull request #33 from YunoHost-Apps/global_upgrade

Global upgrade
This commit is contained in:
yalh76 2019-02-10 19:03:06 +01:00 committed by GitHub
commit 62c8b726fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 127 additions and 39 deletions

View file

@ -35,13 +35,15 @@ Additionals parameters can be configure in Settings / admin settings.
## Documentation
* [Official documentation](https://writefreely.org/start)
* Official documentation: https://writefreely.org/start
## YunoHost specific features
#### Multi-users support
No LDAP and no HTTP auth supported
Depending of the configuration, the app be used by multiple users
If User Mode is configured Multiple users, the app be used by multiple users
#### Supported architectures

View file

@ -18,6 +18,7 @@
setup_private=1
setup_public=1
upgrade=1
#upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=1
incorrect_path=1
@ -29,7 +30,7 @@
Level 3=auto
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
# https://github.com/YunoHost-Apps/writefreely_ynh/issues/24
# https://github.com/YunoHost-Apps/writefreely_ynh/issues/24
Level 4=na
Level 5=auto
Level 6=auto
@ -40,3 +41,8 @@
;;; Options
Email=
Notification=none
#;;; Upgrade options
# ; commit=CommitHash
# name=Name and date of the commit.
# manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -14,7 +14,7 @@
"email": "anmol@datamol.org"
},
"requirements": {
"yunohost": ">= 2.7.14"
"yunohost": ">= 3.4"
},
"multi_instance": true,
"services": [
@ -41,6 +41,15 @@
},
"example": "johndoe"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
},
{
"name": "password",
"type": "password",
@ -54,15 +63,6 @@
},
"example": "Choose a password"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
},
{
"name": "single_user",
"type": "boolean",

View file

@ -1,13 +1,13 @@
#!/bin/bash
# ============= FUTURE YUNOHOST HELPER =============
# Delete a file checksum from the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}
#=================================================
# PERSONNAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTUR OFFICIAL HELPERS
#=================================================

View file

@ -34,6 +34,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Load settings"
app=$YNH_APP_INSTANCE_NAME
@ -46,24 +47,28 @@ db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backup the app main dir"
ynh_backup "$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Backup nginx configuration"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Backup php-fpm configuration"
#ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backup the mysql database"
ynh_mysql_dump_db "$db_name" > db.sql
@ -72,12 +77,14 @@ ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_print_info "Backup logrotate configuration"
#ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_print_info "Backup systemd configuration"
ynh_backup "/etc/systemd/system/$app.service"
@ -86,3 +93,9 @@ ynh_backup "/etc/systemd/system/$app.service"
#=================================================
#ynh_backup "/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed. Please wait for YunoHost to create the backup."

View file

@ -22,6 +22,7 @@ fi
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_print_info "Retrieve arguments from the manifest"
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
@ -34,6 +35,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Load settings"
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path)
@ -45,6 +47,7 @@ final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
ynh_print_info "Check the syntax of the paths"
test -n "$old_path" || old_path="/"
test -n "$new_path" || new_path="/"
@ -72,6 +75,7 @@ fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_print_info "Modify url in nginx configuration"
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -132,5 +136,12 @@ ynh_store_file_checksum "$final_path/config.ini"
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reload nginx"
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Change of url completed"

View file

@ -34,6 +34,7 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_print_info "Retrieve arguments from the manifest ..."
domain=$YNH_APP_ARG_DOMAIN
#path_url=$YNH_APP_ARG_PATH
@ -81,8 +82,8 @@ ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Store settings from manifest ..."
ynh_print_info "Starting app installation ..."
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
@ -95,22 +96,23 @@ ynh_app_setting_set $app single_user $single_user
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_print_info "Configuring firewall ..."
### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port.
### If you're not using these lines:
### - Remove the section "CLOSE A PORT" in the remove script
ynh_print_info "Configuring firewall ..."
# Find a free port
port=$(ynh_find_port 8095)
# Open this port
#yunohost firewall allow --no-upnp TCP $port 2>&1
#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_app_setting_set $app port $port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies ..."
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
### Those deb packages will be installed as dependencies of this package.
@ -119,12 +121,12 @@ ynh_app_setting_set $app port $port
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
ynh_print_info "Installing dependencies ..."
#ynh_install_app_dependencies deb1 deb2
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_print_info "Creating a mysql database ..."
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
@ -135,7 +137,6 @@ ynh_print_info "Installing dependencies ..."
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
ynh_print_info "Initializing database ..."
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
@ -143,12 +144,12 @@ ynh_mysql_setup_db $db_name $db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files ..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_print_info "Setting up source files ..."
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
@ -156,24 +157,25 @@ ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx ..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
ynh_print_info "Configuring nginx ..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user ..."
# Create a system user
ynh_print_info "Configuring system user ..."
ynh_system_user_create "$app" "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm ..."
### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
@ -187,7 +189,6 @@ ynh_system_user_create "$app" "$final_path"
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
# Create a dedicated php-fpm config
#ynh_print_info "Configuring php-fpm ..."
#ynh_add_fpm_config
#=================================================
@ -199,6 +200,7 @@ ynh_system_user_create "$app" "$final_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Configuring a systemd service ..."
### `ynh_systemd_config` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd.
@ -212,7 +214,6 @@ ynh_system_user_create "$app" "$final_path"
### - And the section "SETUP SYSTEMD" in the upgrade script
# Create a dedicated systemd config
ynh_print_info "Configuring systemd service ..."
ynh_add_systemd_config
#=================================================
@ -237,6 +238,7 @@ ynh_add_systemd_config
#systemctl reload nginx
# Installation with curl
#ynh_print_info "Finalizing install ..."
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
# Remove the public access
@ -303,6 +305,7 @@ chown -R "$app":"$app" "$final_path"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Configuring log rotation ..."
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app.
@ -313,7 +316,6 @@ chown -R "$app":"$app" "$final_path"
### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s)
#ynh_print_info "Configuring log rotation ..."
#ynh_use_logrotate
#=================================================
@ -336,6 +338,7 @@ yunohost service add $app --description "$app daemon for WriteFreely" --log_type
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat ..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -347,8 +350,8 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx ..."
systemctl reload nginx
#=================================================
@ -356,3 +359,9 @@ systemctl reload nginx
#=================================================
ynh_systemd_action --action=start --service_name=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation completed"

View file

@ -23,6 +23,7 @@ fi
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Load settings"
app=$YNH_APP_INSTANCE_NAME
@ -40,13 +41,14 @@ final_path=$(ynh_app_setting_get $app final_path)
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app
then
echo "Remove $app service"
ynh_print_info "Remove $app service"
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_print_info "Stop and remove the service"
# Remove the dedicated systemd config
ynh_remove_systemd_config
@ -54,6 +56,7 @@ ynh_remove_systemd_config
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_print_info "Remove the mysql database"
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name
@ -61,6 +64,7 @@ ynh_mysql_remove_db $db_name $db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_print_info "Remove dependencies"
# Remove metapackage and its dependencies
#ynh_remove_app_dependencies
@ -68,6 +72,7 @@ ynh_mysql_remove_db $db_name $db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Remove app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -75,6 +80,7 @@ ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Remove nginx configuration"
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -82,6 +88,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Remove php-fpm configuration"
# Remove the dedicated php-fpm config
#ynh_remove_fpm_config
@ -89,6 +96,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_print_info "Remove logrotate configuration"
# Remove the app-specific logrotate config
#ynh_remove_logrotate
@ -96,11 +104,12 @@ ynh_remove_nginx_config
#=================================================
# CLOSE A PORT
#=================================================
ynh_print_info "Close ports"
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port" >&2
yunohost firewall disallow TCP $port 2>&1
ynh_print_info "Close port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
#=================================================
@ -123,6 +132,13 @@ ynh_secure_remove "/etc/$app/"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Remove the dedicated user"
# Delete a system user
ynh_system_user_delete $app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Deletion completed"

View file

@ -34,6 +34,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Load settings"
app=$YNH_APP_INSTANCE_NAME
@ -62,12 +63,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restore the app main directory"
ynh_restore_file "$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreate the dedicated user"
# Create the dedicated user (if not existing)
ynh_system_user_create "$app" "$final_path"
@ -90,6 +93,7 @@ chown -R "$app":"$app" "$final_path"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstall dependencies"
# Define and install dependencies
#ynh_install_app_dependencies deb1 deb2
@ -97,6 +101,7 @@ chown -R "$app":"$app" "$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_print_info "Restore the mysql database"
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
@ -105,6 +110,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restore the systemd configuration"
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
@ -133,6 +139,7 @@ yunohost service add $app --description "$app daemon for WriteFreely" --log_type
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_print_info "Reload nginx and php-fpm"
#systemctl reload php7.0-fpm
systemctl reload nginx
@ -142,3 +149,9 @@ systemctl reload nginx
#=================================================
ynh_systemd_action --action=start --service_name=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed"

View file

@ -24,6 +24,7 @@ fi
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Load settings"
app=$YNH_APP_INSTANCE_NAME
@ -54,6 +55,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensure downward compatibility"
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
@ -79,6 +81,7 @@ fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backup the app before upgrading"
# Backup the current version of the app
ynh_backup_before_upgrade
@ -108,6 +111,7 @@ path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Download, check and unpack source"
# Download, check integrity, uncompress and patch the source from app.src
if [ "$upgrade_type" == "UPGRADE_APP" ]
@ -118,6 +122,7 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Reconfigure nginx"
# Create a dedicated nginx config
ynh_add_nginx_config
@ -125,12 +130,14 @@ ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_print_info "Upgrade dependencies"
#ynh_install_app_dependencies deb1 deb2
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Create a dedicated user"
# Create a dedicated user (if not existing)
ynh_system_user_create "$app" "$final_path"
@ -138,6 +145,7 @@ ynh_system_user_create "$app" "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Reconfigure php-fpm"
# Create a dedicated php-fpm config
#ynh_add_fpm_config
@ -173,6 +181,7 @@ fi
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Reconfigure logrotate"
# Use logrotate to manage app-specific logfile(s)
#ynh_use_logrotate --non-append
@ -180,6 +189,7 @@ fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Reconfigure systemd"
# Create a dedicated systemd config
ynh_add_systemd_config
@ -196,6 +206,7 @@ chown -R "$app":"$app" "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Reconfigure SSOwat"
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -207,6 +218,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reload nginx"
systemctl reload nginx
@ -215,3 +227,9 @@ systemctl reload nginx
#=================================================
ynh_systemd_action --action=start --service_name=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade completed"