From 2933f8adc76122b6768b8ea0d2a20ac55456212f Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Tue, 10 Oct 2017 00:15:59 -0400 Subject: [PATCH 1/5] Rename mongod service to mongodb --- scripts/_common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6af0ae5..9df5dde 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,11 +26,11 @@ installdeps(){ fi # start mongodb service - sudo systemctl enable mongod.service - sudo systemctl start mongod.service + sudo systemctl enable mongodb.service + sudo systemctl start mongodb.service # add mongodb to services - sudo yunohost service add mongod -l /var/log/mongodb/mongod.log + sudo yunohost service add mongodb -l /var/log/mongodb/mongod.log #Install other dependencies sudo apt-get install -y gzip curl graphicsmagick npm From 0d7bc0f68798c77442e6f138537e2a2cfb248b21 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Tue, 10 Oct 2017 11:06:40 -0400 Subject: [PATCH 2/5] Refactor waitforservice to be more readable --- scripts/_common.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9df5dde..495011e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,10 +5,18 @@ ROCKETCHAT_SHASUM=ed53712b37571b959b5c8c8947d6335c21fced316f2b3174bfe027fa25700c NODE_VERSION=4.7.1 waitforservice() { - isup=false; x=90; 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 + isup=false + seconds=90 + while [ $seconds -gt 0 ]; do + echo "Waiting approx. $seconds seconds..." + seconds=$(( $seconds - 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 + $isup && echo "service is up" || ynh_die "$app could not be started" } installdeps(){ From 912a3adf61b164b7c543d6bb816e6a491071ecba Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Tue, 10 Oct 2017 11:07:04 -0400 Subject: [PATCH 3/5] Set the correct service name for mongodb on armhf --- scripts/_common.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 495011e..7a02fc2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -20,11 +20,15 @@ waitforservice() { } installdeps(){ + mongo=mongod if [ $(dpkg --print-architecture) == "armhf" ]; then #Install mongodb for debian armhf sudo apt-get update sudo apt-get install -y mongodb-server + + # armhf has the old version of mongod, called mongodb + mongo=mongodb else #Install mongodb for debian x86/x64 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 @@ -34,11 +38,11 @@ installdeps(){ fi # start mongodb service - sudo systemctl enable mongodb.service - sudo systemctl start mongodb.service + sudo systemctl enable ${mongo}.service + sudo systemctl start ${mongo}.service # add mongodb to services - sudo yunohost service add mongodb -l /var/log/mongodb/mongod.log + sudo yunohost service add ${mongo} -l /var/log/${mongo}/${mongo}.log #Install other dependencies sudo apt-get install -y gzip curl graphicsmagick npm From 5c70d11eff1235e92cc09c773f86c12d2a5c4a28 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Tue, 10 Oct 2017 11:07:42 -0400 Subject: [PATCH 4/5] Set variables for tarballs to help reduce potential typos --- scripts/install | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 530c234..bb2c966 100644 --- a/scripts/install +++ b/scripts/install @@ -82,15 +82,18 @@ sed -i "s@#DESTDIR#@$final_path@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf "$nginx_conf" # download and extract rocketchat -echo "Downloading rocket.chat-$ROCKETCHAT_VERSION.gtar from https://rocket.chat/releases/${ROCKETCHAT_VERSION}/download." -sudo curl -s -L -o $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar "https://rocket.chat/releases/${ROCKETCHAT_VERSION}/download" -SHA_DOWNLOAD=$(sha256sum $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar | grep -o "^[a-f0-9]*") +tarball=rocket.chat-$ROCKETCHAT_VERSION.gtar +tarpath=$final_path/$tarball +url=https://rocket.chat/releases/${ROCKETCHAT_VERSION}/download +echo "Downloading $tarball from $url" +sudo curl -s -L -o $tarpath "$url" +SHA_DOWNLOAD=$(sha256sum $tarpath | 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 -sudo rm $final_path/rocket.chat-$ROCKETCHAT_VERSION.gtar +sudo tar -xzf $tarpath -C $final_path --strip-components=1 bundle +sudo rm $tarpath sudo chown -R $serviceuser: $final_path @@ -103,7 +106,7 @@ cd $workdir sudo systemctl reload nginx if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set "$app" skipped_uris "/" + ynh_app_setting_set "$app" skipped_uris "/" fi sudo systemctl start rocketchat.service From 0ea7ac40bbde89e309f7207c49e3be63807e4a7e Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Tue, 10 Oct 2017 11:07:42 -0400 Subject: [PATCH 5/5] Set variables for tarballs to help reduce potential typos --- scripts/_common.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7a02fc2..44af6c0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -23,11 +23,18 @@ installdeps(){ mongo=mongod if [ $(dpkg --print-architecture) == "armhf" ]; then - #Install mongodb for debian armhf + # We instal this for the user and service files sudo apt-get update sudo apt-get install -y mongodb-server - # armhf has the old version of mongod, called mongodb + # Rocket chat requires mongodb > 2.4, which raspbian does not provide + tarball=mongodb-linux-i686-v3.2-latest.tgz + wget http://downloads.mongodb.org/linux/$tarball + tar xf tarball + sudo cp ${tarball%%.tgz}*/bin/* /usr/local/bin + + sudo sed -i -e's/bin/local\/bin/' /lib/systemd/system/mongodb.service + mongo=mongodb else #Install mongodb for debian x86/x64 @@ -42,7 +49,7 @@ installdeps(){ sudo systemctl start ${mongo}.service # add mongodb to services - sudo yunohost service add ${mongo} -l /var/log/${mongo}/${mongo}.log + sudo yunohost service add ${mongo} -l /var/log/mongodb/${mongo}.log #Install other dependencies sudo apt-get install -y gzip curl graphicsmagick npm