From ab4b0f7e8c85ec4821fc08a1a311fd4267c4d4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 5 May 2018 11:51:14 +0200 Subject: [PATCH 1/4] sanitize path --- scripts/install | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/install b/scripts/install index 4675365..f4469ec 100644 --- a/scripts/install +++ b/scripts/install @@ -34,6 +34,16 @@ workdir=$(pwd) # find suitable port (default 3000) port=$(ynh_find_port 3000) +# if path do not begin with / add a / at the begining +if [ "${path:0:1}" != "/" ]; then + path="/$path" +fi +# if path do not end with / add a / at the end +if [ "${path:${#path}-1}" != "/" ] && [ ${#path} -gt 1 ]; then + path="$path/" +fi + + # Check domain/path availability ynh_webpath_available $domain $path if [[ ! $? -eq 0 ]]; then From 372c00d2f2038afd07979a7647edca19f2312b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 5 May 2018 11:52:47 +0200 Subject: [PATCH 2/4] update to 0.64.1 --- manifest.json | 2 +- scripts/_common.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 29094e1..84afb58 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ }, "url": "https://github.com/YunoHost-Apps/rocketchat_ynh", "license": "GPL-3.0", - "version": "0.64.0", + "version": "0.64.1", "maintainer": { "name": "selamanse", "email": "selamanse@scheinfrei.info", diff --git a/scripts/_common.sh b/scripts/_common.sh index fe53963..87c1cf7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1,7 @@ # common.sh -ROCKETCHAT_VERSION=0.64.0 -ROCKETCHAT_SHASUM=06aa2c6307c784bc19885fb1e80e1eb7320601c9bc2bfbb0f48c9941d93c6030 +ROCKETCHAT_VERSION=0.64.1 +ROCKETCHAT_SHASUM=8c97b33d9efea7edc2db72462c866ea1c8c4f7054988bebb9fd028c8d6219ec0 NODE_VERSION=8.9.4 checkcmd() { From 51603b2f58cef45e434df745bb59f83828c33771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sat, 5 May 2018 12:37:51 +0200 Subject: [PATCH 3/4] add multiple instances support --- conf/rocketchat.service | 4 ++-- conf/rocketchat_ldap.js | 2 +- manifest.json | 2 +- scripts/install | 17 +++++++++++------ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/conf/rocketchat.service b/conf/rocketchat.service index e7aee51..9ab6361 100644 --- a/conf/rocketchat.service +++ b/conf/rocketchat.service @@ -4,7 +4,7 @@ After=network.target [Service] Type=simple -WorkingDirectory=/var/lib/rocketchat +WorkingDirectory=#DESTDIR# User=#USER# ExecStart=/usr/local/bin/node main.js Restart=always @@ -12,7 +12,7 @@ SyslogIdentifier=rocketchat Environment="BIND_IP=127.0.0.1" Environment="ROOT_URL=https://#ROOTURL##LOCATION#" Environment="PORT=#PORT#" -Environment="MONGO_URL=mongodb://localhost:27017/rocketchat" +Environment="MONGO_URL=mongodb://localhost:27017/#DBNAME#" [Install] WantedBy=multi-user.target diff --git a/conf/rocketchat_ldap.js b/conf/rocketchat_ldap.js index 23de9a0..ccb0f77 100644 --- a/conf/rocketchat_ldap.js +++ b/conf/rocketchat_ldap.js @@ -1,4 +1,4 @@ -use rocketchat +use #DBNAME# db.rocketchat_settings.update( diff --git a/manifest.json b/manifest.json index 84afb58..bc76a2d 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "email": "selamanse@scheinfrei.info", "url": "https://github.com/selamanse" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], diff --git a/scripts/install b/scripts/install index f4469ec..e569c83 100644 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANG app=$YNH_APP_INSTANCE_NAME +dbname=$app serviceuser=rocketchat workdir=$(pwd) @@ -81,7 +82,9 @@ 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 -sudo cp ../conf/rocketchat.service /etc/systemd/system/ +sed -i "s@#DESTDIR#@$final_path@g" ../conf/rocketchat.service +sed -i "s@#DBNAME#@$dbname@g" ../conf/rocketchat.service +sudo cp ../conf/rocketchat.service /etc/systemd/system/$app.service sudo systemctl daemon-reload # Copy and set nginx configuration @@ -90,7 +93,9 @@ 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 -sed -i "s@#DESTDIR#@$final_path@g" ../conf/nginx.conf + +#set db name into ldap config +sed -i "s@#DBNAME#@$dbname@g" ../conf/rocketchat_ldap.js sudo cp ../conf/nginx.conf "$nginx_conf" @@ -119,18 +124,18 @@ then ynh_app_setting_set "$app" skipped_uris "/" fi -sudo systemctl start rocketchat.service -sudo systemctl enable rocketchat.service +sudo systemctl start $app.service +sudo systemctl enable $app.service # add rocketchat to services -sudo yunohost service add rocketchat +sudo yunohost service add $app # wait for rocketchat to populate db and start waitforservice sudo mongo < ../conf/rocketchat_ldap.js -sudo systemctl restart rocketchat.service +sudo systemctl restart $app.service waitforservice From e8268d0613d8816c0c2905e1e72ac1b3eb89d481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 15 May 2018 21:25:56 +0200 Subject: [PATCH 4/4] revert multi-instance --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index bc76a2d..84afb58 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "email": "selamanse@scheinfrei.info", "url": "https://github.com/selamanse" }, - "multi_instance": true, + "multi_instance": false, "services": [ "nginx" ],