VPS SETUP GUIDE


Installation of emercoind on a VPS

Note: This guide remains valid however automatic deployment to Ubuntu LTS or Microsoft Azure are now explained in the guide on blockchainengine.org.

The Emercoin cryptocurrency offers a wealth of interesting possibilities, which are not found either in Bitcoin or any of its other numerous forks. However, to take full advantage of all the benefits of this cryptocurrency, you must set up your own server daemon, emercoind. This article is an installation guide for setting up the Emercoin daemon on a Debian 7 VPS.


To test, we chose a $5/month VPS from the company DigitalOcean, using OS Debian 7 x64.

The first thing we need to do is download the latest version of the Emercoin wallet (substite 0.3.7 below for the latest version).

wget http://downloads.sourceforge.net/project/emercoin/0.3.7/emercoin-0.3.7-linux.7z

The system we have is clean, so we'll have to download the 7z archive utility:

apt-get install p7zip-full

Now you can unpack the archive:

7z x emercoin-0.3.7-linux.7z

Since we are using a 64-bit system, you need to copy the emercoind file from the appropriate folder.

mv emercoin-0.3.7-linux/bin/64/emercoind /usr/bin/

Now we create a user who will run the daemon.

addgroup --gid 1000 emc
adduser --home /home/emc --shell /bin/false --no-create-home --uid 1000 --gid 1000 emc
adduser emc emc

Create a hidden directory .emercoin and add a configuration file emercoin.conf:

cd /home/emc
mkdir .emercoin
cd .emercoin
nano emercoin.conf

Here is a sample configuration file:

rpcuser=emccoinrpc
rpcpassword=very_long_and_complex_password

listen=1
server=1
rpcallowip=127.0.0.1
rpcport=8775

maxconnections=80
gen=0
reservebalance=5
daemon=1

emcdns=0 # Activate DNS
emcdnsallowed=.coin|.emc|.lib|.bazar # Allowed TLDs
emcdnsverbose=4
  • server - indicates that the node will be the "server".
  • gen=0 - disable the automatic mining of coins by the processor.
  • rpcport/user/password - sets the values for communication with the wallet.
  • rpcallowip - the IP addresses from which you can access the wallet.

Save and close the editor (key combination ctrl + x in nano) and set read-only access to this file:

chmod 0400 emercoin.conf

Recursively set the owner of the directory /home/emc:

chown -R emc:emc /home/emc/

Now log in as a user and run the wallet. The -s option specifies which shell to use (remember that above we have indicated the default shell for the emc user as /bin/false)

su -s /bin/bash emc
emercoind

A message appears:

emercoin server starting

After which, the server load sharply increases. It will take about half an hour for the wallet to synchnonize with the Emercoin blockchain, and after synchronizing the server load returns to normal.

Typing the following command:

emercoind getinfo

shows the current situation:

{
"Version": "v0.3.0emc-18-gddeac0f-beta",
"Protocolversion": 60003,
"Walletversion": 60000,
"Balance": 0.00000000,
"Newmint": 0.00000000,
"Stake": 0.00000000,
"Blocks": 106379,
"Moneysupply": 35380182.02903000,
"Connections": 13,
"Proxy": "",
"Ip": "XX.XXX.XX.XXX",
"Difficulty": 8407530.87792009,
"Testnet": false,
"Keypoololdest": 1434370307,
"Keypoolsize": 101,
"Paytxfee": 0.01000000,
"Errors": ""
}
Now you can log out, and move on to setting up a demon.

exit

Running as daemon

Go to /etc/init.d/ and copy a template:

cd /etc/init.d/
cp skeleton emercoind

Open the file for editing, and make changes to the top of the file:

nano emercoind

#! /bin/sh
### BEGIN INIT INFO
# Provides: emercoind
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Auto init Emercoin
# Description: Auto init Emercoin via booting system
### END INIT INFO
# Author: Author: Foo Bar
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Emercoin daemon"
NAME=emercoind
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CHUID=emc:emc
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --chuid $CHUID --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.

Data that needs to be changed (leave the rest of the file intact):

  • Provides: emercoind - the title
  • Short-Description / Description - a description of what the file does
  • DESC = "Emercoin daemon" - service description
  • NAME = emercoind - name of the executable file
  • DAEMON=/usr/bin/$NAME - the full path of the file (do not forget to fix on bin or sbin template)
  • DAEMON_ARGS = "- daemon" - tells the wallet to start the daemon in the background. Since in the emercoin.conf file we already defined daemon (daemon=1), the argument can be omitted
  • start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
    - we change to:
    start-stop-daemon --start --quiet --chuid $CHUID --pidfile $ PIDFILE - exec $DAEMON -- \

Save the file ctrl + x and set permissions:

chmod 0755 emercoind

Now everything is almost ready. Perform the command:

/etc/init.d/emercoind

It should list the possible actions:

Usage: /etc/init.d/emercoind {start|stop|status|restart|force-reload}

The instruction

/etc/init.d/emercoind start

starts the emercoind daemon.

To have our daemon automatically start at server boot, use the command:

update-rc.d emercoind defaults

Now you can restart the system.

reboot

If the daemon is running after the restart, then the system is configured correctly.