From 6944cda5371d165e55f58cc842db8004065121bf Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:32:05 +0100 Subject: [PATCH 1/7] tests: use more recent Yunohost box --- Vagrantfile | 14 +++++++++++++- test.sh | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index ca9abb1..611c8b3 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,11 +11,23 @@ Vagrant.configure("2") do |config| # https://docs.vagrantup.com. config.vm.define :ynhtests - config.vm.box = "yunohost/jessie-stable" + config.vm.box = "yunohost-stretch-unstable" + config.vm.box_url = "https://build.yunohost.org/yunohost-stretch-unstable.box" # Disable auto updates checks. Run `vagrant outdated` to perform manual updates. config.vm.box_check_update = false + # Configuration for the vagrant-disksize plugin. + # We need more space because package_check will create many LXC containers and snapshots. + # + # IMPORTANT: when re-creating the VM from scratch, the logical size of the disk will + # still be 10 Go. + # You'll need a live GParted ISO to resize partitions and fix it. + config.disksize.size = '20GB' + + # Force guest type, because YunoHost /etc/issue can't be tuned + config.vm.guest = :debian + # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. diff --git a/test.sh b/test.sh index bd52d6f..9514a9a 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,7 @@ #!/bin/bash # Run package_check tests against the app in the working directory on a Vagrant virtual machine. +# +# NB: Vagrant is used because package_check uses LXC containers, and Docker doesn't support running LXC. # Fail on first error set -e From 5e72edfc8fbdd397498a6e66fd9b2d54424d4e09 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:32:21 +0100 Subject: [PATCH 2/7] tests: comment out bogus Vagrant settings, that prevent Internet connectivity --- Vagrantfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 611c8b3..5d0bf0c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -40,11 +40,11 @@ Vagrant.configure("2") do |config| # Use the NAT hosts DNS resolver. Fixes slow network in the guest. # See https://serverfault.com/questions/495914/vagrant-slow-internet-connection-in-guest - config.vm.provider "virtualbox" do |v| - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - v.customize ["modifyvm", :id, "--natdnsproxy1", "on"] - v.customize ["modifyvm", :id, "--nictype1", "virtio"] - end + #config.vm.provider "virtualbox" do |v| + # v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + # v.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + # v.customize ["modifyvm", :id, "--nictype1", "virtio"] + #end # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is From 849d75bcbc4152bcb496e63711db10061424d821 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:32:38 +0100 Subject: [PATCH 3/7] tests: make default password more complex Otherwise Yunohost rejects it. --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 5d0bf0c..6333f72 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -60,7 +60,7 @@ Vagrant.configure("2") do |config| # documentation for more information about their specific syntax and use. config.vm.provision "shell", privileged: false, keep_color: true, inline: <<-SHELL DOMAIN=ynhtests.local - YUNOHOST_ADMIN_PASSWORD="alpine" + YUNOHOST_ADMIN_PASSWORD="ynhadminpwd" # Stop on first error set -e From f07b4a7822ea193173e9e48384a039bbafe245f7 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:33:19 +0100 Subject: [PATCH 4/7] app: implement subpath support --- README.md | 3 +-- check_process | 7 +++---- conf/nginx.conf | 4 ++-- manifest.json | 10 ++++++++++ scripts/install | 3 ++- scripts/restore | 2 +- scripts/upgrade | 3 ++- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d6ac03d..c02ca3b 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,13 @@ You can either : ## What works -* Installation on domain's root +* Installation on domain root or sub-directory * Notification emails * Push notifications * Service control in Yunohost Services panel ## TODO -* Allow installation in sub-directory (only root-domains for now, see [#8](https://github.com/YunoHost-Apps/mattermost_ynh/issues/8)) * LDAP integration (only paid Entreprise Edition, see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58)) ## About telemetrics diff --git a/check_process b/check_process index d57e774..b6d972e 100644 --- a/check_process +++ b/check_process @@ -1,7 +1,7 @@ ;; Mattermost ; Manifest domain="ynhtests.local" (DOMAIN) - path="" (PATH) + path="/path" (PATH) admin_email="john@gmail.com" admin_password="MattermostPassword!42" admin_locale="fr" @@ -10,6 +10,7 @@ analytics=0 ; Checks pkg_linter=1 + setup_sub_dir=1 setup_root=1 setup_private=1 setup_public=1 @@ -20,14 +21,12 @@ # Checks not supported yet change_url=0 # Checks not applicable - setup_sub_dir=0 setup_nourl=0 - incorrect_path=0 ;;; Levels Level 1=auto Level 2=auto Level 3=auto - Level 4=na + Level 4=auto Level 5=auto Level 6=auto Level 7=auto diff --git a/conf/nginx.conf b/conf/nginx.conf index f2daff7..edbf5b1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ # Directives from the Mattermost installation guide -location ~ /api/v[0-9]+/(users/)?websocket$ { +location ~ __PATH__/api/v[0-9]+/(users/)?websocket$ { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; client_max_body_size 50M; @@ -15,7 +15,7 @@ location ~ /api/v[0-9]+/(users/)?websocket$ { proxy_pass http://127.0.0.1:__PORT__; } -location / { +location __PATH__/ { client_max_body_size 50M; proxy_set_header Connection ""; proxy_set_header Host $http_host; diff --git a/manifest.json b/manifest.json index 44a31c4..d073f82 100644 --- a/manifest.json +++ b/manifest.json @@ -31,6 +31,16 @@ }, "example": "domain.org" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Mattermost", + "fr": "Choisissez un chemin pour Mattermost" + }, + "example": "/chat", + "default": "/chat" + }, { "name": "is_public", "type": "boolean", diff --git a/scripts/install b/scripts/install index b62c3fc..5df8433 100644 --- a/scripts/install +++ b/scripts/install @@ -21,13 +21,13 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC admin_email=$YNH_APP_ARG_ADMIN_EMAIL admin_password=$YNH_APP_ARG_ADMIN_PASSWORD admin_locale=$YNH_APP_ARG_ADMIN_LOCALE team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME analytics=$YNH_APP_ARG_ANALYTICS -path_url="/" #================================================= # CHECK IF THE APP CAN BE INSTALLED @@ -71,6 +71,7 @@ ynh_webpath_available "$domain" "$path_url" ynh_webpath_register "$app" "$domain" "$path_url" # Store setting ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path "$path_url" #================================================= # FIND AN AVAILABLE PORT diff --git a/scripts/restore b/scripts/restore index d1f4d44..7aab3b3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -21,7 +21,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) is_public=$(ynh_app_setting_get $app is_public) -path_url="/" +path_url=$(ynh_app_setting_get $app path) final_path="/var/www/$app" data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 965f1f8..a09df26 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) # used during nginx configuration is_public=$(ynh_app_setting_get $app is_public) port=$(ynh_app_setting_get $app port) mattermost_user="$app" @@ -55,7 +56,7 @@ ynh_clean_setup () { fi # Restore the backup ynh_restore_upgradebackup - + else # Backup restoration is not available: # let's try at least to restart the server. From d80f335f9d4fc3ebb2dee474d04e2e983b4c9faf Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:33:30 +0100 Subject: [PATCH 5/7] app: improve the manifest file --- manifest.json | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index d073f82..993bd1a 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "nginx" ], "requirements": { - "yunohost": ">= 2.7.0" + "yunohost": ">= 3.2.0" }, "arguments": { "install" : [ @@ -44,14 +44,15 @@ { "name": "is_public", "type": "boolean", - "ask": { - "en": "Can guest users access this chat?", - "fr": "Les utilisateurs non-enregistrés peuvent-ils accéder à ce chat ?" + "help": { + "en": "Can users non registered on Yunohost access this chat?", + "fr": "Les invités non-enregistrés sur Yunohost peuvent-ils accéder à ce chat ?" }, "default": true }, { "name": "admin_email", + "type": "string", "ask": { "en": "Login email for the chat admin", "fr": "Adresse email de login pour l’administrateur du chat" @@ -70,6 +71,7 @@ }, { "name": "admin_locale", + "type": "string", "ask": { "en": "Choose the language of the chat for the admin", "fr": "Choissisez la langue utilisée pour l'administrateur" @@ -79,11 +81,13 @@ }, { "name": "team_display_name", + "type": "string", "ask": { "en": "Choose a Team name", "fr": "Choisissez le nom de l’équipe" }, - "example": "Super Groupe", + "example": "Team", + "default": "Team", "optional": false }, { From e526f969a97d83e41d29edbfdf6f40c7e5f24e83 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sat, 8 Feb 2020 23:34:06 +0100 Subject: [PATCH 6/7] scripts: remove the service before removing the systemd config Yunohost complains if the systemd unit doesn't exist when removing the service. --- scripts/remove | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/remove b/scripts/remove index ed12aff..fb9dbda 100755 --- a/scripts/remove +++ b/scripts/remove @@ -24,6 +24,15 @@ logs_path="/var/log/$app" #================================================= # STANDARD REMOVE +#================================================= +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +if sudo yunohost service status | grep -q "$app"; then + sudo yunohost service remove "$app" +fi + #================================================= # STOP AND REMOVE SERVICE #================================================= @@ -40,14 +49,6 @@ if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then sudo ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf" fi -#================================================= -# REMOVE SERVICE FROM ADMIN PANEL -#================================================= - -if sudo yunohost service status | grep -q "$app"; then - sudo yunohost service remove "$app" -fi - #================================================= # REMOVE THE MYSQL DATABASE #================================================= From fefff41733fc305cca1c47b6fbf178c133825803 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sun, 9 Feb 2020 00:27:51 +0100 Subject: [PATCH 7/7] scripts: remove all usages of sudo The scripts are already run as root. --- README.md | 2 +- scripts/install | 54 ++++++++++++++++++++++++------------------------- scripts/remove | 14 ++++++------- scripts/restore | 14 ++++++------- scripts/upgrade | 38 +++++++++++++++++----------------- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index c02ca3b..ac83478 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A Yunohost package for [Mattermost](http://www.mattermost.org/), an open-source, Mattermost requires: * A x86_64 system (check with `uname -m`), -* Yunohost 2.7 or higher (check in Yunohost Admin panel), +* Yunohost 3.2 or higher (check in Yunohost Admin panel), * MySQL 5.6 or higher, or MariaDB 10 or higher (check with `mysql --version`). ## Installing diff --git a/scripts/install b/scripts/install index 5df8433..226b97c 100644 --- a/scripts/install +++ b/scripts/install @@ -107,7 +107,7 @@ ynh_app_setting_set "$app" mysqlpwd "$db_password" mattermost_user="$app" mattermost_user_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') -sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user" +useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user" ynh_app_setting_set "$app" smtppwd "$mattermost_user_password" #================================================= @@ -117,36 +117,36 @@ ynh_app_setting_set "$app" smtppwd "$mattermost_user_password" ynh_app_setting_set "$app" final_path "$final_path" ynh_setup_source "$final_path" -sudo mkdir -p "$data_path" -sudo mkdir -p "$logs_path" +mkdir -p "$data_path" +mkdir -p "$logs_path" #================================================= # EDIT MATTERMOST CONFIG #================================================= # Configure Service Settings -sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json -sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json +sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json +sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json # Configure the database connection db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8" -sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json +sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json # Configure uploaded files directory -sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json +sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json # Configure SMTP account for sending email notifications -sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json -sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json -sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_user}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${mattermost_user_password}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json +sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json +sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json +sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json +sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_user}\"|g" $final_path/config/config.json +sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${mattermost_user_password}\"|g" $final_path/config/config.json +sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json +sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json # Disable Mattermost debug console by default -sudo sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json +sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json # Configure log file location -sudo sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json +sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json # Configure analytics according to user choice if [ $analytics -eq 0 ]; then - sudo sed -i "s|\"EnableDiagnostics\": true|\"EnableDiagnostics\": false|g" $final_path/config/config.json + sed -i "s|\"EnableDiagnostics\": true|\"EnableDiagnostics\": false|g" $final_path/config/config.json fi ynh_app_setting_set "$app" analytics "$analytics" @@ -154,9 +154,9 @@ ynh_app_setting_set "$app" analytics "$analytics" # SECURE FILES AND DIRECTORIES #================================================= -sudo chown -R "$mattermost_user:www-data" "$final_path" -sudo chown -R "$mattermost_user:www-data" "$data_path" -sudo chown -R "$mattermost_user:adm" "$logs_path" +chown -R "$mattermost_user:www-data" "$final_path" +chown -R "$mattermost_user:www-data" "$data_path" +chown -R "$mattermost_user:adm" "$logs_path" #================================================= # NGINX CONFIGURATION @@ -174,7 +174,7 @@ ynh_add_systemd_config # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -sudo yunohost service add "$app" --log "$logs_path/mattermost.log" +yunohost service add "$app" --log "$logs_path/mattermost.log" #================================================= # SETUP SSOWAT @@ -191,13 +191,13 @@ fi # RELOAD NGINX #================================================= -sudo systemctl reload nginx +systemctl reload nginx #================================================= # START SERVER #================================================= -sudo systemctl start "$app" +systemctl start "$app" #================================================= # CREATE ADMIN AND FIRST TEAM @@ -207,10 +207,10 @@ admin_username=$(cut -d @ -f 1 <<< "$admin_email") 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) cd "$final_path/bin" -sudo ./mattermost user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin -sudo ./mattermost user verify "$admin_username" -sudo ./mattermost team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email" -sudo ./mattermost team add "$team_name" "$admin_username" +./mattermost user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin +./mattermost user verify "$admin_username" +./mattermost team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email" +./mattermost team add "$team_name" "$admin_username" ynh_app_setting_set "$app" admin_email "$admin_email" ynh_app_setting_set "$app" admin_locale "$admin_locale" diff --git a/scripts/remove b/scripts/remove index fb9dbda..349c576 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,8 +29,8 @@ logs_path="/var/log/$app" # REMOVE SERVICE FROM ADMIN PANEL #================================================= -if sudo yunohost service status | grep -q "$app"; then - sudo yunohost service remove "$app" +if yunohost service status | grep -q "$app"; then + yunohost service remove "$app" fi #================================================= @@ -38,15 +38,15 @@ fi #================================================= # Remove systemd service -if $(sudo systemctl -q is-active "$app"); then - sudo systemctl stop "$app" +if $(systemctl -q is-active "$app"); then + systemctl stop "$app" fi ynh_remove_systemd_config # Legacy, for older versions of this app which used supervisor if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then - sudo supervisorctl stop "$app" - sudo ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf" + supervisorctl stop "$app" + ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf" fi #================================================= @@ -72,7 +72,7 @@ ynh_remove_nginx_config # REMOVE LOG FILE #================================================= -sudo ynh_secure_remove --file="$logs_path" +ynh_secure_remove --file="$logs_path" #================================================= # REMOVE DEDICATED USER diff --git a/scripts/restore b/scripts/restore index 7aab3b3..a4257ce 100644 --- a/scripts/restore +++ b/scripts/restore @@ -82,13 +82,13 @@ fi #================================================= # Restore permissions on app files -sudo chown -R "$mattermost_user:www-data" "$final_path" +chown -R "$mattermost_user:www-data" "$final_path" mkdir -p "$data_path" -sudo chown -R "$mattermost_user:www-data" "$data_path" +chown -R "$mattermost_user:www-data" "$data_path" mkdir -p "$logs_path" -sudo chown -R "$mattermost_user:adm" "$logs_path" +chown -R "$mattermost_user:adm" "$logs_path" #================================================= # RESTORE SSOWAT @@ -109,13 +109,13 @@ fi #================================================= ynh_restore_file "/etc/systemd/system/$app.service" -sudo systemctl enable "$app" +systemctl enable "$app" #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -sudo yunohost service add "$app" --log "$logs_path/mattermost.log" +yunohost service add "$app" --log "$logs_path/mattermost.log" #================================================= # GENERIC FINALIZATION @@ -123,10 +123,10 @@ sudo yunohost service add "$app" --log "$logs_path/mattermost.log" # RELOAD NGINX #================================================= -sudo service nginx reload +service nginx reload #================================================= # START SERVER #================================================= -sudo systemctl start "$app" +systemctl start "$app" diff --git a/scripts/upgrade b/scripts/upgrade index a09df26..0e0b1c4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,8 +51,8 @@ fi ynh_clean_setup () { if [ "$can_restore_backup" = true ]; then # Stop attempting to restart the app - if $(sudo systemctl -q is-active "$app"); then - sudo systemctl stop "$app" + if $(systemctl -q is-active "$app"); then + systemctl stop "$app" fi # Restore the backup ynh_restore_upgradebackup @@ -60,7 +60,7 @@ ynh_clean_setup () { else # Backup restoration is not available: # let's try at least to restart the server. - sudo systemctl start "$app" + systemctl start "$app" fi } @@ -72,14 +72,14 @@ ynh_abort_if_errors #================================================= # Stop the server (if the app is already using systemd) -if $(sudo systemctl -q is-active "$app"); then - sudo systemctl stop "$app" +if $(systemctl -q is-active "$app"); then + systemctl stop "$app" fi # Legacy, for previous versions of this app which used supervisor if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then - sudo supervisorctl stop "$app" - sudo rm -f "/etc/supervisor/conf.d/${app}.conf" + supervisorctl stop "$app" + rm -f "/etc/supervisor/conf.d/${app}.conf" fi #================================================= @@ -89,7 +89,7 @@ fi config_file="$final_path/config/config.json" backup_config_file="/tmp/config.json" -sudo cp -f "$config_file" "$backup_config_file" +cp -f "$config_file" "$backup_config_file" #================================================= # MIGRATE SETTINGS FROM PREVIOUS VERSIONS @@ -120,7 +120,7 @@ ynh_setup_source "$final_path" # RESTORE CONFIGURATION FILE #================================================= -sudo cp -f "$backup_config_file" "$config_file" +cp -f "$backup_config_file" "$config_file" #================================================= # NGINX CONFIGURATION @@ -138,7 +138,7 @@ ynh_add_systemd_config # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -sudo yunohost service add "$app" --log "$logs_path/mattermost.log" +yunohost service add "$app" --log "$logs_path/mattermost.log" #================================================= # SPECIFIC UPGRADE STEPS @@ -146,32 +146,32 @@ sudo yunohost service add "$app" --log "$logs_path/mattermost.log" # Fix log FileLocation path (changed in Mattermost 3.8, makes Mattermost >= 4.2 crash) # https://docs.mattermost.com/administration/changelog.html#release-v3-8-3 -sudo sed -i "s|\"FileLocation\": \"/var/log/mattermost.log\"|\"FileLocation\": \"/var/log\"|g" "$config_file" +sed -i "s|\"FileLocation\": \"/var/log/mattermost.log\"|\"FileLocation\": \"/var/log\"|g" "$config_file" # Move log files to a directory (rather than directly in /var/log) # See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61 -sudo mkdir -p "$logs_path" -sudo sed -i "s|\"FileLocation\": \"/var/log\"|\"FileLocation\": \"$logs_path\"|g" "$config_file" +mkdir -p "$logs_path" +sed -i "s|\"FileLocation\": \"/var/log\"|\"FileLocation\": \"$logs_path\"|g" "$config_file" if [ -f "/var/log/${app}.log" ]; then - sudo mv "/var/log/${app}.log" "$logs_path/" + mv "/var/log/${app}.log" "$logs_path/" fi #================================================= # RESTORE FILE PERMISSIONS #================================================= -sudo chown -R "$mattermost_user:www-data" "$final_path" -sudo chown -R "$mattermost_user:www-data" "$data_path" -sudo chown -R "$mattermost_user:adm" "$logs_path" +chown -R "$mattermost_user:www-data" "$final_path" +chown -R "$mattermost_user:www-data" "$data_path" +chown -R "$mattermost_user:adm" "$logs_path" #================================================= # RELOAD NGINX #================================================= -sudo service nginx reload +service nginx reload #================================================= # START SERVER #================================================= -sudo systemctl start "$app" +systemctl start "$app"