mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
Improves installation and removal
This commit is contained in:
parent
aacc621598
commit
eece458af2
5 changed files with 38 additions and 26 deletions
|
@ -1,5 +1,6 @@
|
||||||
location /PATHTOCHANGE {
|
location ^~ #LOCATION# {
|
||||||
rewrite ^PATHTOCHANGE$ PATHTOCHANGE/ permanent;
|
alias #DESTDIR#/;
|
||||||
|
rewrite ^#PATH#$ #PATH#/ permanent;
|
||||||
proxy_pass http://localhost:3000/;
|
proxy_pass http://localhost:3000/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
location / {
|
|
||||||
proxy_pass http://localhost:3000/;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
# be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
|
|
||||||
proxy_buffering off;
|
|
||||||
}
|
|
|
@ -6,7 +6,8 @@
|
||||||
"en": "the ultimate chat platform"
|
"en": "the ultimate chat platform"
|
||||||
},
|
},
|
||||||
"url": "https://github.com/selamanse/rocketchat_ynh",
|
"url": "https://github.com/selamanse/rocketchat_ynh",
|
||||||
"license": "free",
|
"license": "MIT",
|
||||||
|
"version": "0.57.2-rc.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "selamanse",
|
"name": "selamanse",
|
||||||
"email": "selamanse@scheinfrei.info",
|
"email": "selamanse@scheinfrei.info",
|
||||||
|
@ -35,8 +36,8 @@
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a path for RocketChat"
|
"en": "Choose a path for RocketChat"
|
||||||
},
|
},
|
||||||
"example": "/chat",
|
"example": "/rocketchat",
|
||||||
"default": "/chat"
|
"default": "/rocketchat"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
|
|
|
@ -21,7 +21,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANG
|
language=$YNH_APP_ARG_LANG
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
ROCKETCHAT_VERSION=0.57.2
|
ROCKETCHAT_VERSION=0.57.2
|
||||||
NODE_VERSION=4.7.1
|
NODE_VERSION=4.7.1
|
||||||
|
|
||||||
|
workdir=$(pwd)
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain -a rocketchat
|
sudo yunohost app checkurl $domain -a rocketchat
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
@ -50,17 +52,26 @@ sudo npm install -g n
|
||||||
sudo n $NODE_VERSION
|
sudo n $NODE_VERSION
|
||||||
|
|
||||||
# Create destination
|
# Create destination
|
||||||
final_path=/var/www/rocketchat
|
final_path="/var/www/$app"
|
||||||
|
[[ -d $final_path ]] && ynh_die \
|
||||||
|
"The destination directory '$DESTDIR' already exists.\
|
||||||
|
You should safely delete it before installing this app."
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
|
|
||||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
|
# Copy and set systemd configuration
|
||||||
sed -i "s@CHANGEMETOROOTURL@$domain/@g" ../conf/Rocketchat.service
|
sed -i "s@CHANGEMETOROOTURL@$domain/@g" ../conf/Rocketchat.service
|
||||||
|
|
||||||
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/rocketchat.conf
|
|
||||||
sudo cp ../conf/Rocketchat.service /etc/systemd/system/
|
sudo cp ../conf/Rocketchat.service /etc/systemd/system/
|
||||||
|
|
||||||
pkgdir=$(pwd)
|
# Copy and set nginx configuration
|
||||||
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
|
||||||
|
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
|
||||||
|
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
|
||||||
|
sed -i "s@#DESTDIR#@${final_path}@g" ../conf/nginx.conf
|
||||||
|
|
||||||
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||||
|
|
||||||
# download and extract rocketchat
|
# download and extract rocketchat
|
||||||
sudo curl -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "https://rocket.chat/releases/${ROCKETCHAT_VERSION}/download"
|
sudo curl -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "https://rocket.chat/releases/${ROCKETCHAT_VERSION}/download"
|
||||||
|
@ -86,9 +97,13 @@ fi
|
||||||
sudo systemctl start Rocketchat.service
|
sudo systemctl start Rocketchat.service
|
||||||
sudo systemctl enable Rocketchat.service
|
sudo systemctl enable Rocketchat.service
|
||||||
|
|
||||||
sleep 25s
|
# wait for rocketchat to populate db and start (oneliner has to be improved)
|
||||||
|
isup=false; x=5; while [ $x -gt 0 ];do echo "Waiting approx. $x seconds..."; \
|
||||||
|
x=$(( $x - 1 )); sleep 1; if $(curl -m 1 -s localhost:3000/api/v1/info | \
|
||||||
|
grep -e "success.*true" >/dev/null 2>%1); then isup=true; break; fi; done && if $isup; \
|
||||||
|
then echo "service is up"; else echo "service not reachable"; ynh_die; fi
|
||||||
|
|
||||||
cd $pkgdir
|
cd $workdir
|
||||||
|
|
||||||
sudo mongo < ../conf/rocketchat_ldap.js
|
sudo mongo < ../conf/rocketchat_ldap.js
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,11 @@ source /usr/share/yunohost/helpers
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
sudo rm -rf /var/www/rocketchat
|
|
||||||
|
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/rocketchat.conf
|
|
||||||
sudo rm -Rf /var/log/rocketchat/
|
|
||||||
sudo systemctl stop Rocketchat.service
|
sudo systemctl stop Rocketchat.service
|
||||||
|
|
||||||
|
sudo rm -rf /var/www/rocketchat
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/rocketchat.conf
|
||||||
|
sudo rm -rf /var/log/rocketchat/
|
||||||
sudo rm -f /etc/systemd/system/Rocketchat.service
|
sudo rm -f /etc/systemd/system/Rocketchat.service
|
||||||
|
|
||||||
sudo systemctl restart nginx
|
sudo systemctl restart nginx
|
||||||
|
|
Loading…
Add table
Reference in a new issue