1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rocketchat_ynh.git synced 2024-09-03 20:16:25 +02:00

Make it work again (#71)

* Add doctl test files

* Fix nodejs installation

* Improve droplet create

* Improve droplet create

* Improve droplet create

* Modify pkgchk config

* Modify pkgchk config

* Add testconfig again

* Use new helpers and restrict arch

* Upgrade test setup

* Add selamanses key

* Add fingerprint as key id

* Use prebuilt image

* Remove variables in app.src

* Add cleanup cmds

* Fix upgrade

* Remove apt-key warning

* Revert travis

* Revert apt-key setting and restore modifications (#70)

* Fix linter issues

* Fix linter issues

* Fix ynh_replace_string arguments

* Update README.md
This commit is contained in:
Selamanse 2019-05-13 15:41:47 +02:00 committed by GitHub
parent dfc1bb75f5
commit 07f0c1b9c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 94 additions and 75 deletions

View file

@ -23,6 +23,12 @@ Backup stores:
- nginx configuration
- systemd service configuration
#### Supported architectures
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/rocketchat%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/rocketchat/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/rocketchat%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rocketchat/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/rocketchat%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/rocketchat/)
## Links
* Report a bug: [Issues](/../../issues)

7
conf/app.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://releases.rocket.chat/0.73.2/download
SOURCE_SUM=3dc3eb11f383f7b72b0f23fedb305b6a566fa536a1e5087a4398255deeb864d8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=rocket.chat-0.73.2.tgz
SOURCE_EXTRACT=true

View file

@ -5,7 +5,7 @@
"description": {
"en": "the ultimate chat platform"
},
"url": "https://github.com/YunoHost-Apps/rocketchat_ynh",
"url": "https://rocket.chat",
"license": "GPL-3.0",
"version": "0.73.2",
"maintainer": {
@ -41,14 +41,15 @@
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?"
},
"choices": ["Yes", "No"],
"default": "Yes"
},
{
"name": "lang",
"type": "string",
"ask": {
"en": "Select default language"
},

View file

@ -36,4 +36,4 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx"
# BACKUP THE MONGODB DATABASE
#=================================================
sudo mongodump -o "./dump"
mongodump -o "./dump"

View file

@ -30,6 +30,16 @@ app=$YNH_APP_INSTANCE_NAME
dbname=$app
serviceuser=rocketchat
#=================================================
# CHECK IF THE APP CAN BE INSTALLED
#=================================================
# Check for supported architecture
arch="$(uname -m)"
if [[ "$arch" != "x86_64" ]]; then
script_die "This app requires an x86_64 machine, but this one is '${arch}'."
fi
workdir=$(pwd)
# find suitable port (default 3000)
@ -72,74 +82,69 @@ ynh_app_setting_set $app is_public $is_public
installdeps
# Create destination
sudo mkdir -p $final_path
mkdir -p $final_path
# Create user
id -u $serviceuser || sudo useradd -d "$final_path" -M $serviceuser
id -u $serviceuser || useradd -d "$final_path" -M $serviceuser
# Copy and set systemd configuration
sed -i "s@#ROOTURL#@$domain@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@#USER#@$serviceuser@g" ../conf/rocketchat.service
sed -i "s@#DESTDIR#@$final_path@g" ../conf/rocketchat.service
sed -i "s@#DBNAME#@$dbname@g" ../conf/rocketchat.service
ynh_replace_string "#ROOTURL#" "$domain" ../conf/rocketchat.service
ynh_replace_string "#LOCATION#" "${path:-/}" ../conf/rocketchat.service
ynh_replace_string "#PORT#" "$port" ../conf/rocketchat.service
ynh_replace_string "#USER#" "$serviceuser" ../conf/rocketchat.service
ynh_replace_string "#DESTDIR#" "$final_path" ../conf/rocketchat.service
ynh_replace_string "#DBNAME#" "$dbname" ../conf/rocketchat.service
# absolute node path needed
NODE_BIN=$(which node)
sed -i "s@#NODE#@$NODE_BIN@g" ../conf/rocketchat.service
sudo cp ../conf/rocketchat.service /etc/systemd/system/$app.service
sudo systemctl daemon-reload
ynh_replace_string "#NODE#" "$NODE_BIN" ../conf/rocketchat.service
cp ../conf/rocketchat.service /etc/systemd/system/$app.service
systemctl daemon-reload
# 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@#PORT#@$port@g" ../conf/nginx.conf
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
ynh_replace_string "#APP#" "$app" ../conf/nginx.conf
ynh_replace_string "#PATH#" "$path" ../conf/nginx.conf
ynh_replace_string "#PORT#" "$port" ../conf/nginx.conf
ynh_replace_string "#LOCATION#" "${path:-/}" ../conf/nginx.conf
#set db name into ldap config
sed -i "s@#DBNAME#@$dbname@g" ../conf/rocketchat_ldap.js
ynh_replace_string "#DBNAME#" "$dbname" ../conf/rocketchat_ldap.js
sudo cp ../conf/nginx.conf "$nginx_conf"
cp ../conf/nginx.conf "$nginx_conf"
# download and extract rocketchat
echo "Downloading rocket.chat-$ROCKETCHAT_VERSION.gtar from ${ROCKETCHAT_DOWNLOAD_URI}."
sudo curl -s -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "${ROCKETCHAT_DOWNLOAD_URI}"
SHA_DOWNLOAD=$(sha256sum $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar | grep -o "^[a-f0-9]*")
if [[ ! "$SHA_DOWNLOAD" == "$ROCKETCHAT_SHASUM" ]]; then
ynh_die "The sha256sum does not match the configured one"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
sudo tar -xzf $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar -C $final_path --strip-components=1 bundle
sudo rm $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar
ynh_setup_source "$final_path"
sudo chown -R $serviceuser: $final_path
chown -R $serviceuser: $final_path
cd $final_path/programs/server/
sudo -u $serviceuser npm install --production
-u $serviceuser npm install --production
cd $workdir
sudo systemctl reload nginx
systemctl reload nginx
if [ "$is_public" = "Yes" ];
then
ynh_app_setting_set "$app" skipped_uris "/"
fi
sudo systemctl start $app.service
sudo systemctl enable $app.service
systemctl start $app.service
systemctl enable $app.service
# add rocketchat to services
sudo yunohost service add $app
yunohost service add $app
# wait for rocketchat to populate db and start
waitforservice
sudo mongo < ../conf/rocketchat_ldap.js
mongo < ../conf/rocketchat_ldap.js
sudo systemctl restart $app.service
systemctl restart $app.service
waitforservice
sudo yunohost app ssowatconf
yunohost app ssowatconf

View file

@ -14,18 +14,18 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path)
sudo systemctl stop $app.service
systemctl stop $app.service
# remove Rocketchat from services
sudo yunohost service remove $app
yunohost service remove $app
sudo rm -rf $final_path
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -rf /var/log/$app
sudo rm -f /etc/systemd/system/$app.service
ynh_secure_remove $final_path
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
ynh_secure_remove /var/log/$app
ynh_secure_remove /etc/systemd/system/$app.service
# remove database!!!
sudo mongo rocketchat --eval "db.dropDatabase()"
mongo rocketchat --eval "db.dropDatabase()"
sudo systemctl daemon-reload
sudo systemctl reload nginx
systemctl daemon-reload
systemctl reload nginx

