2015-05-24 23:01:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-12-02 21:41:55 +01:00
|
|
|
#set -e
|
|
|
|
|
2015-05-24 23:01:16 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
port=$2
|
|
|
|
sync_node=$3
|
|
|
|
sync_port=$4
|
|
|
|
salt=$5
|
2015-12-02 21:41:55 +01:00
|
|
|
psswd=$6
|
2015-06-04 21:59:29 +02:00
|
|
|
#cpu=$(($7/100))
|
2015-06-02 23:57:56 +02:00
|
|
|
#cpu=`expr $7 / 100`
|
2015-12-02 21:41:55 +01:00
|
|
|
path=/home/yunohost.app/ucoin
|
|
|
|
ucoin="node --harmony $path/bin/ucoind"
|
2015-05-24 23:01:16 +02:00
|
|
|
|
2015-12-02 21:41:55 +01:00
|
|
|
# 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
|
2015-05-24 23:01:16 +02:00
|
|
|
|
|
|
|
# Install uCoin node and pm2 daemon manager
|
2015-12-02 21:41:55 +01:00
|
|
|
cd /home/yunohost.app/
|
|
|
|
sudo git clone https://github.com/ucoin-io/ucoin
|
|
|
|
cd $path
|
|
|
|
sudo npm install
|
|
|
|
sudo npm install -g pm2
|
2015-05-24 23:01:16 +02:00
|
|
|
|
|
|
|
# Check port availability
|
|
|
|
sudo yunohost app checkport $port
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-06-04 21:59:29 +02:00
|
|
|
# Open port on firewall
|
2015-05-24 23:01:16 +02:00
|
|
|
sudo yunohost firewall allow TCP $port > /dev/null 2>&1
|
|
|
|
|
2015-06-02 22:53:19 +02:00
|
|
|
# Configure and sync uCoin node
|
2015-12-02 21:41:55 +01:00
|
|
|
$ucoin init --autoconf
|
|
|
|
$ucoin config --remoteh $domain --port $port --remotep $port --salt $salt --passwd $psswd # --cpu $cpu
|
|
|
|
$ucoin sync $sync_node $sync_port # --nocautious
|
2015-05-24 23:01:16 +02:00
|
|
|
|
2015-06-04 21:59:29 +02:00
|
|
|
# Launch uCoin node with pm2 daemon
|
2015-12-02 21:41:55 +01:00
|
|
|
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
|