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 - nginx configuration
- systemd service 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 ## Links
* Report a bug: [Issues](/../../issues) * 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": { "description": {
"en": "the ultimate chat platform" "en": "the ultimate chat platform"
}, },
"url": "https://github.com/YunoHost-Apps/rocketchat_ynh", "url": "https://rocket.chat",
"license": "GPL-3.0", "license": "GPL-3.0",
"version": "0.73.2", "version": "0.73.2",
"maintainer": { "maintainer": {
@ -41,14 +41,15 @@
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean",
"ask": { "ask": {
"en": "Is it a public application?" "en": "Is it a public application?"
}, },
"choices": ["Yes", "No"],
"default": "Yes" "default": "Yes"
}, },
{ {
"name": "lang", "name": "lang",
"type": "string",
"ask": { "ask": {
"en": "Select default language" "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 # BACKUP THE MONGODB DATABASE
#================================================= #=================================================
sudo mongodump -o "./dump" mongodump -o "./dump"

View file

@ -30,6 +30,16 @@ app=$YNH_APP_INSTANCE_NAME
dbname=$app dbname=$app
serviceuser=rocketchat 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) workdir=$(pwd)
# find suitable port (default 3000) # find suitable port (default 3000)
@ -72,74 +82,69 @@ ynh_app_setting_set $app is_public $is_public
installdeps installdeps
# Create destination # Create destination
sudo mkdir -p $final_path mkdir -p $final_path
# Create user # 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 # Copy and set systemd configuration
sed -i "s@#ROOTURL#@$domain@g" ../conf/rocketchat.service ynh_replace_string "#ROOTURL#" "$domain" ../conf/rocketchat.service
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/rocketchat.service ynh_replace_string "#LOCATION#" "${path:-/}" ../conf/rocketchat.service
sed -i "s@#PORT#@$port@g" ../conf/rocketchat.service ynh_replace_string "#PORT#" "$port" ../conf/rocketchat.service
sed -i "s@#USER#@$serviceuser@g" ../conf/rocketchat.service ynh_replace_string "#USER#" "$serviceuser" ../conf/rocketchat.service
sed -i "s@#DESTDIR#@$final_path@g" ../conf/rocketchat.service ynh_replace_string "#DESTDIR#" "$final_path" ../conf/rocketchat.service
sed -i "s@#DBNAME#@$dbname@g" ../conf/rocketchat.service ynh_replace_string "#DBNAME#" "$dbname" ../conf/rocketchat.service
# absolute node path needed # absolute node path needed
NODE_BIN=$(which node) NODE_BIN=$(which node)
sed -i "s@#NODE#@$NODE_BIN@g" ../conf/rocketchat.service ynh_replace_string "#NODE#" "$NODE_BIN" ../conf/rocketchat.service
sudo cp ../conf/rocketchat.service /etc/systemd/system/$app.service cp ../conf/rocketchat.service /etc/systemd/system/$app.service
sudo systemctl daemon-reload systemctl daemon-reload
# Copy and set nginx configuration # Copy and set nginx configuration
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
sed -i "s@#APP#@$app@g" ../conf/nginx.conf ynh_replace_string "#APP#" "$app" ../conf/nginx.conf
sed -i "s@#PATH#@$path@g" ../conf/nginx.conf ynh_replace_string "#PATH#" "$path" ../conf/nginx.conf
sed -i "s@#PORT#@$port@g" ../conf/nginx.conf ynh_replace_string "#PORT#" "$port" ../conf/nginx.conf
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf ynh_replace_string "#LOCATION#" "${path:-/}" ../conf/nginx.conf
#set db name into ldap config #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}." # DOWNLOAD, CHECK AND UNPACK SOURCE
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
sudo tar -xzf $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar -C $final_path --strip-components=1 bundle ynh_setup_source "$final_path"
sudo rm $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar
sudo chown -R $serviceuser: $final_path chown -R $serviceuser: $final_path
cd $final_path/programs/server/ cd $final_path/programs/server/
sudo -u $serviceuser npm install --production -u $serviceuser npm install --production
cd $workdir cd $workdir
sudo systemctl reload nginx 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 $app.service systemctl start $app.service
sudo systemctl enable $app.service systemctl enable $app.service
# add rocketchat to services # add rocketchat to services
sudo yunohost service add $app yunohost service add $app
# wait for rocketchat to populate db and start # wait for rocketchat to populate db and start
waitforservice waitforservice
sudo mongo < ../conf/rocketchat_ldap.js mongo < ../conf/rocketchat_ldap.js
sudo systemctl restart $app.service systemctl restart $app.service
waitforservice 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) domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
sudo systemctl stop $app.service systemctl stop $app.service
# remove Rocketchat from services # remove Rocketchat from services
sudo yunohost service remove $app yunohost service remove $app
sudo rm -rf $final_path ynh_secure_remove $final_path
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -rf /var/log/$app ynh_secure_remove /var/log/$app
sudo rm -f /etc/systemd/system/$app.service ynh_secure_remove /etc/systemd/system/$app.service
# remove database!!! # remove database!!!
sudo mongo rocketchat --eval "db.dropDatabase()" mongo rocketchat --eval "db.dropDatabase()"
sudo systemctl daemon-reload systemctl daemon-reload
sudo systemctl reload nginx systemctl reload nginx

View file

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

View file

@ -18,31 +18,29 @@ serviceuser=$(ynh_app_setting_get $app serviceuser)
path=$(ynh_app_setting_get $app path) path=$(ynh_app_setting_get $app path)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
# download and extract rocketchat #=================================================
echo "Downloading rocket.chat-$ROCKETCHAT_VERSION.gtar from ${ROCKETCHAT_DOWNLOAD_URI}." # BACKUP THE APPLICATION
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
sudo systemctl stop rocketchat # Backup the current version of the app
ynh_backup_before_upgrade > >(tee "upgrade.log")
sudo rm -rf $final_path systemctl stop rocketchat
sudo mkdir -p $final_path
ynh_secure_remove $final_path
mkdir -p $final_path
# update to latest required node setup # update to latest required node setup
installnode installnode
sudo tar -xzf $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar -C $final_path --strip-components=1 bundle ynh_setup_source "$final_path"
sudo rm $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar
sudo chown -R $serviceuser: $final_path chown -R $serviceuser: $final_path
cd $final_path/programs/server/ 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 waitforservice