diff --git a/conf/systemd.service b/conf/systemd.service index 1215b5d..8ea1d9e 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,11 +7,11 @@ Requires=postgresql.service Type=notify User=__APP__ Group=__APP__ -ExecStart=__FINALPATH__/bin/mattermost +ExecStart=__INSTALL_DIR__/bin/mattermost TimeoutStartSec=3600 Restart=always RestartSec=10 -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__INSTALL_DIR__ RuntimeDirectory=__APP__ LimitNOFILE=49152 diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..d1968d8 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,87 @@ +packaging_format = 2 + +id = "mattermost" +name = "Mattermost" +description.en = "Open source collaboration platform built for developers" +description.fr = "Plateforme de collaboration open source conçue pour les développeurs" + +version = "7.5.2~ynh1" + +maintainers = ["pmorinerie"] + +[upstream] +license = "GPL-3.0-only" +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"] +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, ... + +[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" + + [install.init_main_permission] + help.en = "If enabled, Mattermost will be accessible by the user without a YunoHost account. This can be changed later via the webadmin." + help.fr = "Si cette case est cochée, Mattermost sera accessible par l'utilisateur sans compte YunoHost. Vous pourrez changer ceci plus tard via l’interface d’administration." + type = "group" + 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] + ask.en = "Choose the version you want to install" + ask.fr = "Choisissez la version que vous souhaitez installer" + help.en = "Use Team Edition for the open source version (ARM, ARM64 and x86-64 support) or Enterprise Edition if you want to use a license (x86-64 support only)" + help.fr = "Utilisez Team Edition pour la version open source (prise en charge ARM, ARM64 et x86-64) ou Enterprise Edition si vous souhaitez utiliser une licence (prise en charge x86-64 uniquement)" + type = "string" + choices = ["Enterprise", "Team"] + default = "Team" + + [install.language] + ask.en = "Choose the language of the chat for the admin" + ask.fr = "Choissisez la langue utilisée pour l'administrateur" + type = "string" + choices = ["de", "en", "es", "fr", "it", "pt"] + default = "en" + + [install.team_display_name] + ask.en = "Choose a Team name" + ask.fr = "Choisissez le nom de l’équipe" + type = "string" + example = "Team" + default = "Team" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index a5928ff..d63f892 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql postgresql-contrib pgloader" +#REMOVEME? pkg_dependencies="postgresql postgresql-contrib pgloader" #================================================= # PERSONAL HELPERS @@ -15,7 +15,7 @@ mariadb-to-pg() { ynh_print_info --message="Migrating to PostgreSQL database..." - mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +#REMOVEME? mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) # In old instance db_user is `mmuser` mysql_db_user="$db_user" @@ -24,15 +24,15 @@ mariadb-to-pg() { fi # Initialize PostgreSQL database - 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) +#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) # Configure the new database and run Mattermost in order to create tables - ynh_write_var_in_file --file="$final_path/config/config.json" --key="DriverName" --value="postgres" --after="SqlSettings" - ynh_write_var_in_file --file="$final_path/config/config.json" --key="DataSource" --value="postgres://$db_user:$psqlpwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10" --after="SqlSettings" - cat "$final_path/config/config.json" - pushd $final_path + ynh_write_var_in_file --file="$install_dir/config/config.json" --key="DriverName" --value="postgres" --after="SqlSettings" + ynh_write_var_in_file --file="$install_dir/config/config.json" --key="DataSource" --value="postgres://$db_user:$psqlpwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10" --after="SqlSettings" + cat "$install_dir/config/config.json" + pushd $install_dir ynh_systemd_action --service_name="$app" --action="stop" set +e sudo -u mattermost timeout --preserve-status 30 "./bin/mattermost" @@ -75,7 +75,7 @@ EOT # Removinging MySQL database - ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name +#REMOVEME? ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name } diff --git a/scripts/backup b/scripts/backup index 7aa0fef..ec5e8fb 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,23 +10,23 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +#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 @@ -37,7 +37,7 @@ 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 APP DATA diff --git a/scripts/install b/scripts/install index cfb1a3c..381ee95 100644 --- a/scripts/install +++ b/scripts/install @@ -13,48 +13,48 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? 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 +#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) -password=$YNH_APP_ARG_PASSWORD -language=$YNH_APP_ARG_LANGUAGE -team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME -version=$YNH_APP_ARG_VERSION +#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 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=6 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=6 -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=password --value="$password" +#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 @@ -62,57 +62,57 @@ ynh_app_setting_set --app=$app --key=team_display_name --value=$team_display_nam #================================================= # FIND AN AVAILABLE PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=3 +#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=3 # Find an available port -port=$(ynh_find_port --port=8065) -ynh_app_setting_set --app=$app --key=port --value=$port +#REMOVEME? port=$(ynh_find_port --port=8065) +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=10 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=10 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3 # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # CREATE A DATABASE #================================================= ynh_script_progression --message="Creating a database..." --weight=10 -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 +#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 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#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 # Get Enterprise binary path - ynh_setup_source --dest_dir="$final_path" --source_id="enterprise" + ynh_setup_source --dest_dir="$install_dir" --source_id="enterprise" elif [ "$version" = "Team" ]; then # Get Team binary path - ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" --source_id="$YNH_ARCH" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # CREATE DIRECTORY FOR DATA @@ -120,7 +120,7 @@ chown -R $app:www-data "$final_path" ynh_script_progression --message="Creating the data directory..." --weight=1 data_path=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=data_path --value=$data_path +#REMOVEME? ynh_app_setting_set --app=$app --key=data_path --value=$data_path mkdir -p $data_path @@ -148,10 +148,10 @@ ynh_use_logrotate ynh_script_progression --message="Modifying a config file..." --weight=3 smtp_user_pwd=$(ynh_string_random --length=24) -url=https://$domain$path_url -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +url=https://$domain$path +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -ynh_add_config --template="../conf/config.json" --destination="$final_path/config/config.json" +ynh_add_config --template="../conf/config.json" --destination="$install_dir/config/config.json" #================================================= # NGINX CONFIGURATION @@ -190,7 +190,7 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_ ynh_script_progression --message="Create the first administrator and team..." --weight=1 team_name=$(echo "$team_display_name" | iconv -f utf8 -t ascii//TRANSLIT//IGNORE | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z) -bin_mmctl="$final_path/bin/mmctl" +bin_mmctl="$install_dir/bin/mmctl" # mmctl is not packaged with ARM versions yet if [[ -f "$bin_mmctl" ]]; then @@ -203,25 +203,25 @@ if [[ -f "$bin_mmctl" ]]; then fi # Disable mmctl passwordless access -ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$final_path/config/config.json" +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 #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 -if [ $is_public -eq 1 ] +#REMOVEME? if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=2 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index aa3f444..21872f8 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,14 +13,14 @@ source /usr/share/yunohost/helpers # LOAD SETTINGS #================================================= -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +#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 @@ -57,15 +57,15 @@ ynh_remove_logrotate ynh_script_progression --message="Removing the database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=3 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR @@ -73,7 +73,7 @@ ynh_remove_app_dependencies ynh_script_progression --message="Removing $app main directory..." --weight=6 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE DATA DIR @@ -106,9 +106,9 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 87ea3d5..0a79caa 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,34 +13,34 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +#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 #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS @@ -54,21 +54,21 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=2 -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" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY @@ -86,19 +86,19 @@ chown -R $app:www-data "$data_path" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=10 # Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE DATABASE #================================================= ynh_script_progression --message="Restoring the database..." --weight=6 -db_pwd=$(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=$db_pwd +#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 fea6ce5..9aaa0c1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,54 +13,54 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -language=$(ynh_app_setting_get --app=$app --key=language) -version=$(ynh_app_setting_get --app=$app --key=version) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) -team_display_name=$(ynh_app_setting_get --app=$app --key=team_display_name) -admin=$(ynh_app_setting_get --app=$app --key=admin) -password=$(ynh_app_setting_get --app=$app --key=password) +#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) email=$(ynh_user_get_info --username=$admin --key=mail) -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? db_user=$db_name #================================================= # CHECK VERSION #================================================= ynh_script_progression --message="Checking version..." --weight=1 -previous_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" +#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 #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -69,7 +69,7 @@ ynh_abort_if_errors # Save the port used if not present if [ -z "$port" ]; then port=8065 - ynh_app_setting_set --app=$app --key=port --value=$port +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port fi # Save the language used if not present @@ -86,18 +86,18 @@ fi if [ -z "$db_name" ]; then db_name="$app" - ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi -# If final_path doesn't exist, create it +# If install_dir doesn't exist, create it if [ -z "$data_path" ]; then data_path="/home/yunohost.app/$app" - ynh_app_setting_set --app=$app --key=data_path --value=$data_path +#REMOVEME? ynh_app_setting_set --app=$app --key=data_path --value=$data_path fi # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi @@ -105,9 +105,9 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=10 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=10 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # MIGRATING DATABASE @@ -132,10 +132,10 @@ ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$ #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -149,29 +149,29 @@ then tmpdir="$(mktemp -d)" # Backup the config file and local plugins in the temp dir - cp -a "$final_path/config/config.json" "$tmpdir/config.json" - cp -ar "$final_path/plugins" "$tmpdir/plugins" + cp -a "$install_dir/config/config.json" "$tmpdir/config.json" + cp -ar "$install_dir/plugins" "$tmpdir/plugins" # Remove the app directory securely - ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" if [ "$version" = "Enterprise" ]; then - ynh_setup_source --dest_dir="$final_path" --source_id="enterprise" + ynh_setup_source --dest_dir="$install_dir" --source_id="enterprise" elif [ "$version" = "Team" ]; then - ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" --source_id="$YNH_ARCH" fi # Copy the admin saved settings and plugins from tmp directory to final path - cp -a "$tmpdir/config.json" "$final_path/config/config.json" - cp -ar --no-clobber "$tmpdir/plugins" "$final_path/" + cp -a "$tmpdir/config.json" "$install_dir/config/config.json" + cp -ar --no-clobber "$tmpdir/plugins" "$install_dir/" # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -244,9 +244,9 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_ #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT