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

Merge pull request #164 from YunoHost-Apps/testing

Subpath and upgrades
This commit is contained in:
Pierre de La Morinerie 2020-02-20 21:40:07 +01:00 committed by GitHub
commit ae51eac3a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 138 additions and 100 deletions

View file

@ -8,8 +8,8 @@ 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),
* A x86_64 system (check with `uname -m`) (ARM Raspberry Pi wont work, sorry),
* Yunohost 3.0 or higher (check in Yunohost Admin panel),
* MySQL 5.6 or higher, or MariaDB 10 or higher (check with `mysql --version`).
## Installing
@ -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

26
Vagrantfile vendored
View file

@ -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.
@ -28,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
@ -48,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

View file

@ -1,15 +1,16 @@
;; Mattermost
; Manifest
domain="ynhtests.local" (DOMAIN)
path="" (PATH)
path="/path" (PATH)
admin_email="john@gmail.com"
admin_password="MattermostPassword!42"
admin_password="admin!42"
admin_locale="fr"
team_display_name="Mon équipe"
is_public=1 (PUBLIC|public=1|private=0)
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

View file

@ -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;

View file

@ -18,7 +18,7 @@
"nginx"
],
"requirements": {
"yunohost": ">= 2.7.0"
"yunohost": ">= 3.0.0"
},
"arguments": {
"install" : [
@ -31,17 +31,28 @@
},
"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",
"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 ladministrateur du chat"
@ -53,13 +64,14 @@
"name": "admin_password",
"type": "password",
"ask": {
"en": "Password for the chat admin. Must contain at least 10 characters, one lowercase letter, one uppercase letter, one number, and one symbol (e.g. '~!@#$%^&*()').",
"fr": "Mot de passe pour ladministrateur du chat. Doit contenir au moins 10 caractères, une majuscule, une minuscule, un chiffre, et une ponctuation (ex. '~!@#$%^&*()')."
"en": "Password for the chat admin. At least 8 characters.",
"fr": "Mot de passe pour ladministrateur du chat. Minimum 8 caractères."
},
"optional": false
},
{
"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"
@ -69,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
},
{

View file

@ -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
@ -95,18 +96,19 @@ logs_path="/var/log/$app"
#=================================================
db_name="$app"
db_user="mmuser"
db_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')
db_user="$YNH_APP_INSTANCE_NAME"
db_password=$(ynh_string_random --length=24)
ynh_mysql_create_db "$db_name" "$db_user" "$db_password"
ynh_app_setting_set "$app" mysqlpwd "$db_password"
ynh_app_setting_set "$app" mysqluser "$db_user"
ynh_app_setting_set "$app" mysqlpwd "$db_password"
#=================================================
# CREATE USER FOR EMAIL NOTIFICATIONS
#=================================================
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"
mattermost_user_password=$(ynh_string_random --length=24)
useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user"
ynh_app_setting_set "$app" smtppwd "$mattermost_user_password"
#=================================================
@ -116,36 +118,42 @@ 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
ynh_replace_string --match_string "\"SiteURL\": \"\"" --replace_string "\"SiteURL\": \"https://${domain}${path_url}\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"ListenAddress\": \".*\"" --replace_string "\"ListenAddress\": \"127.0.0.1:${port}\"" --target_file $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
ynh_replace_string --match_string "\"DataSource\": \".*\"" --replace_string "\"DataSource\": \"${db_connection_url}\"" --target_file $final_path/config/config.json
# Configure uploaded files directory
sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json
ynh_replace_string --match_string "\"Directory\": \"./data/\"" --replace_string "\"Directory\": \"${data_path}/\"" --target_file $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
ynh_replace_string --match_string "\"SendEmailNotifications\": false" --replace_string "\"SendEmailNotifications\": true" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"FeedbackName\": \"\"" --replace_string "\"FeedbackName\": \"Mattermost notification\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"FeedbackEmail\": \"\"" --replace_string "\"FeedbackEmail\": \"no-reply@${domain}\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"SMTPUsername\": \"\"" --replace_string "\"SMTPUsername\": \"${mattermost_user}\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"SMTPPassword\": \"\"" --replace_string "\"SMTPPassword\": \"${mattermost_user_password}\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"SMTPServer\": \"\"" --replace_string "\"SMTPServer\": \"localhost\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"SMTPPort\": \".*\"" --replace_string "\"SMTPPort\": \"25\"" --target_file $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
ynh_replace_string --match_string "\"EnableConsole\": true" --replace_string "\"EnableConsole\": false" --target_file $final_path/config/config.json
# Configure log file location
sudo sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json
ynh_replace_string --match_string "\"FileLocation\": \"\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file $final_path/config/config.json
# Disable questionable password complexity rules
ynh_replace_string --match_string "\"MinimumLength\": 10" --replace_string "\"MinimumLength\": 8" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Lowercase\": true" --replace_string "\"Lowercase\": false" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Number\": true" --replace_string "\"Number\": false" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Uppercase\": true" --replace_string "\"Uppercase\": false" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Symbol\": true" --replace_string "\"Symbol\": false" --target_file $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
ynh_replace_string --match_string "\"EnableDiagnostics\": true" --replace_string "\"EnableDiagnostics\": false" --target_file $final_path/config/config.json
fi
ynh_app_setting_set "$app" analytics "$analytics"
@ -153,9 +161,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
@ -173,7 +181,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
@ -190,13 +198,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
@ -206,10 +214,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"

View file

@ -16,7 +16,8 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
db_name="$app"
db_user="mmuser"
db_user=$(ynh_app_setting_get $app mysqluser)
db_user=${db_user:-"mmuser"}
mattermost_user="$app"
final_path="/var/www/$app"
data_path="/home/yunohost.app/$app"
@ -24,28 +25,29 @@ logs_path="/var/log/$app"
#=================================================
# STANDARD REMOVE
#=================================================
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if yunohost service status | grep -q "$app"; then
yunohost service remove "$app"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
# 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"
fi
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if sudo yunohost service status | grep -q "$app"; then
sudo yunohost service remove "$app"
supervisorctl stop "$app"
ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf"
fi
#=================================================
@ -71,7 +73,7 @@ ynh_remove_nginx_config
# REMOVE LOG FILE
#=================================================
sudo ynh_secure_remove --file="$logs_path"
ynh_secure_remove --file="$logs_path"
#=================================================
# REMOVE DEDICATED USER

View file

@ -21,12 +21,13 @@ 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"
db_name="$app"
db_user="mmuser"
db_user=$(ynh_app_setting_get $app mysqluser)
db_user=${db_user:-"mmuser"}
mattermost_user="$app"
#=================================================
@ -82,13 +83,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 +110,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 +124,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"

View file

@ -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"
@ -50,16 +51,16 @@ 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
else
# Backup restoration is not available:
# let's try at least to restart the server.
sudo systemctl start "$app"
systemctl start "$app"
fi
}
@ -71,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
#=================================================
@ -88,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
@ -119,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
@ -137,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
@ -145,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"
ynh_replace_string --match_string "\"FileLocation\": \"/var/log/mattermost.log\"" --replace_string "\"FileLocation\": \"/var/log\"" --target_file "$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"
ynh_replace_string --match_string "\"FileLocation\": \"/var/log\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file "$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"

View file

@ -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