From 940f146d5f07d3bb3d7380e590c9897de2549a05 Mon Sep 17 00:00:00 2001 From: Moul Date: Wed, 2 Dec 2015 21:41:55 +0100 Subject: [PATCH] Update from https://moul.re/repo/moul/ucoin_ynh/ --- manifest.json | 11 ++++++----- scripts/install | 33 ++++++++++++++++++++++----------- scripts/remove | 17 +++++++++++------ scripts/upgrade | 10 +++++++--- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/manifest.json b/manifest.json index b808a6f..caa46e3 100644 --- a/manifest.json +++ b/manifest.json @@ -3,10 +3,10 @@ "id": "ucoin", "description": { "en": "uCoin node which permits participate chainblocks writing. Monetary system with universal dividende, libre money, Relative Money Theory", - "fr": "Nœux uCoin qui permet de participer l'écriture de blocs. Système monétaire à Dividende universel, monnaie libre, Thérorie Relative de la Monnaie" + "fr": "Nœud uCoin qui permet de participer l'écriture de blocs. Système monétaire à Dividende universel, monnaie libre, Thérorie Relative de la Monnaie" }, "url": "http://ucoin.io/", - "licence": "GPL3", + "licence": "free", "maintainer": { "name": "Moul", "email": "moul@moul.re", @@ -29,8 +29,8 @@ "en": "Port of uCoin node", "fr": "Port du nœud uCoin" }, - "example": "9201", - "default": "9201" + "example": "8999", + "default": "8999" }, { "name": "sync_node", @@ -58,7 +58,8 @@ } }, { - "name": "pwd", + "name": "psswd", + "type": "password", "ask": { "en": "Password of your account", "fr": "Mot de passe de votre compte" diff --git a/scripts/install b/scripts/install index ceea9c4..0b63063 100755 --- a/scripts/install +++ b/scripts/install @@ -1,23 +1,31 @@ #!/bin/bash +#set -e + # Retrieve arguments -#ipv4=$(ifconfig | grep "inet addr:" | sed '1!d' | cut -d : -f 2 | cut -b -14) -#ipv4=$(traceroute -4 maelstro.me | grep ms | cut -d " " -f 4) domain=$1 port=$2 sync_node=$3 sync_port=$4 salt=$5 -pwd=$6 +psswd=$6 #cpu=$(($7/100)) #cpu=`expr $7 / 100` +path=/home/yunohost.app/ucoin +ucoin="node --harmony $path/bin/ucoind" -# Install dependencies: nodejs, npm -sudo apt-get -y -qq install nodejs npm nodejs-legacy +# Install dependencies: nodejs 0.12.x, npm +#sudo apt -y -qq install npm node nodejs-legacy +sudo apt -y -qq install curl g++ make +sudo curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash - +sudo apt -y -qq install nodejs # Install uCoin node and pm2 daemon manager -git clone https://github.com/ucoin-io/ucoin /tmp/ucoin -sudo npm install -g /tmp/ucoin pm2 +cd /home/yunohost.app/ +sudo git clone https://github.com/ucoin-io/ucoin +cd $path +sudo npm install +sudo npm install -g pm2 # Check port availability sudo yunohost app checkport $port @@ -29,9 +37,12 @@ fi sudo yunohost firewall allow TCP $port > /dev/null 2>&1 # Configure and sync uCoin node -ucoind config --noupnp --ipv4 $ipv4 --remote4 $ipv4 --remoteh $domain --port $port --remotep $port --salt $salt --passwd $pwd -# --cpu $cpu -ucoind sync $sync_node $sync_port +$ucoin init --autoconf +$ucoin config --remoteh $domain --port $port --remotep $port --salt $salt --passwd $psswd # --cpu $cpu +$ucoin sync $sync_node $sync_port # --nocautious # Launch uCoin node with pm2 daemon -pm2 start ucoind -- start +pm2 start $path/bin/ucoind --name ucoin --interpreter=node --node-args="--harmony" --log /var/log/ucoin.log -- start + +# Add uCoin service to the YunoHost monitoring +sudo yunohost service add ucoin --log /var/log/ucoin.log diff --git a/scripts/remove b/scripts/remove index c4f22d9..40a57cc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,14 +1,19 @@ #!/bin/bash -# Retrieve argument -port=$2 +#set -e -# Delete uCoin node daemon -pm2 delete ucoind +# Remove uCoin node daemon +pm2 delete ucoin # Remove uCoin node -sudo npm remove ucoin pm2 -#sudo apt-get -y remove nodejs npm +sudo npm remove ucoin + +# Remove uCoin service to YunoHost monitoring +sudo yunohost service remove ucoin + +# I can't remove thoses packages which could be used by other apps +#sudo npm remove pm2 +#sudo apt -y -qq remove nodejs npm # Close opened port sudo yunohost firewall disallow TCP $port diff --git a/scripts/upgrade b/scripts/upgrade index 8333673..a114a52 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,10 +1,14 @@ #!/bin/bash +#set -e + # Stop uCoin daemon -pm2 stop ucoind +pm2 stop ucoin # Upgrade ucoin package -sudo npm install -g ucoin +cd /home/yunohost.app/ucoin +git pull +sudo npm install -g . # Restart uCoin daemon -pm2 restart ucoind +pm2 restart ucoin