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] 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