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:
commit
ae51eac3a5
10 changed files with 138 additions and 100 deletions
|
@ -8,8 +8,8 @@ A Yunohost package for [Mattermost](http://www.mattermost.org/), an open-source,
|
||||||
|
|
||||||
Mattermost requires:
|
Mattermost requires:
|
||||||
|
|
||||||
* A x86_64 system (check with `uname -m`),
|
* A x86_64 system (check with `uname -m`) (ARM Raspberry Pi won’t work, sorry),
|
||||||
* Yunohost 2.7 or higher (check in Yunohost Admin panel),
|
* Yunohost 3.0 or higher (check in Yunohost Admin panel),
|
||||||
* MySQL 5.6 or higher, or MariaDB 10 or higher (check with `mysql --version`).
|
* MySQL 5.6 or higher, or MariaDB 10 or higher (check with `mysql --version`).
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
@ -24,14 +24,13 @@ You can either :
|
||||||
|
|
||||||
## What works
|
## What works
|
||||||
|
|
||||||
* Installation on domain's root
|
* Installation on domain root or sub-directory
|
||||||
* Notification emails
|
* Notification emails
|
||||||
* Push notifications
|
* Push notifications
|
||||||
* Service control in Yunohost Services panel
|
* Service control in Yunohost Services panel
|
||||||
|
|
||||||
## TODO
|
## 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))
|
* LDAP integration (only paid Entreprise Edition, see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58))
|
||||||
|
|
||||||
## About telemetrics
|
## About telemetrics
|
||||||
|
|
26
Vagrantfile
vendored
26
Vagrantfile
vendored
|
@ -11,11 +11,23 @@ Vagrant.configure("2") do |config|
|
||||||
# https://docs.vagrantup.com.
|
# https://docs.vagrantup.com.
|
||||||
|
|
||||||
config.vm.define :ynhtests
|
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.
|
# Disable auto updates checks. Run `vagrant outdated` to perform manual updates.
|
||||||
config.vm.box_check_update = false
|
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
|
# 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,
|
# 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.
|
# 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.
|
# Use the NAT hosts DNS resolver. Fixes slow network in the guest.
|
||||||
# See https://serverfault.com/questions/495914/vagrant-slow-internet-connection-in-guest
|
# See https://serverfault.com/questions/495914/vagrant-slow-internet-connection-in-guest
|
||||||
config.vm.provider "virtualbox" do |v|
|
#config.vm.provider "virtualbox" do |v|
|
||||||
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
# v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||||
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
# v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
||||||
v.customize ["modifyvm", :id, "--nictype1", "virtio"]
|
# v.customize ["modifyvm", :id, "--nictype1", "virtio"]
|
||||||
end
|
#end
|
||||||
|
|
||||||
# Share an additional folder to the guest VM. The first argument is
|
# 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
|
# 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.
|
# documentation for more information about their specific syntax and use.
|
||||||
config.vm.provision "shell", privileged: false, keep_color: true, inline: <<-SHELL
|
config.vm.provision "shell", privileged: false, keep_color: true, inline: <<-SHELL
|
||||||
DOMAIN=ynhtests.local
|
DOMAIN=ynhtests.local
|
||||||
YUNOHOST_ADMIN_PASSWORD="alpine"
|
YUNOHOST_ADMIN_PASSWORD="ynhadminpwd"
|
||||||
|
|
||||||
# Stop on first error
|
# Stop on first error
|
||||||
set -e
|
set -e
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
;; Mattermost
|
;; Mattermost
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="ynhtests.local" (DOMAIN)
|
domain="ynhtests.local" (DOMAIN)
|
||||||
path="" (PATH)
|
path="/path" (PATH)
|
||||||
admin_email="john@gmail.com"
|
admin_email="john@gmail.com"
|
||||||
admin_password="MattermostPassword!42"
|
admin_password="admin!42"
|
||||||
admin_locale="fr"
|
admin_locale="fr"
|
||||||
team_display_name="Mon équipe"
|
team_display_name="Mon équipe"
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
analytics=0
|
analytics=0
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
|
setup_sub_dir=1
|
||||||
setup_root=1
|
setup_root=1
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
|
@ -20,14 +21,12 @@
|
||||||
# Checks not supported yet
|
# Checks not supported yet
|
||||||
change_url=0
|
change_url=0
|
||||||
# Checks not applicable
|
# Checks not applicable
|
||||||
setup_sub_dir=0
|
|
||||||
setup_nourl=0
|
setup_nourl=0
|
||||||
incorrect_path=0
|
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 1=auto
|
Level 1=auto
|
||||||
Level 2=auto
|
Level 2=auto
|
||||||
Level 3=auto
|
Level 3=auto
|
||||||
Level 4=na
|
Level 4=auto
|
||||||
Level 5=auto
|
Level 5=auto
|
||||||
Level 6=auto
|
Level 6=auto
|
||||||
Level 7=auto
|
Level 7=auto
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Directives from the Mattermost installation guide
|
# 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 Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
client_max_body_size 50M;
|
client_max_body_size 50M;
|
||||||
|
@ -15,7 +15,7 @@ location ~ /api/v[0-9]+/(users/)?websocket$ {
|
||||||
proxy_pass http://127.0.0.1:__PORT__;
|
proxy_pass http://127.0.0.1:__PORT__;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location __PATH__/ {
|
||||||
client_max_body_size 50M;
|
client_max_body_size 50M;
|
||||||
proxy_set_header Connection "";
|
proxy_set_header Connection "";
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host $http_host;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"nginx"
|
"nginx"
|
||||||
],
|
],
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.7.0"
|
"yunohost": ">= 3.0.0"
|
||||||
},
|
},
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
|
@ -31,17 +31,28 @@
|
||||||
},
|
},
|
||||||
"example": "domain.org"
|
"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",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
"help": {
|
||||||
"en": "Can guest users access this chat?",
|
"en": "Can users non registered on Yunohost access this chat?",
|
||||||
"fr": "Les utilisateurs non-enregistrés peuvent-ils accéder à ce chat ?"
|
"fr": "Les invités non-enregistrés sur Yunohost peuvent-ils accéder à ce chat ?"
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin_email",
|
"name": "admin_email",
|
||||||
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Login email for the chat admin",
|
"en": "Login email for the chat admin",
|
||||||
"fr": "Adresse email de login pour l’administrateur du chat"
|
"fr": "Adresse email de login pour l’administrateur du chat"
|
||||||
|
@ -53,13 +64,14 @@
|
||||||
"name": "admin_password",
|
"name": "admin_password",
|
||||||
"type": "password",
|
"type": "password",
|
||||||
"ask": {
|
"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. '~!@#$%^&*()').",
|
"en": "Password for the chat admin. At least 8 characters.",
|
||||||
"fr": "Mot de passe pour l’administrateur du chat. Doit contenir au moins 10 caractères, une majuscule, une minuscule, un chiffre, et une ponctuation (ex. '~!@#$%^&*()')."
|
"fr": "Mot de passe pour l’administrateur du chat. Minimum 8 caractères."
|
||||||
},
|
},
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin_locale",
|
"name": "admin_locale",
|
||||||
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose the language of the chat for the admin",
|
"en": "Choose the language of the chat for the admin",
|
||||||
"fr": "Choissisez la langue utilisée pour l'administrateur"
|
"fr": "Choissisez la langue utilisée pour l'administrateur"
|
||||||
|
@ -69,11 +81,13 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "team_display_name",
|
"name": "team_display_name",
|
||||||
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a Team name",
|
"en": "Choose a Team name",
|
||||||
"fr": "Choisissez le nom de l’équipe"
|
"fr": "Choisissez le nom de l’équipe"
|
||||||
},
|
},
|
||||||
"example": "Super Groupe",
|
"example": "Team",
|
||||||
|
"default": "Team",
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,13 +21,13 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
admin_email=$YNH_APP_ARG_ADMIN_EMAIL
|
admin_email=$YNH_APP_ARG_ADMIN_EMAIL
|
||||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||||
admin_locale=$YNH_APP_ARG_ADMIN_LOCALE
|
admin_locale=$YNH_APP_ARG_ADMIN_LOCALE
|
||||||
team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME
|
team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME
|
||||||
analytics=$YNH_APP_ARG_ANALYTICS
|
analytics=$YNH_APP_ARG_ANALYTICS
|
||||||
path_url="/"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED
|
# CHECK IF THE APP CAN BE INSTALLED
|
||||||
|
@ -71,6 +71,7 @@ ynh_webpath_available "$domain" "$path_url"
|
||||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
# Store setting
|
# Store setting
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
|
ynh_app_setting_set "$app" path "$path_url"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AN AVAILABLE PORT
|
# FIND AN AVAILABLE PORT
|
||||||
|
@ -95,9 +96,10 @@ logs_path="/var/log/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
db_name="$app"
|
db_name="$app"
|
||||||
db_user="mmuser"
|
db_user="$YNH_APP_INSTANCE_NAME"
|
||||||
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_password=$(ynh_string_random --length=24)
|
||||||
ynh_mysql_create_db "$db_name" "$db_user" "$db_password"
|
ynh_mysql_create_db "$db_name" "$db_user" "$db_password"
|
||||||
|
ynh_app_setting_set "$app" mysqluser "$db_user"
|
||||||
ynh_app_setting_set "$app" mysqlpwd "$db_password"
|
ynh_app_setting_set "$app" mysqlpwd "$db_password"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -105,8 +107,8 @@ ynh_app_setting_set "$app" mysqlpwd "$db_password"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
mattermost_user="$app"
|
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')
|
mattermost_user_password=$(ynh_string_random --length=24)
|
||||||
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"
|
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_app_setting_set "$app" final_path "$final_path"
|
||||||
ynh_setup_source "$final_path"
|
ynh_setup_source "$final_path"
|
||||||
|
|
||||||
sudo mkdir -p "$data_path"
|
mkdir -p "$data_path"
|
||||||
sudo mkdir -p "$logs_path"
|
mkdir -p "$logs_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EDIT MATTERMOST CONFIG
|
# EDIT MATTERMOST CONFIG
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Configure Service Settings
|
# Configure Service Settings
|
||||||
sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|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
|
||||||
sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $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
|
# Configure the database connection
|
||||||
db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8"
|
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
|
# 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
|
# Configure SMTP account for sending email notifications
|
||||||
sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json
|
ynh_replace_string --match_string "\"SendEmailNotifications\": false" --replace_string "\"SendEmailNotifications\": true" --target_file $final_path/config/config.json
|
||||||
sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json
|
ynh_replace_string --match_string "\"FeedbackName\": \"\"" --replace_string "\"FeedbackName\": \"Mattermost notification\"" --target_file $final_path/config/config.json
|
||||||
sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json
|
ynh_replace_string --match_string "\"FeedbackEmail\": \"\"" --replace_string "\"FeedbackEmail\": \"no-reply@${domain}\"" --target_file $final_path/config/config.json
|
||||||
sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_user}\"|g" $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPUsername\": \"\"" --replace_string "\"SMTPUsername\": \"${mattermost_user}\"" --target_file $final_path/config/config.json
|
||||||
sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${mattermost_user_password}\"|g" $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPPassword\": \"\"" --replace_string "\"SMTPPassword\": \"${mattermost_user_password}\"" --target_file $final_path/config/config.json
|
||||||
sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPServer\": \"\"" --replace_string "\"SMTPServer\": \"localhost\"" --target_file $final_path/config/config.json
|
||||||
sudo sed -i "s|\"SMTPPort\": \".*\"|\"SMTPPort\": \"25\"|g" $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
|
# 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
|
# 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
|
# Configure analytics according to user choice
|
||||||
if [ $analytics -eq 0 ]; then
|
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
|
fi
|
||||||
ynh_app_setting_set "$app" analytics "$analytics"
|
ynh_app_setting_set "$app" analytics "$analytics"
|
||||||
|
|
||||||
|
@ -153,9 +161,9 @@ ynh_app_setting_set "$app" analytics "$analytics"
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo chown -R "$mattermost_user:www-data" "$final_path"
|
chown -R "$mattermost_user:www-data" "$final_path"
|
||||||
sudo chown -R "$mattermost_user:www-data" "$data_path"
|
chown -R "$mattermost_user:www-data" "$data_path"
|
||||||
sudo chown -R "$mattermost_user:adm" "$logs_path"
|
chown -R "$mattermost_user:adm" "$logs_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -173,7 +181,7 @@ ynh_add_systemd_config
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# 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
|
# SETUP SSOWAT
|
||||||
|
@ -190,13 +198,13 @@ fi
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SERVER
|
# START SERVER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl start "$app"
|
systemctl start "$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE ADMIN AND FIRST TEAM
|
# 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)
|
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"
|
cd "$final_path/bin"
|
||||||
sudo ./mattermost user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin
|
./mattermost user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin
|
||||||
sudo ./mattermost user verify "$admin_username"
|
./mattermost user verify "$admin_username"
|
||||||
sudo ./mattermost team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email"
|
./mattermost team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email"
|
||||||
sudo ./mattermost team add "$team_name" "$admin_username"
|
./mattermost team add "$team_name" "$admin_username"
|
||||||
|
|
||||||
ynh_app_setting_set "$app" admin_email "$admin_email"
|
ynh_app_setting_set "$app" admin_email "$admin_email"
|
||||||
ynh_app_setting_set "$app" admin_locale "$admin_locale"
|
ynh_app_setting_set "$app" admin_locale "$admin_locale"
|
||||||
|
|
|
@ -16,7 +16,8 @@ source /usr/share/yunohost/helpers
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
db_name="$app"
|
db_name="$app"
|
||||||
db_user="mmuser"
|
db_user=$(ynh_app_setting_get $app mysqluser)
|
||||||
|
db_user=${db_user:-"mmuser"}
|
||||||
mattermost_user="$app"
|
mattermost_user="$app"
|
||||||
final_path="/var/www/$app"
|
final_path="/var/www/$app"
|
||||||
data_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
|
@ -24,28 +25,29 @@ logs_path="/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if yunohost service status | grep -q "$app"; then
|
||||||
|
yunohost service remove "$app"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP AND REMOVE SERVICE
|
# STOP AND REMOVE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove systemd service
|
# Remove systemd service
|
||||||
if $(sudo systemctl -q is-active "$app"); then
|
if $(systemctl -q is-active "$app"); then
|
||||||
sudo systemctl stop "$app"
|
systemctl stop "$app"
|
||||||
fi
|
fi
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
# Legacy, for older versions of this app which used supervisor
|
# Legacy, for older versions of this app which used supervisor
|
||||||
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
|
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
|
||||||
sudo supervisorctl stop "$app"
|
supervisorctl stop "$app"
|
||||||
sudo ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf"
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -71,7 +73,7 @@ ynh_remove_nginx_config
|
||||||
# REMOVE LOG FILE
|
# REMOVE LOG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo ynh_secure_remove --file="$logs_path"
|
ynh_secure_remove --file="$logs_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
|
|
|
@ -21,12 +21,13 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
path_url="/"
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
final_path="/var/www/$app"
|
final_path="/var/www/$app"
|
||||||
data_path="/home/yunohost.app/$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
logs_path="/var/log/$app"
|
logs_path="/var/log/$app"
|
||||||
db_name="$app"
|
db_name="$app"
|
||||||
db_user="mmuser"
|
db_user=$(ynh_app_setting_get $app mysqluser)
|
||||||
|
db_user=${db_user:-"mmuser"}
|
||||||
mattermost_user="$app"
|
mattermost_user="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -82,13 +83,13 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Restore permissions on app files
|
# 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"
|
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"
|
mkdir -p "$logs_path"
|
||||||
sudo chown -R "$mattermost_user:adm" "$logs_path"
|
chown -R "$mattermost_user:adm" "$logs_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SSOWAT
|
# RESTORE SSOWAT
|
||||||
|
@ -109,13 +110,13 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
sudo systemctl enable "$app"
|
systemctl enable "$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# 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
|
# GENERIC FINALIZATION
|
||||||
|
@ -123,10 +124,10 @@ sudo yunohost service add "$app" --log "$logs_path/mattermost.log"
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo service nginx reload
|
service nginx reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SERVER
|
# START SERVER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl start "$app"
|
systemctl start "$app"
|
||||||
|
|
|
@ -21,6 +21,7 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
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)
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
port=$(ynh_app_setting_get $app port)
|
port=$(ynh_app_setting_get $app port)
|
||||||
mattermost_user="$app"
|
mattermost_user="$app"
|
||||||
|
@ -50,8 +51,8 @@ fi
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
if [ "$can_restore_backup" = true ]; then
|
if [ "$can_restore_backup" = true ]; then
|
||||||
# Stop attempting to restart the app
|
# Stop attempting to restart the app
|
||||||
if $(sudo systemctl -q is-active "$app"); then
|
if $(systemctl -q is-active "$app"); then
|
||||||
sudo systemctl stop "$app"
|
systemctl stop "$app"
|
||||||
fi
|
fi
|
||||||
# Restore the backup
|
# Restore the backup
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
|
@ -59,7 +60,7 @@ ynh_clean_setup () {
|
||||||
else
|
else
|
||||||
# Backup restoration is not available:
|
# Backup restoration is not available:
|
||||||
# let's try at least to restart the server.
|
# let's try at least to restart the server.
|
||||||
sudo systemctl start "$app"
|
systemctl start "$app"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,14 +72,14 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Stop the server (if the app is already using systemd)
|
# Stop the server (if the app is already using systemd)
|
||||||
if $(sudo systemctl -q is-active "$app"); then
|
if $(systemctl -q is-active "$app"); then
|
||||||
sudo systemctl stop "$app"
|
systemctl stop "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Legacy, for previous versions of this app which used supervisor
|
# Legacy, for previous versions of this app which used supervisor
|
||||||
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
|
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
|
||||||
sudo supervisorctl stop "$app"
|
supervisorctl stop "$app"
|
||||||
sudo rm -f "/etc/supervisor/conf.d/${app}.conf"
|
rm -f "/etc/supervisor/conf.d/${app}.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -88,7 +89,7 @@ fi
|
||||||
config_file="$final_path/config/config.json"
|
config_file="$final_path/config/config.json"
|
||||||
backup_config_file="/tmp/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
|
# MIGRATE SETTINGS FROM PREVIOUS VERSIONS
|
||||||
|
@ -119,7 +120,7 @@ ynh_setup_source "$final_path"
|
||||||
# RESTORE CONFIGURATION FILE
|
# RESTORE CONFIGURATION FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo cp -f "$backup_config_file" "$config_file"
|
cp -f "$backup_config_file" "$config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -137,7 +138,7 @@ ynh_add_systemd_config
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# 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
|
# 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)
|
# 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
|
# 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)
|
# Move log files to a directory (rather than directly in /var/log)
|
||||||
# See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61
|
# See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61
|
||||||
sudo mkdir -p "$logs_path"
|
mkdir -p "$logs_path"
|
||||||
sudo sed -i "s|\"FileLocation\": \"/var/log\"|\"FileLocation\": \"$logs_path\"|g" "$config_file"
|
ynh_replace_string --match_string "\"FileLocation\": \"/var/log\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file "$config_file"
|
||||||
if [ -f "/var/log/${app}.log" ]; then
|
if [ -f "/var/log/${app}.log" ]; then
|
||||||
sudo mv "/var/log/${app}.log" "$logs_path/"
|
mv "/var/log/${app}.log" "$logs_path/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FILE PERMISSIONS
|
# RESTORE FILE PERMISSIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo chown -R "$mattermost_user:www-data" "$final_path"
|
chown -R "$mattermost_user:www-data" "$final_path"
|
||||||
sudo chown -R "$mattermost_user:www-data" "$data_path"
|
chown -R "$mattermost_user:www-data" "$data_path"
|
||||||
sudo chown -R "$mattermost_user:adm" "$logs_path"
|
chown -R "$mattermost_user:adm" "$logs_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo service nginx reload
|
service nginx reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SERVER
|
# START SERVER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl start "$app"
|
systemctl start "$app"
|
||||||
|
|
2
test.sh
2
test.sh
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run package_check tests against the app in the working directory on a Vagrant virtual machine.
|
# 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
|
# Fail on first error
|
||||||
set -e
|
set -e
|
||||||
|
|
Loading…
Reference in a new issue