mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
57 lines
1.4 KiB
Text
57 lines
1.4 KiB
Text
|
#!/bin/bash
|
||
|
set -e # Exit on error
|
||
|
|
||
|
# Retrieve arguments
|
||
|
domain=$1
|
||
|
is_public=$2
|
||
|
path=""
|
||
|
|
||
|
# Check domain availability
|
||
|
sudo yunohost app checkurl $domain$path -a mattermost
|
||
|
if [[ ! $? -eq 0 ]]; then
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# TODO: check 64 bits support
|
||
|
|
||
|
# TODO: check for MySQL 5.6
|
||
|
|
||
|
# Install dependencies
|
||
|
sudo apt-get install -y supervisor
|
||
|
|
||
|
# Initialize database and store mysql password for upgrade
|
||
|
db_user="mmuser"
|
||
|
db_password="mmuser_password" # TODO: stronger password
|
||
|
sudo yunohost app initdb $db_user -p $db_password -d mattermost
|
||
|
|
||
|
# 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
|
||
|
|
||
|
# 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
|
||
|
|
||
|
# Set permissions to app directory
|
||
|
sudo chown -R www-data: $final_path
|
||
|
|
||
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||
|
sudo cp $root_path/conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/mattermost.conf
|
||
|
|
||
|
# Copy supervisor script
|
||
|
sudo cp $root_path/conf/supervisor.conf /etc/supervisor/conf.d/mattermost.conf
|
||
|
|
||
|
# Reload Nginx and regenerate SSOwat conf
|
||
|
sudo service nginx reload
|
||
|
sudo yunohost app ssowatconf
|
||
|
|
||
|
# Start app
|
||
|
sudo supervisorctl start mattermost
|