diff --git a/README.md b/README.md
index 352ecb7..a2db8ca 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
INSTALL AS A DAEMON (!!! Tested only on Ubuntu 20.04 !!!)
-
Prerequisites:
1. You should install humanode as in original manual (https://testnet.humanode.io/run-your-own-humanode)
2. Humanode files must be in $HOME/humanode
3. Ngrok binary file should be located in /usr/bin
-To install humanode and ngrok as a daemon you should to edit installer.sh file and add your own variables:
NAME= Your node name, for example "SuPerValiDat0r"
RPC_URL= Your Ngrok url, you can see it on the ngrok website (https://dashboard.ngrok.com/endpoints/status)
NGROK_TOKEN= Your Ngrok authentification token
-Then make this file executable (run a command chmod +x installer.sh) and run it AS ROOT!
+
Prerequisites:
1. !!! You should have secret phrase (i.e. mnemonic) !!!
2. Humanode files must be in $HOME/humanode
Ngrok binary now is auto install in /usr/bin
+To install humanode and ngrok as a daemon you should to edit installer.sh file and add your own variables:
NAME= Your node name, for example "SuPerValiDat0r"
NGROK_TOKEN= Your Ngrok authentification token
SECRET_PHRASE= Your humanode secret phrase (i.e. mnemonic)
+RUN $ ./installer.sh
TELEGRAM NOTIFICATIONS
Prerequisites:
Humanode and Ngrok should run as a services (daemons)
diff --git a/installer.sh b/installer.sh
index 1a677f9..c09dc8e 100644
--- a/installer.sh
+++ b/installer.sh
@@ -2,44 +2,60 @@
# REPLACE DEMO VALUES WITH YOUR VALUES
NAME=DEMO_NODE_NAME
-RPC_URL=DEMO_UNIQUE_RPC_URL
NGROK_TOKEN=DEMO_NGROK_TOKEN
+SECRET_PHRASE=DEMO_SECRET_PHRASE
+USER_HOME="/home/your_user_name"
-echo "Setting up Humanode service..."
-apt install curl jq -y
+echo "Check for humanode & ngrok services..."
+if [ -f /etc/systemd/system/humanode.service ]
+ then
+ systemctl stop humanode&& \
+ systemctl disable humanode
+ sleep 2
+fi
-# Make Humanode startup script
-printf "exec 1> >(logger -t humanode) 2>&1
-exec /usr/local/bin/humanode-peer --name "$NAME" --validator --chain chainspec.json --rpc-url "$RPC_URL" --rpc-cors all" > $HOME/humanode/start.sh
-chmod +x $HOME/humanode/start.sh
-
-# Create Humanode service
-printf "[Unit]
-Description=humanode
-After=network.service
-
-[Service]
-type=simple
-User=$USER
-WorkingDirectory=$HOME/humanode
-ExecStart=$HOME/humanode/start.sh
-Restart=on-failure
+if [ -f /etc/systemd/system/ngrok.service ]
+ then
+ systemctl stop ngrok&& \
+ systemctl disable ngrok
+ sleep 2
+fi
-[Install]
-WantedBy=multi-user.target" > /etc/systemd/system/humanode.service
+echo "Install packages ..."
+apt install curl jq wget unzip -y
+sleep 2
-# Enable & run Humanode service
-systemctl daemon-reload && \
-systemctl enable humanode && \
-systemctl start humanode && \
-systemctl restart systemd-journald
-
-# View last 50 lines of Humanode log
-journalctl -u humanode -n 50 | cat
+if [ -f /usr/bin/ngrok ]
+ then
+ echo "Found ngrok in /usr/bin ..."
+ else
+ wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
+ unzip ngrok-stable-linux-amd64.zip
+ rm ngrok-stable-linux-amd64.zip
+ mv ./ngrok /usr/bin/ngrok
+ chmod +x /usr/bin/ngrok
+ sleep 2
+fi
-echo "Setting up Ngrok service..."
+echo Copy new files from $USER_HOME/humanode to $HOME/humanode ...
+#move humanode folder to /root
+if [ -d $USER_HOME/humanode ]
+ then
+ echo Found $HOME/humanode ...
+ sleep 2
+ mkdir $HOME/humanode
+ cp $USER_HOME/humanode/chainspec.json $HOME/humanode/chainspec.json
+ cp $USER_HOME/humanode/binaries/$(uname -s)-$(uname -m)/humanode-peer $HOME/humanode/humanode-peer
+ sleep 2
+ else
+ echo TODO: unzip humanode-testnet1.zip $USER_HOME/humanode \
+ then run that script again ...
+ exit
+fi
+echo "Configure & run ngrok.service..."
# Make Ngrok config file
+rm -rf $HOME/.ngrok2
mkdir $HOME/.ngrok2
printf "authtoken: $NGROK_TOKEN
tunnels:
@@ -54,7 +70,7 @@ Description=Ngrok
After=network.service
[Service]
-type=simple
+Type=simple
User=$USER
WorkingDirectory=$HOME/.ngrok2
ExecStart=/usr/bin/ngrok start --all --config="ngrok.yml"
@@ -63,10 +79,51 @@ Restart=on-failure
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/ngrok.service
+systemctl daemon-reload
# Enable & run Ngrok service
-systemctl daemon-reload && \
-systemctl enable ngrok && \
-systemctl start ngrok
-
+systemctl enable ngrok && \
+systemctl start ngrok && \
+systemctl status ngrok
# View Ngrok status
-curl localhost:4040/api/tunnels | jq
+# curl localhost:4040/api/tunnels | jq
+curl localhost:4040/api/tunnels | jq > $HOME/humanode/ngrok_tunnels.json
+RPC_URL=$(echo "$public_url" | jq '.tunnels[0].public_url' $HOME/humanode/ngrok_tunnels.json)
+sleep 2
+
+cd $HOME/humanode
+install -m 0755 "humanode-peer" /usr/local/bin
+humanode-peer key insert --key-type aura --suri "$SECRET_PHRASE" --chain chainspec.json
+echo "Make Humanode startup script ..."
+printf "exec 1> >(logger -t humanode) 2>&1
+exec /usr/local/bin/humanode-peer --name "$NAME" --validator --chain chainspec.json --rpc-url "$RPC_URL" --rpc-cors all" > $HOME/humanode/start.sh
+chmod +x $HOME/humanode/start.sh
+ls
+sleep 2
+
+# View last 50 lines of Humanode log
+# journalctl -u humanode -n 50 | cat
+
+echo "Configure & run humanode.service..."
+# Create Humanode service
+printf "[Unit]
+Description=humanode
+After=network.service
+
+[Service]
+Type=simple
+User=$USER
+WorkingDirectory=$HOME/humanode
+ExecStart=/bin/bash $HOME/humanode/start.sh
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target" > /etc/systemd/system/humanode.service
+
+systemctl daemon-reload
+# Enable & run Humanode service
+systemctl enable humanode && \
+systemctl start humanode && \
+systemctl restart systemd-journal
+
+systemctl status humanode
+journalctl -u humanode -f
diff --git a/telegram-notify.sh b/telegram-notify.sh
index 2e937a0..64652a7 100644
--- a/telegram-notify.sh
+++ b/telegram-notify.sh
@@ -1,15 +1,27 @@
#!/bin/bash
-
+#
#Make telegram-send script and move it to /usr/bin folder
printf "#!/bin/bash
-GROUP_ID="TELEGRAM_GROUP_ID"
-BOT_TOKEN="YOUR_TELEGRAM_TOKEN"
-curl -s --data "text=$1" --data "chat_id=$GROUP_ID" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null" > /usr/bin/telegram-send
+#
+# script for sending TEXT/FILE to Telegram
+#
+# Usage: telegram-send "" or ""
+# ..."folder non-exist" errors may be ignored
+#
+SEND_ME=$1
+CHAT_ID=""
+BOT_TOKEN=""
+#
+# Sending text-message
+curl --socks5-basic \
+-X POST https://api.telegram.org/bot$BOT_TOKEN/sendMessage \
+-d chat_id=$CHAT_ID -d text="$SEND_ME"
+#
chmod +x /usr/bin/telegram-send && \
chown root:root /usr/bin/telegram-send
-
-#Add script to crontab (Run every 15 minutes)
+#
+# Add script to crontab (Run every 15 minutes)
crontab -l | { cat; echo "*/15 * * * * /$HOME/humanode/notify.sh >/dev/null 2>&1"; } | crontab -
-
-#Send test message to Telegram
-telegram-send "Test!"
+#
+# Send test message to Telegram
+telegram-send "Working ..."