2016-04-29 16:32:48 +02:00
|
|
|
#!/bin/bash
|
2017-07-18 13:16:23 +02:00
|
|
|
set -eu
|
2016-04-29 16:32:48 +02:00
|
|
|
|
2017-07-18 13:03:45 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2017-07-18 14:42:10 +02:00
|
|
|
language=$YNH_APP_ARG_LANG
|
2017-07-18 13:03:45 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2017-07-18 11:48:53 +02:00
|
|
|
ROCKETCHAT_VERSION=0.57.2
|
|
|
|
NODE_VERSION=4.7.1
|
2016-04-29 16:32:48 +02:00
|
|
|
|
|
|
|
# Check domain/path availability
|
2016-04-29 21:24:00 +02:00
|
|
|
sudo yunohost app checkurl $domain -a rocketchat
|
2016-04-29 16:32:48 +02:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2017-07-18 13:16:23 +02:00
|
|
|
ynh_die
|
2016-04-29 16:32:48 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Save specific settings
|
2017-07-18 13:16:23 +02:00
|
|
|
ynh_app_setting_set $app is_public $is_public
|
2016-04-29 16:32:48 +02:00
|
|
|
|
|
|
|
#Install dependencies
|
|
|
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
|
|
|
|
echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
|
|
|
|
sudo apt-get update
|
2017-07-18 14:47:01 +02:00
|
|
|
sudo apt-get install -y mongodb-org gzip curl graphicsmagick npm
|
2016-04-29 16:32:48 +02:00
|
|
|
|
|
|
|
# Meteor needs at least this version of node to work.
|
2017-07-18 14:47:01 +02:00
|
|
|
sudo npm install -g n
|
2017-07-18 11:48:53 +02:00
|
|
|
sudo n $NODE_VERSION
|
2016-04-29 16:32:48 +02:00
|
|
|
|
2017-07-18 14:51:10 +02:00
|
|
|
# Create destination
|
|
|
|
final_path=/var/www/rocketchat
|
|
|
|
ynh_app_setting_set $app final_path $final_path
|
|
|
|
sudo mkdir -p $final_path
|
|
|
|
|
2016-04-29 16:32:48 +02:00
|
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
|
2016-04-29 21:02:20 +02:00
|
|
|
sed -i "s@CHANGEMETOROOTURL@$domain/@g" ../conf/Rocketchat.service
|
2016-04-29 18:16:29 +02:00
|
|
|
|
2016-04-29 21:02:20 +02:00
|
|
|
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/rocketchat.conf
|
2017-07-18 15:32:34 +02:00
|
|
|
sudo cp ../conf/Rocketchat.service /etc/systemd/system/
|
2016-04-29 16:32:48 +02:00
|
|
|
|
2016-04-29 18:08:30 +02:00
|
|
|
pkgdir=$(pwd)
|
2016-04-29 16:32:48 +02:00
|
|
|
|
2017-07-18 11:48:53 +02:00
|
|
|
# download and extract rocketchat
|
2017-07-18 15:46:39 +02:00
|
|
|
sudo curl -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "https://rocket.chat/releases/${ROCKETCHAT_VERSION}/download"
|
2017-07-18 15:44:12 +02:00
|
|
|
sudo tar -xzf $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar -C $final_path
|
2017-07-18 15:46:39 +02:00
|
|
|
sudo ls -lah $final_path
|
2017-07-18 15:44:12 +02:00
|
|
|
sudo mv $final_path/bundle/** $final_path
|
2016-04-29 16:32:48 +02:00
|
|
|
|
|
|
|
cd $final_path/programs/server/
|
|
|
|
|
|
|
|
sudo npm install
|
|
|
|
|
|
|
|
cd $final_path/
|
|
|
|
|
|
|
|
sudo chown -R www-data: $final_path
|
|
|
|
|
|
|
|
sudo service nginx reload
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
2017-07-18 13:16:23 +02:00
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2016-04-29 16:32:48 +02:00
|
|
|
fi
|
|
|
|
sudo systemctl start Rocketchat.service
|
|
|
|
sudo systemctl enable Rocketchat.service
|
|
|
|
|
2016-04-29 21:50:20 +02:00
|
|
|
sleep 25s
|
|
|
|
|
2016-04-29 18:08:30 +02:00
|
|
|
cd $pkgdir
|
|
|
|
|
|
|
|
sudo mongo < ../conf/rocketchat_ldap.js
|
|
|
|
|
2016-04-29 16:32:48 +02:00
|
|
|
sudo yunohost app ssowatconf
|