mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
Use the new Mattermost download URL
This commit is contained in:
parent
60a0e984f5
commit
ed8d078d8e
3 changed files with 39 additions and 30 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
v2.1.0
|
2.1.0
|
||||||
|
|
|
@ -6,6 +6,13 @@ domain=$1
|
||||||
is_public=$2
|
is_public=$2
|
||||||
path=""
|
path=""
|
||||||
|
|
||||||
|
# Set up common variables
|
||||||
|
root_path="$(pwd)/.."
|
||||||
|
final_path=/var/www/mattermost
|
||||||
|
data_path=/home/yunohost.app/mattermost
|
||||||
|
version=$(cat "$root_path/VERSION")
|
||||||
|
archive_filename="mattermost-$version.tar.gz"
|
||||||
|
|
||||||
# Check for 64 bits support
|
# Check for 64 bits support
|
||||||
arch="$(uname -m)"
|
arch="$(uname -m)"
|
||||||
if [[ "$arch" != "x86_64" ]]; then
|
if [[ "$arch" != "x86_64" ]]; then
|
||||||
|
@ -52,8 +59,8 @@ function exit_properly
|
||||||
mysql -u root -p$root_pwd -e "DROP DATABASE mattermost ; DROP USER mmuser@localhost ;"
|
mysql -u root -p$root_pwd -e "DROP DATABASE mattermost ; DROP USER mmuser@localhost ;"
|
||||||
|
|
||||||
sudo userdel mattermost
|
sudo userdel mattermost
|
||||||
sudo rm -Rf /var/www/mattermost
|
sudo rm -Rf "$final_path"
|
||||||
rm "mattermost.tar.gz"
|
rm "$archive_filename"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
trap exit_properly ERR
|
trap exit_properly ERR
|
||||||
|
@ -61,25 +68,23 @@ trap exit_properly ERR
|
||||||
# Create user for email notifications
|
# 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')
|
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 useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "mattermost"
|
||||||
sudo yunohost app setting mattermost smtppwd -v $smtp_password
|
sudo yunohost app setting mattermost smtppwd -v "$smtp_password"
|
||||||
|
/
|
||||||
# Download and install code
|
# Download and install code
|
||||||
root_path=$(pwd)/..
|
archive_url="https://releases.mattermost.com/${version}/mattermost-team-${version}-linux-amd64.tar.gz"
|
||||||
final_path=/var/www/mattermost
|
|
||||||
data_path=/home/yunohost.app/mattermost
|
|
||||||
sudo mkdir -p $final_path
|
|
||||||
sudo mkdir -p $data_path
|
|
||||||
|
|
||||||
version=$(cat $root_path/VERSION)
|
sudo mkdir -p "$final_path"
|
||||||
wget -q "https://github.com/mattermost/platform/releases/download/${version}/mattermost.tar.gz"
|
sudo mkdir -p "$data_path"
|
||||||
sudo tar -xvz --file "mattermost.tar.gz" --directory $final_path --strip-components 1
|
|
||||||
rm -f "mattermost.tar.gz"
|
wget --quiet --output-document "$archive_filename" "$archive_url"
|
||||||
|
sudo tar -xvz --file "$archive_filename" --directory "$final_path" --strip-components 1
|
||||||
|
rm -f "$archive_filename"
|
||||||
|
|
||||||
# Change variables in Mattermost config
|
# Change variables in Mattermost config
|
||||||
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
|
sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json
|
||||||
|
|
||||||
sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json
|
sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json
|
||||||
|
|
||||||
sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|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|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json
|
||||||
|
|
|
@ -5,11 +5,17 @@ set -e # Exit on error
|
||||||
domain=$(sudo yunohost app setting mattermost domain)
|
domain=$(sudo yunohost app setting mattermost domain)
|
||||||
is_public=$(sudo yunohost app setting mattermost is_public)
|
is_public=$(sudo yunohost app setting mattermost is_public)
|
||||||
|
|
||||||
|
# Set up common variables
|
||||||
|
root_path="$(pwd)/.."
|
||||||
|
final_path=/var/www/mattermost
|
||||||
|
version=$(cat "$root_path/VERSION")
|
||||||
|
archive_filename="mattermost-$version.tar.gz"
|
||||||
|
|
||||||
# Cleanup and restart if exit with an error
|
# Cleanup and restart if exit with an error
|
||||||
function cleanup_and_restart
|
function cleanup_and_restart
|
||||||
{
|
{
|
||||||
set +e
|
set +e
|
||||||
rm "mattermost.tar.gz"
|
rm "$archive_filename"
|
||||||
sudo supervisorctl start mattermost
|
sudo supervisorctl start mattermost
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -19,28 +25,26 @@ trap cleanup_and_restart ERR
|
||||||
sudo supervisorctl stop mattermost
|
sudo supervisorctl stop mattermost
|
||||||
|
|
||||||
# Download code
|
# Download code
|
||||||
root_path=$(pwd)/..
|
archive_url="https://releases.mattermost.com/${version}/mattermost-team-${version}-linux-amd64.tar.gz"
|
||||||
final_path=/var/www/mattermost
|
wget --quiet --output-document "$archive_filename" "$archive_url"
|
||||||
config_file=$final_path/config/config.json
|
|
||||||
backup_config_file=/tmp/config.json
|
|
||||||
|
|
||||||
version=$(cat $root_path/VERSION)
|
|
||||||
wget -q "https://github.com/mattermost/platform/releases/download/${version}/mattermost.tar.gz"
|
|
||||||
|
|
||||||
# Backup configuration file
|
# Backup configuration file
|
||||||
sudo cp -f $config_file $backup_config_file
|
config_file="$final_path/config/config.json"
|
||||||
|
backup_config_file="/tmp/config.json"
|
||||||
|
|
||||||
|
sudo cp -f "$config_file" "$backup_config_file"
|
||||||
|
|
||||||
# Copy new code
|
# Copy new code
|
||||||
sudo rm -rf $final_path
|
sudo rm -rf "$final_path"
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p "$final_path"
|
||||||
sudo tar -xvz --file "mattermost.tar.gz" --directory $final_path --strip-components 1
|
sudo tar -xvz --file "$archive_filename" --directory "$final_path" --strip-components 1
|
||||||
rm -f "mattermost.tar.gz"
|
rm -f "$archive_filename"
|
||||||
|
|
||||||
# Restore configuration file
|
# Restore configuration file
|
||||||
sudo cp -f $backup_config_file $config_file
|
sudo cp -f "$backup_config_file" "$config_file"
|
||||||
|
|
||||||
# Restore file permissions
|
# Restore file permissions
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
sudo supervisorctl start mattermost
|
sudo supervisorctl start mattermost
|
||||||
|
|
Loading…
Add table
Reference in a new issue