Ensure you are logged in as the non-root user being used to run zend and the node tracker
- Install packages from the official guide
- Stop tracker with pm2
- Create systemd unit the node tracker
- Start tracker with systemd
- Stop zend with monit
- Create systemd unit for zend
- Start zend with systemd
- Check status of zend and zentracker
- Enable service units at boot
- Ensure Firewall is monitored by systemd
- Kill and remove pm2
- Remove and purge monit
- acme.sh - Migration to certbot
Description | Command | |
---|---|---|
1 | Install packages for ssl-cert and certbot and ensure other packages are installed from the official guide | sudo apt-get install build-essential software-properties-common apt-transport-https lsb-release dirmngr pwgen ssl-cert git jq ufw curl -y |
2 | Update the package cache | sudo apt-get update -y |
3 | Install curl and add the nodejs repository and update the package cache NOTE: Skip this step for Ubuntu | Debian 9 only sudo apt-get install curl -y curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get update -y |
4 | Install npm, upgrading it to the latest version | sudo apt-get install npm -y && sudo npm install -g n && sudo n latest |
5 | Stop the node tracker NOTE: If for some reason you have more than one tracker running in pm2, you may have to change "0" to the number that corresponds with your tracker, and stop those as well. You can get a listing of the numbers from running: pm2 list | pm2 stop 0 |
6 | <INSERT STEPS TO MIGRATE AND UPGRADE NODE TRACKER> | <INSERT COMMANDS TO MIGRATE AND UPGRADE NODE TRACKER> |
7 | Create a systemd unit file for the Node Tracker, copy and paste the entire block of text | echo "\ [Unit] Description=ZenCash node daemon installed on ~/nodetracker/ Requires=zend.service After=zend.service [Service] User=$USER Type=simple WorkingDirectory=/home/$USER/nodetracker/ ExecStart=/usr/local/bin/node /home/$USER/nodetracker/app.js Restart=always RestartSec=10 [Install] WantedBy=multi-user.target" | sudo tee /lib/systemd/system/zentracker.service |
8 | Test the tracker unit file | sudo systemctl start zentracker |
9 | Follow the tracker output log to check everything looks OK, if all appears fine, exit with CTRL+c | sudo journalctl -fu zentracker Example Output zenops@node01~$ sudo journalctl -fu zentracker |
10 | Stop zend with monit, then stop monit. Both commands are shown to stop via systemctl and sysinit (only one should be needed, but both are here for completeness) | sudo monit stop zend && sleep 8 sudo systemctl stop monit sudo service monit stop |
11 | Create a systemd unit file for zend, copy and paste the entire block of text | echo "\ [Unit] Description=ZenCash daemon [Service] User=$USER Type=forking ExecStart=/usr/bin/zend -daemon -pid=/home/$USER/.zen/zend.pid PIDFile=/home/$USER/.zen/zend.pid Restart=always RestartSec=10 [Install] WantedBy=multi-user.target" | sudo tee /lib/systemd/system/zend.service |
12 | Test the zend unit file | sudo systemctl start zend && sleep 8 |
13 | Check the status of both zend and the tracker, both should return active (running), exit with CTRL+c | sudo systemctl status zend zentracker Example Output zenops@node01:~$ sudo systemctl status zend May 24 22:31:30 node01 systemd[1]: Started ZenCash daemon. ● zentracker.service - ZenCash node daemon installed on ~/nodetracker/ Loaded: loaded (/lib/systemd/system/zentracker.service; disabled; vendor preset: enabled) May 24 22:10:28 node01 node[42000]: 2018-05-25 02:10:28 GMT -- Stat check: connected to:ts1.na blocks:313150 peers:8 bal:0.0247 isValidBal:true queueDepth:0 lastChalBlock:312579 lastExecSec:170.77 |
14 | If both work correctly, enable them at boot | sudo systemctl enable zend zentracker |
15 | Use systemctl to enable the firewall NOTE: Many guides lacked enabling this under systemctl If the firewall is not installed, see: Part 5 - Securing the Host | sudo ufw -f enable sudo systemctl start ufw sudo systemctl enable ufw sudo systemctl status ufw Example Output zenops@node01:~$ sudo systemctl status ufw May 26 16:03:39 node01 systemd[1]: Started Uncomplicated firewall. |
16 | Remove pm2 from startup | sudo rm /etc/systemd/system/pm2* sudo rm /etc/systemd/system/multi-user.target.wants/pm2* |
17 | Kill and remove PM2 (if all of the above executed without error) You may see a message about updating npm, you may ignore this | pm2 kill sudo npm remove pm2 -g sudo rm -r ~/.pm2 Example Output zenops@node01:~$ pm2 kill Example Output zenops@node01:~$ sudo npm remove pm2 -g ╭──────────────────────────╮ |
18 | Remove monit from startup (you may not require both commands, both are present to accommodate either systemd, or init script) Run both commands if you're unsure of which way monit was configured NOTE: It is expected that you will see an error if you execute the command that doesn't correspond with how monit was setup. You can safely dismiss errors from the one command of the two presented here. | sudo systemctl disable monit sudo update-rc.d monit remove |
19 | Remove and purge monit from system and remove old repositories (if all of the above executed without error) | sudo apt-get remove monit -y sudo apt-get purge monit -y sudo apt-get -y autoremove rm -rf ~/zen_node.sh |
20 |