From 43f0aafb8b47dc2eb7fdc62e8b6fc2addd31831d Mon Sep 17 00:00:00 2001 From: Selamanse Date: Mon, 4 Sep 2017 22:24:56 +0200 Subject: [PATCH] Add common install routine for restore --- scripts/_common.sh | 21 ++++++++++++++++++++- scripts/install | 16 +--------------- scripts/restore | 13 ++++++++++++- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7c40984..f7bcb1c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,5 +8,24 @@ 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 + then echo "service is up"; else {ynh_die "$app could not be started"; fi +} + +installdeps(){ + #Install dependencies + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 + echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list + sudo apt-get update + sudo apt-get install -y mongodb-org gzip curl graphicsmagick npm + + # start mongodb service + sudo systemctl enable mongod.service + sudo systemctl start mongod.service + + # add mongodb to services + sudo yunohost service add mongod -l /var/log/mongodb/mongod.log + + # Meteor needs at least this version of node to work. + sudo npm install -g n + sudo n $NODE_VERSION } diff --git a/scripts/install b/scripts/install index d1295ce..b568275 100644 --- a/scripts/install +++ b/scripts/install @@ -55,21 +55,7 @@ ynh_app_setting_set $app path $path ynh_app_setting_set $app is_public $is_public #Install dependencies -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 -echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list -sudo apt-get update -sudo apt-get install -y mongodb-org gzip curl graphicsmagick npm - -# start mongodb service -sudo systemctl enable mongod.service -sudo systemctl start mongod.service - -# add mongodb to services -sudo yunohost service add mongod -l /var/log/mongodb/mongod.log - -# Meteor needs at least this version of node to work. -sudo npm install -g n -sudo n $NODE_VERSION +installdeps # Create destination sudo mkdir -p $final_path diff --git a/scripts/restore b/scripts/restore index c261bd5..199fad0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -4,7 +4,12 @@ set -eu #================================================= # IMPORT GENERIC HELPERS #================================================= - +if [ ! -e _common ]; then + # Fetch helpers file if not in current directory + sudo cp ../settings/scripts/_common.sh ./_common.sh + sudo chmod a+rx _common +fi +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -64,6 +69,12 @@ sudo systemctl enable rocketchat sudo tar -xzf ./rocket.chat.gtar -C $final_path sudo chown -R $serviceuser: $final_path +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +installdeps + #================================================= # RESTORE THE MONGODB #=================================================