diff --git a/doc/DISCLAIMER.md b/doc/POST_INSTALL.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/POST_INSTALL.md diff --git a/doc/DISCLAIMER_fr.md b/doc/POST_INSTALL_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/POST_INSTALL_fr.md diff --git a/manifest.toml b/manifest.toml index d1968d8..116dfee 100644 --- a/manifest.toml +++ b/manifest.toml @@ -15,26 +15,22 @@ website = "http://www.mattermost.org/" admindoc = "https://docs.mattermost.com/guides/deployment.html" userdoc = "https://docs.mattermost.com/guides/messaging.html" code = "https://github.com/mattermost/mattermost-server" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. [integration] yunohost = ">= 11.1.6" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +architectures = ["amd64", "armhf", "arm64"] multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = "?" +sso = "?" +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" [install.path] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "path" default = "/mattermost" @@ -45,11 +41,9 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen default = "visitors" [install.admin] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "user" [install.password] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "password" [install.version] @@ -80,6 +74,10 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.install_dir] + [resources.data_dir] + + [resources.ports] + [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index d63f892..1612d4c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,7 +15,7 @@ mariadb-to-pg() { ynh_print_info --message="Migrating to PostgreSQL database..." -#REMOVEME? mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) # In old instance db_user is `mmuser` mysql_db_user="$db_user" @@ -24,9 +24,9 @@ mariadb-to-pg() { fi # Initialize PostgreSQL database -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$mysqlpwd -#REMOVEME? psqlpwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) + ynh_psql_test_if_first_run + ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$mysqlpwd + psqlpwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Configure the new database and run Mattermost in order to create tables ynh_write_var_in_file --file="$install_dir/config/config.json" --key="DriverName" --value="postgres" --after="SqlSettings" @@ -75,7 +75,7 @@ EOT # Removinging MySQL database -#REMOVEME? ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name + ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name } diff --git a/scripts/backup b/scripts/backup index ec5e8fb..ac5599c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,28 +6,6 @@ source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/install b/scripts/install index 381ee95..9317f93 100644 --- a/scripts/install +++ b/scripts/install @@ -9,97 +9,28 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? admin=$YNH_APP_ARG_ADMIN email=$(ynh_user_get_info --username=$admin --key=mail) -#REMOVEME? password=$YNH_APP_ARG_PASSWORD -#REMOVEME? language=$YNH_APP_ARG_LANGUAGE -#REMOVEME? team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME -#REMOVEME? version=$YNH_APP_ARG_VERSION - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path +team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME +version=$YNH_APP_ARG_VERSION #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=6 +ynh_script_progression --message="Storing installation settings..." --weight=6 -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin -#REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password" ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=version --value=$version ynh_app_setting_set --app=$app --key=team_display_name --value=$team_display_name -#================================================= -# FIND AN AVAILABLE PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=3 - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8065) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=10 - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - -#================================================= -# CREATE A DATABASE -#================================================= -ynh_script_progression --message="Creating a database..." --weight=10 - -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src if [ "$version" = "Enterprise" ]; then @@ -110,24 +41,8 @@ elif [ "$version" = "Team" ]; then ynh_setup_source --dest_dir="$install_dir" --source_id="$YNH_ARCH" fi -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# CREATE DIRECTORY FOR DATA -#================================================= -ynh_script_progression --message="Creating the data directory..." --weight=1 - -data_path=/home/yunohost.app/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=data_path --value=$data_path - -mkdir -p $data_path - -chmod 750 "$data_path" -chmod -R o-rwx "$data_path" -chown -R $app:www-data "$data_path" - #================================================= # HANDLE LOG FILES AND LOGROTATE #================================================= @@ -149,7 +64,6 @@ ynh_script_progression --message="Modifying a config file..." --weight=3 smtp_user_pwd=$(ynh_string_random --length=24) url=https://$domain$path -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_add_config --template="../conf/config.json" --destination="$install_dir/config/config.json" @@ -206,23 +120,6 @@ fi ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$install_dir/config/config.json" ynh_systemd_action --service_name=$app --action=restart --log_path=systemd --line_match="Started Mattermost" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -#REMOVEME? if [ $is_public -eq 1 ] -then -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 21872f8..73c853e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path) - #================================================= # STANDARD REMOVE #================================================= @@ -51,41 +38,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE DATABASE -#================================================= -ynh_script_progression --message="Removing the database..." --weight=2 - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=3 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=6 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$data_path" -fi - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -103,13 +55,6 @@ ynh_script_progression --message="Removing various files..." --weight=1 ynh_secure_remove --file="/var/log/$app" -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 0a79caa..e04a2da 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,39 +9,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -51,14 +18,6 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -66,8 +25,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= @@ -83,22 +40,11 @@ chmod 750 "$data_path" chmod -R o-rwx "$data_path" chown -R $app:www-data "$data_path" -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=10 - -# Define and install dependencies -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE DATABASE #================================================= ynh_script_progression --message="Restoring the database..." --weight=6 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9aaa0c1..55cbfbf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,59 +9,20 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # LOAD SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language) -#REMOVEME? version=$(ynh_app_setting_get --app=$app --key=version) -#REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path) -#REMOVEME? team_display_name=$(ynh_app_setting_get --app=$app --key=team_display_name) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password) +team_display_name=$(ynh_app_setting_get --app=$app --key=team_display_name) email=$(ynh_user_get_info --username=$admin --key=mail) -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 -#REMOVEME? previous_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -91,24 +52,11 @@ fi # If install_dir doesn't exist, create it if [ -z "$data_path" ]; then - data_path="/home/yunohost.app/$app" -#REMOVEME? ynh_app_setting_set --app=$app --key=data_path --value=$data_path + data_path=data_dir + data_dir="/home/yunohost.app/$app" + ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir fi -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=10 - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # MIGRATING DATABASE #================================================= @@ -129,14 +77,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=3 ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -153,7 +93,7 @@ then cp -ar "$install_dir/plugins" "$tmpdir/plugins" # Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" + ynh_secure_remove --file="$install_dir" if [ "$version" = "Enterprise" ]; then ynh_setup_source --dest_dir="$install_dir" --source_id="enterprise" @@ -181,8 +121,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config - - #================================================= # SETUP SYSTEMD #================================================= @@ -216,8 +154,6 @@ EOM # If nothing is displayed in the sidebar it may be needed to change the Id of SidebarCategories... fi - - #================================================= # SETUP LOGROTATE #================================================= @@ -241,13 +177,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..ce71724 --- /dev/null +++ b/tests.toml @@ -0,0 +1,18 @@ +test_format = 1.0 + +[default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.email = "john@gmail.com" + args.admin_password = "admin!42" + args.version = "Enterprise" + args.team_display_name = "Mon équipe" + +["Test with Team Edition"] + + only = ["install.subdir", "backup_restore", "upgrade" ] + args.version = "Team" +