diff --git a/README.md b/README.md index 0724f68..bcc3c04 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,6 @@ Web-based cross-platform XMPP client ![Screenshot of Movim](./doc/screenshots/movim.png) -## Disclaimers / important information - -## Configuration - - * After installing the app, it can be configured at https://example.com/movim/?admin using the username and password defined during the installation. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 3af56e4..3b5ee72 100644 --- a/README_fr.md +++ b/README_fr.md @@ -27,12 +27,6 @@ Client XMPP multiplateforme basé sur le Web ![Capture d’écran de Movim](./doc/screenshots/movim.png) -## Avertissements / informations importantes - -## Configuration - - * Après l'installation, l'application peut être configurée sur https://example.com/movim/?admin en utilisant le nom d'utilisateur et le mot de passe définis lors de l'installation. - ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index ea5e366..0000000 --- a/check_process +++ /dev/null @@ -1,29 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - language="fr" - admin="john" - password="1Strong-Password" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # 0.19~ynh1 - upgrade=1 from_commit=80bdea70f80aafef673718911ad492ddc54aab5c - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=80bdea70f80aafef673718911ad492ddc54aab5c - name=0.19~ynh1 - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=phrasedepasse& diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 1ddbcec..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/movim/movim/archive/v0.19.tar.gz -SOURCE_SUM=df98b5b0df6fd6bfa5fda88f387ac017bc7bcead42c462745296604f3e0ee501 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index a7e6452..93291a2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/public/; + alias __INSTALL_DIR__/public/; more_set_headers "Access-Control-Allow-Origin: *"; diff --git a/conf/systemd.service b/conf/systemd.service index a1918e1..7403f00 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ User=__APP__ Group=__APP__ Environment=PUBLIC_URL=https://__DOMAIN____PATH__/ Environment=WS_PORT=__PORT__ -WorkingDirectory=__FINALPATH__/ +WorkingDirectory=__INSTALL_DIR__/ ExecStart=/usr/bin/php__PHPVERSION__ daemon.php start --url=${PUBLIC_URL} --port=${WS_PORT} StandardOutput=syslog SyslogIdentifier=__APP__ diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..9c79cf0 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1 @@ +The app can be configured at using the username and password defined during the installation. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..ed9211f --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1 @@ +L'application peut être configurée sur en utilisant le nom d'utilisateur et le mot de passe définis lors de l'installation. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e389646..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,3 +0,0 @@ -## Configuration - - * After installing the app, it can be configured at https://example.com/movim/?admin using the username and password defined during the installation. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index 0f3c02c..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,3 +0,0 @@ -## Configuration - - * Après l'installation, l'application peut être configurée sur https://example.com/movim/?admin en utilisant le nom d'utilisateur et le mot de passe définis lors de l'installation. diff --git a/doc/screenshots/movim.png b/doc/screenshots/movim.png index e7fab07..47c9c1b 100644 Binary files a/doc/screenshots/movim.png and b/doc/screenshots/movim.png differ diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 468e288..0000000 --- a/manifest.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "Movim", - "id": "movim", - "packaging_format": 1, - "description": { - "en": "Web-based cross-platform XMPP client", - "fr": "Client XMPP multiplateforme basé sur le Web" - }, - "version": "0.19~ynh5", - "url": "https://movim.eu", - "upstream": { - "license": "AGPL-3.0-or-later", - "website": "https://movim.eu", - "demo": "https://nl.movim.eu/?login", - "admindoc": "https://github.com/movim/movim/wiki", - "code": "https://github.com/movim/movim", - "cpe": "cpe:2.3:a:movim:movim" - }, - "license": "AGPL-3.0-or-later", - "maintainer": { - "name": "", - "email": "" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": false, - "services": [ - "nginx", - "php7.4-fpm", - "postgresql", - "metronome" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/movim", - "default": "/movim" - }, - { - "name": "is_public", - "type": "boolean", - "default": true - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "password", - "type": "password" - } - ] - } -} \ No newline at end of file diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..51c9161 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,80 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "movim" +name = "Movim" +description.en = "Decentralized social platform based on XMPP" +description.fr = "Plateforme sociale décentralisée basée sur XMPP" + +version = "0.19~ynh5" + +maintainers = [] + +[upstream] +license = "AGPL-3.0-or-later" +website = "https://movim.eu" +demo = "https://nl.movim.eu/?login" +admindoc = "https://github.com/movim/movim/wiki" +code = "https://github.com/movim/movim" +cpe = "cpe:2.3:a:movim:movim" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = false +ldap = false +sso = false +disk = "50M" +ram.build = "100M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/movim" + + [install.init_main_permission] + type = "group" + default = "visitors" + + [install.admin] + type = "user" + + [install.password] + type = "password" + +[resources] + [resources.sources.main] + url = "https://github.com/movim/movim/archive/v0.19.tar.gz" + sha256 = "df98b5b0df6fd6bfa5fda88f387ac017bc7bcead42c462745296604f3e0ee501" + + autoupdate.strategy = "latest_github_tag" + + [resources.ports] + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = [ + "php7.4-curl", + "php7.4-mbstring", + "php7.4-imagick", + "php7.4-gd", + "php7.4-pgsql", + "php7.4-xml", + "postgresql", + "postgresql-contrib", + "apt-transport-https", + ] + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 70fa908..ff3a014 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,14 +4,8 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.4" - YNH_COMPOSER_VERSION="2.2.5" -php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-xml" - -pkg_dependencies="postgresql postgresql-contrib apt-transport-https $php_dependencies" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index cc57d2b..b371c66 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,28 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_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) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -41,24 +19,16 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE PHP-FPM CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 375f20e..dde6c32 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,64 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -74,64 +16,28 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi +ynh_change_url_nginx_config #================================================= # SPECIFIC MODIFICATIONS #================================================= -# SETUP SYSTEMD -#================================================= ynh_script_progression --message="Configuring a systemd service..." -domain=$new_domain -path=$new_path ynh_add_systemd_config -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Movim daemon launched" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Movim daemon launched" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 3c7d079..9326fbb 100644 --- a/scripts/install +++ b/scripts/install @@ -10,128 +10,37 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# INITIALIZE AND STORE SETTINGS #================================================= -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC -admin=$YNH_APP_ARG_ADMIN -password=$YNH_APP_ARG_PASSWORD - -app=$YNH_APP_INSTANCE_NAME - -timezone=$(cat /etc/timezone) fpm_footprint="low" fpm_free_footprint=0 fpm_usage="low" +ynh_app_setting_set --app="$app" --key=fpm_footprint --value="$fpm_footprint" +ynh_app_setting_set --app="$app" --key=fpm_free_footprint --value="$fpm_free_footprint" +ynh_app_setting_set --app="$app" --key=fpm_usage --value="$fpm_usage" #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +# CONFIGURING A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Configuring a PostgreSQL database..." -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint -ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint -ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." - -# Find an available port -port=$(ynh_find_port --port=9537) -ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name +ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" +ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -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" +ynh_setup_source --dest_dir="$install_dir" # Temporary workaround to fix movim.ERROR: Error: Call to undefined function GuzzleHttp\Psr7\uri_for() -ynh_replace_string --match_string="0.3.5" --replace_string="0.4.1" --target_file="$final_path/composer.json" +ynh_replace_string --match_string="0.3.5" --replace_string="0.4.1" --target_file="$install_dir/composer.json" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." - -# Create a dedicated NGINX config -ynh_add_nginx_config +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # SPECIFIC SETUP @@ -140,36 +49,36 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." -ynh_add_config --template="../conf/db.example.inc.php" --destination="$final_path/config/db.inc.php" +ynh_add_config --template="db.example.inc.php" --destination="$install_dir/config/db.inc.php" -chmod 400 "$final_path/config/db.inc.php" -chown $app:$app "$final_path/config/db.inc.php" - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config +chmod 400 "$install_dir/config/db.inc.php" +chown "$app:$app" "$install_dir/config/db.inc.php" #================================================= # BUILD MOVIM #================================================= ynh_script_progression --message="Building Movim..." -ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path" -ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$final_path" --commands="movim:migrate" -ynh_exec_as $app php$phpversion $final_path/daemon.php config --username=$admin --password=$password --quiet +# Install composer +ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir" + +ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$install_dir" --commands="movim:migrate" +ynh_exec_as "$app" "php$phpversion" "$install_dir/daemon.php" config --username="$admin" --password="$password" --quiet #================================================= -# GENERIC FINALIZATION +# SYSTEM CONFIGURATION #================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 -yunohost service add $app --description="Responsive web-based XMPP client" +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint + +# Create a dedicated NGINX config +ynh_add_nginx_config + +# Create a dedicated systemd config +ynh_add_systemd_config +yunohost service add "$app" --description="Responsive web-based XMPP client" #================================================= # START SYSTEMD SERVICE @@ -177,27 +86,7 @@ yunohost service add $app --description="Responsive web-based XMPP client" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Movim daemon launched" - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. - ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Movim daemon launched" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index b7d84fa..24adb09 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,89 +10,24 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 97055ea..1a6977b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,131 +10,51 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -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) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -timezone=$(cat /etc/timezone) - -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." - -# Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -# Recreate a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +# Recreate a dedicated PHP-FPM config +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="Responsive web-based XMPP client" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Movim daemon launched" +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="Responsive web-based XMPP client" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Movim daemon launched" +ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload + +ynh_systemd_action --service_name=nginx --action="reload" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index e470061..7c13422 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,49 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) -timezone=$(cat /etc/timezone) - -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -59,7 +16,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -67,93 +24,36 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li ynh_script_progression --message="Ensuring downward compatibility..." # If fpm_footprint doesn't exist, create it -if [ -z "$fpm_footprint" ]; then +if [ -z "${fpm_footprint:-}" ]; then fpm_footprint=low - ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint + ynh_app_setting_set --app="$app" --key=fpm_footprint --value="$fpm_footprint" fi # If fpm_free_footprint doesn't exist, create it -if [ -z "$fpm_free_footprint" ]; then +if [ -z "${fpm_free_footprint:-}" ]; then fpm_free_footprint=0 - ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint + ynh_app_setting_set --app="$app" --key=fpm_free_footprint --value="$fpm_free_footprint" fi # If fpm_usage doesn't exist, create it -if [ -z "$fpm_usage" ]; then +if [ -z "${fpm_usage:-}" ]; then fpm_usage=low - ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage + ynh_app_setting_set --app="$app" --key=fpm_usage --value="$fpm_usage" fi -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - db_user=$db_name - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/db.inc.php" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="config/db.inc.php" +# Temporary workaround to fix movim.ERROR: Error: Call to undefined function GuzzleHttp\Psr7\uri_for() +ynh_replace_string --match_string="0.3.5" --replace_string="0.4.1" --target_file="$install_dir/composer.json" - # Temporary workaround to fix movim.ERROR: Error: Call to undefined function GuzzleHttp\Psr7\uri_for() - ynh_replace_string --match_string="0.3.5" --replace_string="0.4.1" --target_file="$final_path/composer.json" -fi - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - -# Create a dedicated NGINX config -ynh_add_nginx_config +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # SPECIFIC UPGRADE @@ -162,51 +62,43 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_add_config --template="../conf/db.example.inc.php" --destination="$final_path/config/db.inc.php" +ynh_add_config --template="db.example.inc.php" --destination="$install_dir/config/db.inc.php" -chmod 400 "$final_path/config/db.inc.php" -chown $app:$app "$final_path/config/db.inc.php" +chmod 400 "$install_dir/config/db.inc.php" +chown "$app:$app" "$install_dir/config/db.inc.php" #================================================= # BUILD MOVIM #================================================= ynh_script_progression --message="Building Movim..." -ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path" -ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$final_path" --commands="config --global discard-changes true --quiet" -ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$final_path" --commands="update --no-interaction --quiet" -ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$final_path" --commands="movim:migrate --quiet" +ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir" +ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$install_dir" --commands="config --global discard-changes true --quiet" +ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$install_dir" --commands="update --no-interaction --quiet" +ynh_exec_warn_less ynh_composer_exec --phpversion="$phpversion" --workdir="$install_dir" --commands="movim:migrate --quiet" #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --phpversion="$phpversion" --usage="$fpm_usage" --footprint="$fpm_footprint" + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="Responsive web-based XMPP client" +yunohost service add "$app" --description="Responsive web-based XMPP client" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Movim daemon launched" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload +# Start a systemd service +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Movim daemon launched" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..f1e72b7 --- /dev/null +++ b/tests.toml @@ -0,0 +1,11 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.80bdea70.name = "Upgrade from 0.19~ynh1"