mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
Better install; email notifications
This commit is contained in:
parent
c3b7b565fc
commit
e11d51b3b7
6 changed files with 51 additions and 102 deletions
|
@ -19,8 +19,10 @@ You can either :
|
|||
## What works
|
||||
|
||||
* Installation on domain's root
|
||||
* Notification emails
|
||||
|
||||
## TODO
|
||||
|
||||
* Allow installation in sub-directory (only root-domains work for now)
|
||||
* LDAP integration
|
||||
* Configuring lov level on install
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
{
|
||||
"ServiceSettings": {
|
||||
"ListenAddress": ":8065",
|
||||
"MaximumLoginAttempts": 10,
|
||||
"SegmentDeveloperKey": "",
|
||||
"GoogleDeveloperKey": "",
|
||||
"EnableOAuthServiceProvider": false,
|
||||
"EnableIncomingWebhooks": true,
|
||||
"EnablePostUsernameOverride": false,
|
||||
"EnablePostIconOverride": false,
|
||||
"EnableTesting": false,
|
||||
"EnableSecurityFixAlert": true
|
||||
},
|
||||
"TeamSettings": {
|
||||
"SiteName": "Mattermost",
|
||||
"MaxUsersPerTeam": 50,
|
||||
"EnableTeamCreation": true,
|
||||
"EnableUserCreation": true,
|
||||
"RestrictCreationToDomains": ""
|
||||
},
|
||||
"SqlSettings": {
|
||||
"DriverName": "mysql",
|
||||
"DataSource": "mmuser:mmuser_password@tcp(127.0.0.1:3306)/mattermost?charset=utf8mb4,utf8",
|
||||
"DataSourceReplicas": [],
|
||||
"MaxIdleConns": 10,
|
||||
"MaxOpenConns": 10,
|
||||
"Trace": false,
|
||||
"AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QVg"
|
||||
},
|
||||
"LogSettings": {
|
||||
"EnableConsole": true,
|
||||
"ConsoleLevel": "DEBUG",
|
||||
"EnableFile": true,
|
||||
"FileLevel": "INFO",
|
||||
"FileFormat": "",
|
||||
"FileLocation": ""
|
||||
},
|
||||
"FileSettings": {
|
||||
"DriverName": "local",
|
||||
"Directory": "./data/",
|
||||
"EnablePublicLink": true,
|
||||
"PublicLinkSalt": "A705AklYF8MFDOfcwh3I488G8vtLlVip",
|
||||
"ThumbnailWidth": 120,
|
||||
"ThumbnailHeight": 100,
|
||||
"PreviewWidth": 1024,
|
||||
"PreviewHeight": 0,
|
||||
"ProfileWidth": 128,
|
||||
"ProfileHeight": 128,
|
||||
"InitialFont": "luximbi.ttf",
|
||||
"AmazonS3AccessKeyId": "",
|
||||
"AmazonS3SecretAccessKey": "",
|
||||
"AmazonS3Bucket": "",
|
||||
"AmazonS3Region": ""
|
||||
},
|
||||
"EmailSettings": {
|
||||
"EnableSignUpWithEmail": true,
|
||||
"SendEmailNotifications": false,
|
||||
"RequireEmailVerification": false,
|
||||
"FeedbackName": "",
|
||||
"FeedbackEmail": "",
|
||||
"SMTPUsername": "",
|
||||
"SMTPPassword": "",
|
||||
"SMTPServer": "",
|
||||
"SMTPPort": "",
|
||||
"ConnectionSecurity": "",
|
||||
"InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS",
|
||||
"PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL",
|
||||
"ApplePushServer": "",
|
||||
"ApplePushCertPublic": "",
|
||||
"ApplePushCertPrivate": ""
|
||||
},
|
||||
"RateLimitSettings": {
|
||||
"EnableRateLimiter": true,
|
||||
"PerSec": 10,
|
||||
"MemoryStoreSize": 10000,
|
||||
"VaryByRemoteAddr": true,
|
||||
"VaryByHeader": ""
|
||||
},
|
||||
"PrivacySettings": {
|
||||
"ShowEmailAddress": true,
|
||||
"ShowFullName": true
|
||||
},
|
||||
"GitLabSettings": {
|
||||
"Enable": false,
|
||||
"Secret": "",
|
||||
"Id": "",
|
||||
"Scope": "",
|
||||
"AuthEndpoint": "",
|
||||
"TokenEndpoint": "",
|
||||
"UserApiEndpoint": ""
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
location / {
|
||||
client_max_body_size 50M;
|
||||
|
||||
proxy_pass http://localhost:8065/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_buffering off;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
directory=/var/www/mattermost
|
||||
command=/var/www/mattermost/bin/platform
|
||||
user=www
|
||||
startsecs=5
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/log/mattermost.log
|
||||
|
|
|
@ -20,24 +20,46 @@ fi
|
|||
sudo apt-get install -y supervisor
|
||||
|
||||
# Initialize database and store mysql password for upgrade
|
||||
db_name="mattermost"
|
||||
db_user="mmuser"
|
||||
db_password="mmuser_password" # TODO: stronger password
|
||||
sudo yunohost app initdb $db_user -p $db_password -d mattermost
|
||||
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')
|
||||
sudo yunohost app initdb $db_user -p $db_password -d $db_name
|
||||
sudo yunohost app setting mattermost mysqlpwd -v $db_password
|
||||
|
||||
# Save specific settings
|
||||
sudo yunohost app setting mattermost is_public -v $is_public
|
||||
sudo yunohost app setting mattermost mysqlpwd -v $db_password
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
sudo yunohost app setting mattermost unprotected_uris -v "/"
|
||||
fi
|
||||
# Delete db and user if exit with an error
|
||||
function exit_properly
|
||||
{
|
||||
set +e
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
mysql -u root -p$root_pwd -e "DROP DATABASE mattermost ; DROP USER mmuser@localhost ;"
|
||||
|
||||
sudo userdel mattermost
|
||||
sudo rm -Rf /var/www/mattermost
|
||||
exit 1
|
||||
}
|
||||
trap exit_properly ERR
|
||||
|
||||
# Create user for email notifications
|
||||
smtp_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 "$smtp_password") "mattermost"
|
||||
sudo yunohost app setting mattermost smtppwd -v $smtp_password
|
||||
|
||||
# Install sources
|
||||
root_path=$(pwd)/..
|
||||
final_path=/var/www/mattermost
|
||||
sudo mkdir -p $final_path
|
||||
sudo cp -af $root_path/sources/. $final_path
|
||||
sudo cp $root_path/conf/config.json $final_path/config/config.json
|
||||
|
||||
# Change variables in Mattermost config
|
||||
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
|
||||
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\"|g" $final_path/config/config.json
|
||||
sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${smtp_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
|
||||
|
||||
# Set permissions to app directory
|
||||
sudo chown -R www-data: $final_path
|
||||
|
@ -48,6 +70,13 @@ sudo cp $root_path/conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/mattermost.
|
|||
# Copy supervisor script
|
||||
sudo cp $root_path/conf/supervisor.conf /etc/supervisor/conf.d/mattermost.conf
|
||||
|
||||
# Enable public access if needed
|
||||
sudo yunohost app setting mattermost is_public -v $is_public
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
sudo yunohost app setting mattermost unprotected_uris -v "/"
|
||||
fi
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
|
@ -15,6 +15,13 @@ sudo rm -rf /var/www/mattermost
|
|||
# Remove database
|
||||
mysql -u root -p$db_root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
||||
|
||||
# Delete SMTP user
|
||||
sudo userdel mattermost
|
||||
|
||||
# Remove configuration files
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/mattermost.conf
|
||||
sudo rm /etc/supervisor/conf.d/mattermost.conf
|
||||
|
||||
# Remove log files
|
||||
sudo rm -f /var/log/mattermost.log
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue