mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
Improvements overall
This commit is contained in:
parent
19c910fb36
commit
14668f1d07
7 changed files with 47 additions and 38 deletions
|
@ -1,7 +1,7 @@
|
||||||
# rocketchat_ynh
|
# rocketchat_ynh
|
||||||
[![Build Status](https://travis-ci.org/selamanse/rocketchat_ynh.svg?branch=master)](https://travis-ci.org/selamanse/rocketchat_ynh)
|
[![Build Status](https://travis-ci.org/selamanse/rocketchat_ynh.svg?branch=master)](https://travis-ci.org/selamanse/rocketchat_ynh)
|
||||||
|
|
||||||
rocket.chat for yunohost
|
Rocketchat for yunohost
|
||||||
|
|
||||||
## Install with
|
## Install with
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Rocket.Chat
|
Description=rocketchat
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/var/www/rocketchat
|
WorkingDirectory=/var/www/rocketchat
|
||||||
User=www-data
|
User=#USER#
|
||||||
Group=www-data
|
|
||||||
ExecStart=/usr/local/bin/node main.js
|
ExecStart=/usr/local/bin/node main.js
|
||||||
Restart=always
|
Restart=always
|
||||||
SyslogIdentifier=Rocket.Chat
|
SyslogIdentifier=Rocket.Chat
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
},
|
},
|
||||||
"url": "https://github.com/selamanse/rocketchat_ynh",
|
"url": "https://github.com/selamanse/rocketchat_ynh",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.57.2-rc.0",
|
"version": "0.57.2-rc.1",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "selamanse",
|
"name": "selamanse",
|
||||||
"email": "selamanse@scheinfrei.info",
|
"email": "selamanse@scheinfrei.info",
|
||||||
|
|
|
@ -45,4 +45,4 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf
|
||||||
# BACKUP THE MONGODB DATABASE
|
# BACKUP THE MONGODB DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo mongodump -o "$final_path/dump"
|
sudo mongodump -o "${backup_dir}/dump"
|
||||||
|
|
|
@ -26,19 +26,23 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANG
|
language=$YNH_APP_ARG_LANG
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
user=$app
|
||||||
|
|
||||||
ROCKETCHAT_VERSION=0.57.2
|
ROCKETCHAT_VERSION=0.57.2
|
||||||
NODE_VERSION=4.7.1
|
NODE_VERSION=4.7.1
|
||||||
|
|
||||||
workdir=$(pwd)
|
workdir=$(pwd)
|
||||||
|
|
||||||
|
# find suitable port (default 3000)
|
||||||
|
port=$(ynh_find_port 3000)
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl $domain -a $app
|
sudo yunohost app checkurl $domain -a $app
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
ynh_die "domain not available"
|
ynh_die "domain not available"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
final_path="/var/www/$app"
|
final_path="/var/lib/$app"
|
||||||
[[ -d $final_path ]] && ynh_die \
|
[[ -d $final_path ]] && ynh_die \
|
||||||
"The destination directory '$final_path' already exists.\
|
"The destination directory '$final_path' already exists.\
|
||||||
You should safely delete it before installing this app."
|
You should safely delete it before installing this app."
|
||||||
|
@ -47,6 +51,13 @@ final_path="/var/www/$app"
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
ynh_app_setting_set $app is_public $is_public
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
|
||||||
|
function waitforservice {
|
||||||
|
isup=false; x=45; while [ $x -gt 0 ];do echo "Waiting approx. $x seconds..."; \
|
||||||
|
x=$(( $x - 1 )); sleep 1; if $(curl -m 1 -s localhost:$port${path:-/}/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 ynh_die "$app could not be started"; fi
|
||||||
|
}
|
||||||
|
|
||||||
#Install dependencies
|
#Install dependencies
|
||||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 >/dev/null
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 >/dev/null
|
||||||
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
|
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
|
||||||
|
@ -60,17 +71,14 @@ sudo yunohost service add mongod -l /var/log/mongodb/mongod.log
|
||||||
sudo npm install -g n
|
sudo npm install -g n
|
||||||
sudo n $NODE_VERSION
|
sudo n $NODE_VERSION
|
||||||
|
|
||||||
# find suitable port (default 3000)
|
|
||||||
port=$(ynh_find_port 3000)
|
|
||||||
|
|
||||||
# Create destination
|
# Create destination
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
|
|
||||||
# Copy and set systemd configuration
|
# Copy and set systemd configuration
|
||||||
sed -i "s@#ROOTURL#@$domain@g" ../conf/Rocketchat.service
|
sed -i "s@#ROOTURL#@$domain@g" ../conf/rocketchat.service
|
||||||
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/Rocketchat.service
|
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/rocketchat.service
|
||||||
sed -i "s@#PORT#@/$port@g" ../conf/Rocketchat.service
|
sed -i "s@#PORT#@/$port@g" ../conf/rocketchat.service
|
||||||
sudo cp ../conf/Rocketchat.service /etc/systemd/system/
|
sudo cp ../conf/rocketchat.service /etc/systemd/system/
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
# Copy and set nginx configuration
|
# Copy and set nginx configuration
|
||||||
|
@ -92,32 +100,32 @@ cd $final_path/programs/server/
|
||||||
|
|
||||||
sudo npm install
|
sudo npm install
|
||||||
|
|
||||||
cd $final_path/
|
cd $final_path
|
||||||
|
|
||||||
sudo chown -R www-data: $final_path
|
sudo useradd -d "$final_path" -M $user
|
||||||
|
sudo chown -R $user: $final_path
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo chown -R $user: $final_path
|
||||||
|
|
||||||
|
sudo systemctl reload nginx
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
ynh_app_setting_set "$app" skipped_uris "/"
|
ynh_app_setting_set "$app" skipped_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl start Rocketchat.service
|
sudo systemctl start rocketchat.service
|
||||||
sudo systemctl enable Rocketchat.service
|
sudo systemctl enable rocketchat.service
|
||||||
|
|
||||||
# add Rocketchat to services
|
# add rocketchat to services
|
||||||
sudo yunohost service add Rocketchat
|
sudo yunohost service add rocketchat
|
||||||
|
|
||||||
# wait for rocketchat to populate db and start (oneliner has to be improved)
|
# wait for rocketchat to populate db and start
|
||||||
isup=false; x=45; while [ $x -gt 0 ];do echo "Waiting approx. $x seconds..."; \
|
waitforservice
|
||||||
x=$(( $x - 1 )); sleep 1; if $(curl -m 1 -s localhost:$port${path:-/}/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 ynh_die "$app could not be started"; fi
|
|
||||||
|
|
||||||
cd $workdir
|
sudo mongo < $workdir/conf/rocketchat_ldap.js
|
||||||
|
|
||||||
sudo mongo < ../conf/rocketchat_ldap.js
|
sudo systemctl restart rocketchat.service
|
||||||
|
|
||||||
sudo systemctl restart Rocketchat.service
|
waitforservice
|
||||||
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -11,16 +11,18 @@ 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)
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
|
||||||
sudo systemctl stop Rocketchat.service
|
sudo systemctl stop $app.service
|
||||||
|
|
||||||
# remove Rocketchat from services
|
# remove Rocketchat from services
|
||||||
sudo yunohost service remove Rocketchat
|
sudo yunohost service remove $app
|
||||||
|
|
||||||
sudo rm -rf /var/www/rocketchat
|
sudo rm -rf $final_path
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/rocketchat.conf
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo rm -rf /var/log/rocketchat/
|
sudo rm -rf /var/log/$app
|
||||||
sudo rm -f /etc/systemd/system/Rocketchat.service
|
sudo rm -f /etc/systemd/system/$app.service
|
||||||
|
sudo userdel -r $app
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl restart nginx
|
sudo systemctl reload nginx
|
||||||
|
|
|
@ -54,4 +54,4 @@ ynh_restore_file "$final_path"
|
||||||
# RESTORE THE MONGODB
|
# RESTORE THE MONGODB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo mongorestore --dbpath /var/lib/mongo "$final_path/dump"
|
sudo mongorestore --dbpath /var/lib/mongodb ./dump
|
||||||
|
|
Loading…
Reference in a new issue