View file

@ -1,14 +1,16 @@
#!/bin/bash
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ./_common.sh
if [ ! -e _common.sh ]; then
# Fetch helpers file if not in current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source /usr/share/yunohost/helpers
source _common.sh
#=================================================
# GENERIC START
@ -43,10 +45,10 @@ fi
You should safely delete it before restoring this app."
# Create destination
sudo mkdir -p $final_path
mkdir -p $final_path
# Create user
id -u $serviceuser || sudo useradd -d "$final_path" -M $serviceuser
id -u $serviceuser || useradd -d "$final_path" -M $serviceuser
#=================================================
# STANDARD RESTORATION STEPS
@ -58,19 +60,19 @@ ynh_restore
# RELOAD THE NGINX CONFIGURATION
#=================================================
sudo systemctl reload nginx
systemctl reload nginx
#=================================================
# RELOAD AND ENABLE THE SYSTEMD CONFIGURATION
#=================================================
sudo systemctl daemon-reload
sudo systemctl enable rocketchat
systemctl daemon-reload
systemctl enable rocketchat
#=================================================
# RESTORE PERMISSIONS IN THE APP MAIN DIR
#=================================================
sudo chown -R $serviceuser: $final_path
chown -R $serviceuser: $final_path
#=================================================
# INSTALL DEPENDENCIES
@ -82,11 +84,11 @@ installdeps
# RESTORE THE MONGODB
#=================================================
sudo mongorestore ./dump
mongorestore ./dump
#=================================================
# START APP RELATED SERVICES
#=================================================
sudo systemctl start rocketchat
systemctl start rocketchat
waitforservice

View file

@ -18,31 +18,29 @@ serviceuser=$(ynh_app_setting_get $app serviceuser)
path=$(ynh_app_setting_get $app path)
port=$(ynh_app_setting_get $app port)
# download and extract rocketchat
echo "Downloading rocket.chat-$ROCKETCHAT_VERSION.gtar from ${ROCKETCHAT_DOWNLOAD_URI}."
sudo curl -s -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "${ROCKETCHAT_DOWNLOAD_URI}"
SHA_DOWNLOAD=$(sha256sum $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar | grep -o "^[a-f0-9]*")
if [[ ! "$SHA_DOWNLOAD" == "$ROCKETCHAT_SHASUM" ]]; then
ynh_die "The sha256sum does not match the configured one"
fi
#=================================================
# BACKUP THE APPLICATION
#=================================================
sudo systemctl stop rocketchat
# Backup the current version of the app
ynh_backup_before_upgrade > >(tee "upgrade.log")
sudo rm -rf $final_path
sudo mkdir -p $final_path
systemctl stop rocketchat
ynh_secure_remove $final_path
mkdir -p $final_path
# update to latest required node setup
installnode
sudo tar -xzf $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar -C $final_path --strip-components=1 bundle
sudo rm $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar
ynh_setup_source "$final_path"
sudo chown -R $serviceuser: $final_path
chown -R $serviceuser: $final_path
cd $final_path/programs/server/
sudo npm install --production
npm install --production
sudo chown -R $serviceuser: $final_path
chown -R $serviceuser: $final_path
sudo systemctl start rocketchat
systemctl start rocketchat
waitforservice