mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
93 lines
2.5 KiB
Bash
93 lines
2.5 KiB
Bash
#!/bin/bash
|
|
set -eu
|
|
|
|
#=================================================
|
|
# 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
|
|
language=$YNH_APP_ARG_LANG
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
ROCKETCHAT_VERSION=0.57.2
|
|
NODE_VERSION=4.7.1
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain -a rocketchat
|
|
if [[ ! $? -eq 0 ]]; then
|
|
ynh_die
|
|
fi
|
|
|
|
# Save specific settings
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
#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
|
|
sudo apt-get install -y mongodb-org gzip curl graphicsmagick npm
|
|
|
|
# Meteor needs at least this version of node to work.
|
|
sudo npm install -g n
|
|
sudo n $NODE_VERSION
|
|
|
|
# Create destination
|
|
final_path=/var/www/rocketchat
|
|
ynh_app_setting_set $app final_path $final_path
|
|
sudo mkdir -p $final_path
|
|
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
|
|
sed -i "s@CHANGEMETOROOTURL@$domain/@g" ../conf/Rocketchat.service
|
|
|
|
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/rocketchat.conf
|
|
|
|
pkgdir=$(pwd)
|
|
|
|
# download and extract rocketchat
|
|
sudo curl -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "https://rocket.chat/releases/$ROCKETCHAT_VERSION/download"
|
|
cd $final_path && sudo gunzip -c $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar | sudo tar xvf -
|
|
cd $final_path && sudo rm -r PaxHeader && mv bundle/** .
|
|
|
|
sudo cp ../conf/Rocketchat.service /etc/systemd/system/
|
|
|
|
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
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
|
fi
|
|
sudo systemctl start Rocketchat.service
|
|
sudo systemctl enable Rocketchat.service
|
|
|
|
sleep 25s
|
|
|
|
cd $pkgdir
|
|
|
|
sudo mongo < ../conf/rocketchat_ldap.js
|
|
|
|
sudo yunohost app ssowatconf
|