How to easily configure and install NEM on Ubuntu


Here are two scripts that will install nem and its dependencies on Ubuntu 14.04


Something may break with nis and ncc updates. But i will attempt to keep the scripts current.
No guarantees provided.


The first script, ubuntu_install_nem_tools.sh, will create a swap file if wanted, download java and some other useful software, and setup a basic firewall. If you only want to install java 8 see this link
[url=https://github.com/jadedjack/Nem-Installers#how-can-i-install-oracle-java-8]https://github.com/jadedjack/Nem-Installers#how-can-i-install-oracle-java-8


The second script, install_nem.sh, will download the nis-ncc server directly from  http://bob.nem.ninja/ and check it with Gimre's published public key to be sure it is authentic.




The code may be seen at
[url=https://github.com/jadedjack/Nem-Installers]https://github.com/jadedjack/Nem-Installers




Changes
April 14 2014 - install_nem.sh script will automatically get latest version and download , it also installs the client to a more standard linux installation. This is a new version and is not compatible with old one.




Install unzip
sudo apt-get install unzip


Get both files by entering the command
wget https://github.com/jadedjack/Nem-Installers/archive/master.zip


Then uncompress them
unzip master.zip


Make them executable
chmod +x ubuntu_install_nem_tools.sh
chmod +x install_nem.sh


Then run the ubuntu_install_nem_tools.sh script, follow the prompts when software is loaded.
./ubuntu_install_nem_tools.sh


Then run install_nem.sh script.
sudo su -
./install_nem.sh


You can choose to have NIS started automatically or,


You can start NIS with
/etc/init.d/nis start


You can start NCC with
/etc/init.d/ncc start


Stop NIS with
/etc/init.d/nis stop


Stop NCC with
/etc/init.d/ncc stop


Upgrade NIS NCC with latest version, for example
UpgradeNem


The configuration files are saved to /etc/nem
If you want to change something in the nis configuration for example edit it with your favorite text editor.
sudo nano /etc/nem/nis/config-user.properties






Good Luck and have fun.
:slight_smile:

That is GREAT! Thank you!

Thanks! Does more practical to start!

I tested it, it works perfectly fine.

Thanks a lot, jadedjack!

If this is done: https://github.com/NewEconomyMovement/NemCommunityClient/issues/337

You could include an automatic download of the last db file from bob.nem.ninja as well. I think the user should be asked to do it though.

Cool Script. Thanks.

My NIS didn't start. Guess I make there is something I missed. Maybe some has a hint for me.

Log:

O updating local node endpoint from <http://127.0.0.1:7890/> to <http://52.X.Y.Z:7890/> (org.nem.peer.services.LocalNodeEndpointUpdater c)
2015-04-03 12:23:17.428 INFO auto harvesting with 'NBSQP3RYM5ZD5D4IB6YRW26FAPKH7SW44NFLBC5D' -> 'FAILURE_UNKNOWN_ACCOUNT' (org.nem.nis.boot.HarvestAwareNetworkHostBootstrapper e)
2015-04-03 12:23:17.430 SEVERE something really bad happened: java.util.concurrent.CompletionException: java.lang.IllegalStateException: FAILURE_UNKNOWN_ACCOUNT (org.nem.nis.oh d)


Cool Script. Thanks.

My NIS didn't start. Guess I make there is something I missed. Maybe some has a hint for me.

Log:

O updating local node endpoint from <http://127.0.0.1:7890/> to <http://52.X.Y.Z:7890/> (org.nem.peer.services.LocalNodeEndpointUpdater c)
2015-04-03 12:23:17.428 INFO auto harvesting with 'NBSQP3RYM5ZD5D4IB6YRW26FAPKH7SW44NFLBC5D' -> 'FAILURE_UNKNOWN_ACCOUNT' (org.nem.nis.boot.HarvestAwareNetworkHostBootstrapper e)
2015-04-03 12:23:17.430 SEVERE something really bad happened: java.util.concurrent.CompletionException: java.lang.IllegalStateException: FAILURE_UNKNOWN_ACCOUNT (org.nem.nis.oh d)


Problem is the boot.key in nis/config-user.properties file. I set it to my remote private key of my main account. But it still didn't work cause the Account was still unknown. When I tried to start NIS with out config-user.prop* it started but I was not able to boot it. When I connect with my NCC from my localhost it wasn't not able to remote boot NIS. So I choiced to start NCC on remote site (ncc/config.properties updated to public IP) and create a new wallet (I'll never ever use). NIS was syncing and now I can start with remote privat key :-) Next time I would try to just copy my locale nis DB over to remote site.

I am looking forward to trying this. I have a couple questions:

1. Does your top post include each step of the process? Or are you assuming a certain amount of prior knowledge/experience with setting up aws instances? Can a nontechnical (but fairly smart) person get through the whole process with those instructions?

2. Does the amount of server resources it takes to run a node fall within the limitations of the 1st year free AWS account?

Thanks in advance. I'll probably be posting more here once I actually try this.

EDIT: I just found your tutorial for setting up the actual instance, complete with screen shots, so now I'm more confident I'll figure it out. This thread is more like the sequel :wink:

is the script automatically working with 6.26 version? Or just would be a solution if the name of the file at bob-ninja were still the same no matter which is the actual version to be compatible forever?

edit: command UpgradeNem 6.26 did the work…


eeeh didnt… after the upgrade by this command -
running the nis ended with

SEVERE SystemTray is not supported (org.nem.monitor.SystemTrayException <init>)
Exception in thread "AWT-EventQueue-0" org.nem.monitor.SystemTrayException: SystemTray is not supported
        at org.nem.monitor.NemMonitor.lambda$main$18(NemMonitor.java:53)
        at org.nem.monitor.NemMonitor$$Lambda$14/28074779.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:702)
        at java.awt.EventQueue$3.run(EventQueue.java:696)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

forget it, after clean installation it works fine… probably wrong command or something because i was unable to reproduce it too

edit: so the problem was with Nis + Ncc by running it by ./RunMon.sh, when running NIS only everything seems to be OK…

Ok now i am sure, the command runMon doesnt work, runNis is OK. The same errors i get at my raspberry at clean install (new machine, new debian, no ballast).

screen

cd /package

sudo ./nix.runMon.sh

<init>)
Exception in thread "AWT-EventQueue-0" org.nem.monitor.SystemTrayException: SystemTray is not supported
        at org.nem.monitor.NemMonitor.lambda$main$18(NemMonitor.java:53)
        at org.nem.monitor.NemMonitor$$Lambda$13/18955154.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
        at java.awt.EventQueue.access$400(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:697)
        at java.awt.EventQueue$3.run(EventQueue.java:691)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


yes I thought about putting the package in /usr/local but opted for just putting it on the home directory of the user to keep it simple. That way if someone wanted to modify config-user.properties file, it was easy for them.

The better way would be to run nis as a user with no privileges, login,  etc.

I see your point with config-user.properties.
It is not a good practice to bundle the config files with the application package - ideally config files related to a server (NIS?) should be in /etc. Config files related to users should reside in the home directory of the user (ideally as hidden directory i.e. /home/directory/.nis-server). Probably need to get in touch with the devs here to make these enhancements?

I do agree for removing priviliges as far as needed. Not sure what the difference here with NCC and NIS is


Panther was working on a debian package. I think he said he was nearly finished.


Can you link me to the proper use? I`d get in contact with him and would also offer to make a ubuntu package based on his work. (I am a big fan of DRY ;-) )


I have an script that I use with my public servers. It could be added to this script and give the user the option to autostart if they wish.


Is it possible to create a common repository for the scripts (i.e. via Github). Then it would be easy to commit further modifications and share them. Public repositories is also a good place for creating trustworthy scripts anyone can download (without needing to trust your tar.gz is not tampered with)

Different question:

why do you provide dnsproxy when you don`t configure a resolver? Am I missing something in your install script?

EDIT:

Found this thread:
https://forum.ournem.com/technical-discussion/secure-nis-and-ncc-setup-on-linux/

there is some pretty good information in there and I suggest to incorporate some of the ideas for a more secure approach

Is it possible to create a common repository for the scripts (i.e. via Github). Then it would be easy to commit further modifications and share them. Public repositories is also a good place for creating trustworthy scripts anyone can download (without needing to trust your tar.gz is not tampered with)

That is a good idea and I have been thinking about that. Just have not done it yet and was not sure there was enough interest.


Is there an official nem account were we could create a repository for the scripts? Probably better to maintain an official repository even for community contributions. Otherwise things get fragmented pretty fast...


why do you provide dnsproxy when you don`t configure a resolver? Am I missing something in your install script?

I initially did, but the defaults in /etc/default/dnscrypt-proxy seemed to work well enough.


For some reason my ubuntu installation doesn`t use the default settings - will get into that later



As for the script - I had some additional ideas - one is to set things up as described in here:
https://forum.ournem.com/technical-discussion/secure-nis-and-ncc-setup-on-linux/

We can also provide a more detailed setup script where users can choose what to install/modify.
For the update script it would be best if we save version.txt in the nem folder and then when a user wants to perform an update check it against the version on the server and only perform an update if the versions differ

this work is pretty awesome!



[code]./Safe-nem-install.sh 0.6.25[/code]

[code]UpgradeNem 0.6.25[/code]



With the latest script you don`t need the version number anymore - it fetches automatically the latest version.
UpgradeNem will compare it`s own VERSION file against the one on http://bob.nem.ninja and only upgrade if there is a difference in Version number

So just use

[code]./Safe-nem-install.sh[/code]
or
[code]UpgradeNem[/code]


For everyone here - the new script is not compatible with the previous version of this script, since I introduced changes for installing and maintaining the version. To start with the current version of the script, you will need to install from scratch.
If you want keep your current data, just copy existing blockchain/wallet data to the new data directories located at /var/lib/nem. To keep your old settings, you need to edit the properties files located at /etc/nem (be sure to do this as root or via sudo - otherwise you won`t be able to save the changes)
I will provide instructions for this later on.

Something to keep in mind is, that these scripts are also BETA, while they work as is, they are subject to change if needed for better installation or a more secure setup

Enjoy the script.

ps: it`s mrpj not mrjp :P

Edit: credit for the upstart scripts goes to [url=https://forum.ournem.com/technical-discussion/secure-nis-and-ncc-setup-on-linux/]riegel

Edit:
I`ve fixed a little permission issue with the installation script and wrote a more indepth README - once jadedjack merges the changes I will write on how to switch from the old script to the current one.

Important information - for anyone not having fetched the Version 0.1.1 - the update 0.6.28 breaks the init scripts after Upgrading.

You can still use UpgradeNem to upgrade - but need to change

org.nem.core.deploy.CommonStarter
to
org.nem.deploy.CommonStarter

if the files /etc/init.d/nis and /etc/init.d/ncc


You also need to change in the file /etc/init.d/nis the following line
<br />STARTED=`grep -m 1 &quot;NEM Infrastructure Server is ready to serve&quot; $NISLOGFILE`<br />
to
<br />STARTED=`grep -m 1 &quot;NEM Deploy is ready to serve&quot; $NISLOGFILE`<br />

I got my own VPS at Amazon. I think everything is working, but I am not sure how to verify that it's 100% running:



I also want to check the version of NEM I am running at the VPS. What is the command for this?

I will change the RAM-settings. Can you tell me, how many people can use my node by default and how I can set this option?

Thanks. Is an unlockedLimit of 10 optimal for an free Amazon EC2?

Thanks. I will install it. Can you tell me, how to check how many harvesters are on my node?