diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..3bbe1f22
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@
+# Top-most EditorConfig file
+root = true
+
+# Unix-style end-of-line characters
+[*]
+end_of_line = LF
+
+# Use UTF-8 encoding
+[*.{sh,bash}]
+charset = utf-8
+
+# Indentation settings
+[*.{sh,bash}]
+indent_style = space
+indent_size = 2
+
+# Trailing whitespace
+[*.{sh,bash}]
+trim_trailing_whitespace = true
+
+# Insert final newline
+[*.{sh,bash}]
+insert_final_newline = true
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000..8c312950
--- /dev/null
+++ b/.github/CODE_OF_CONDUCT.md
@@ -0,0 +1,56 @@
+# Contributor Code of Conduct
+
+As contributors and maintainers of this project, and in the interest of
+fostering an open and welcoming community, we pledge to respect all people who
+contribute through reporting issues, posting feature requests, updating
+documentation, submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project a harassment-free
+experience for everyone, regardless of level of experience, gender, gender
+identity and expression, sexual orientation, disability, personal appearance,
+body size, race, ethnicity, age, religion, or nationality.
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery
+* Personal attacks
+* Trolling or insulting/derogatory comments
+* Public or private harassment
+* Publishing other's private information, such as physical or electronic
+ addresses, without explicit permission
+* Other unethical or unprofessional conduct
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful. Note that contributors may be volunteers
+who do not represent Electric Coin Company. They are free to express their own
+opinions so long as they adhere to these guidelines.
+
+By adopting this Code of Conduct, project maintainers commit themselves to
+fairly and consistently applying these principles to every aspect of managing
+this project. Project maintainers who do not follow or enforce the Code of
+Conduct may be permanently removed from the project team.
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting a project maintainer (see below). All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. Maintainers are
+obligated to maintain confidentiality with regard to the reporter of an
+incident.
+
+If you wish to contact specific maintainers directly, the following have made
+themselves available for conduct issues:
+
+- N/A
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 1.3.0, available at
+[https://www.contributor-covenant.org/version/1/3/0/][version]
+
+[homepage]: https://www.contributor-covenant.org
+[version]: https://www.contributor-covenant.org/version/1/3/0/
diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml
new file mode 100644
index 00000000..b89cda64
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug.yml
@@ -0,0 +1,76 @@
+name: Bug Report 🐛
+description: Report something that's not working the way it's (probably) intended to
+title: '[BUG]
'
+labels: ['🐛 Bug']
+assignees:
+ - matthewjdegarmo
+body:
+ - type: dropdown
+ id: environment
+ attributes:
+ label: Environment
+ description: Where are you running multitoolbox?
+ options:
+ - Self-Hosted
+ - VPS
+ - Other (Specify below)
+ validations:
+ required: true
+ - type: input
+ id: system
+ attributes:
+ label: System
+ description: >-
+ For deployment issues, specify your [distro or OS](https://whatsmyos.com/).
+ placeholder: e.g. Ubuntu 20.04 LTS
+ validations:
+ required: false
+ - type: input
+ id: version
+ attributes:
+ label: Version
+ description: What version of multitoolbox are you running?
+ placeholder: v4.2.0 ← should look like this (check multitoolbox options prompt for this)
+ validations:
+ required: false
+ - type: textarea
+ id: repro
+ attributes:
+ label: Describe the problem
+ description: Please describe exactly what is not working, include the steps to reproduce, actual result and expected result
+ placeholder: When doing ABC then DEF, I expect to see XYZ, but I actually see ZYX
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: Additional info
+ description: Logs? Screenshots? Yes, please.
+ placeholder: Take care to blank out any personal info.
+ validations:
+ required: false
+ - type: checkboxes
+ id: idiot-check
+ attributes:
+ label: Please tick the boxes
+ description: Before submitting, please ensure that
+ options:
+ - label: You have explained the issue clearly, and included all relevant info
+ required: true
+ - label: You are using the latest version of multitoolbox
+ required: true
+ - label: You've checked that this [issue hasn't already been raised](https://github.com/RunOnFlux/fluxnode-multitool/issues?q=is%3Aissue)
+ required: true
+ - label: You've checked the official [RunOnFlux Discord](https://discord.gg/runonflux) Pinned messages and FAQ 
+ required: true
+ - label: You agree to the [code of conduct](https://github.com/RunOnFlux/fluxnode-multitool/blob/master/.github/CODE_OF_CONDUCT.md)
+ required: true
+ - type: markdown
+ attributes:
+ value: |-
+ ## Thanks 🙏
+
+ Thank you for raising this ticket - in doing so you are helping to make the app better for everyone 💪
+ ⭐️ Consider dropping the repo a star if you're enjoying multitoolbox!
+ validations:
+ required: false
diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml
new file mode 100644
index 00000000..a103e8fe
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.yml
@@ -0,0 +1,62 @@
+name: Feature Request ✨
+description: Suggest an idea for future development of multitoolbox
+title: '[FEATURE_REQUEST] '
+labels: ['🦄 Feature Request']
+
+body:
+
+ # Field 1 - Is it bug-related
+ - type: textarea
+ id: issue
+ attributes:
+ label: Is your feature request related to a problem? If so, please describe.
+ description:
+ placeholder: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+ validations:
+ required: false
+
+ # Field 2 - Describe feature
+ - type: textarea
+ id: solution
+ attributes:
+ label: Describe the solution you'd like
+ placeholder: An outline of how you would like this to be implemented, include as much details as possible
+ validations:
+ required: true
+
+ # Field 3 - Priority
+ - type: dropdown
+ id: priority
+ attributes:
+ label: Priority
+ description: How urgent is the development of this feature
+ options:
+ - Low (Nice-to-have)
+ - Medium (Would be very useful)
+ - High (The app does not function without it)
+ validations:
+ required: true
+
+ # Field 3 - Can the user implement
+ - type: dropdown
+ id: canImplement
+ attributes:
+ label: Is this something you would be keen to implement
+ description: Are you raising this ticket in order to get an issue number for your PR?
+ options:
+ - 'No'
+ - 'Maybe'
+ - 'Yes!'
+ validations:
+ required: false
+
+ # Final text
+ - type: markdown
+ attributes:
+ value: |-
+ ## Thanks 🙏
+ Thank you for your feature suggestion!
+ Please note that there is no guarantee that your idea will be implemented
+ If you haven't already done so, please Star the [fluxnode-multitool](https://github.com/RunOnFlux/fluxnode-multitool) repository on GitHub, to help other users discover it
+ validations:
+ required: false
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml
new file mode 100644
index 00000000..53ac4780
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/question.yml
@@ -0,0 +1,65 @@
+name: Question 🤷♂️
+description: Got a question about multitoolbox, deployment, development or usage?
+title: '[QUESTION] '
+labels: ['🤷♂️ Question']
+
+body:
+ # Filed 1 - Intro Text
+ - type: markdown
+ attributes:
+ value: >
+ Thanks for using multitoolbox! Questions are welcome.
+ Quick questions should be asked in the [Official RunOnFlux Discord](https://discord.gg/runonflux) support channels, Please. :)
+ validations:
+ required: false
+
+ # Field 2 - The actual question
+ - type: textarea
+ id: question
+ attributes:
+ label: Question
+ description: Outline your question in a clear and concise manner
+ validations:
+ required: true
+
+ # Field 3 - Category
+ - type: dropdown
+ id: category
+ attributes:
+ label: Category
+ description: What part of the application does this relate to?
+ options:
+ - Option 1
+ - Option 2
+ - Option 3
+ - Option 4
+ - Option 5
+ - Option 6
+ - Option 7
+ - Option 8
+ - Option 9
+ - Option 10
+ - Option 11
+ - Option 12
+ - Option 13
+ - Option 14
+ validations:
+ required: true
+
+ # Field 4 - User has RTFM first, and agrees to code of conduct, etc
+ - type: checkboxes
+ id: idiot-check
+ attributes:
+ label: Please tick the boxes
+ description: Before submitting, please ensure that
+ options:
+ - label: You have explained the issue clearly, and included all relevant info
+ required: true
+ - label: You are using the latest version of multitoolbox
+ required: true
+ - label: You've checked that this [issue hasn't already been raised](https://github.com/RunOnFlux/fluxnode-multitool/issues?q=is%3Aissue)
+ required: true
+ - label: You've checked the official [RunOnFlux Discord](https://discord.gg/runonflux) Pinned messages and FAQ 
+ required: true
+ - label: You agree to the [code of conduct](https://github.com/RunOnFlux/fluxnode-multitool/blob/master/.github/CODE_OF_CONDUCT.md)
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/share-feedback.md b/.github/ISSUE_TEMPLATE/share-feedback.md
new file mode 100644
index 00000000..30906de8
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/share-feedback.md
@@ -0,0 +1,10 @@
+---
+name: "Share Feedback \U0001F308"
+about: Share what you think about multitoolbox, and any ideas or suggestions you have
+title: "[FEEDBACK]"
+labels: "\U0001F308 Feedback"
+assignees: ''
+
+---
+
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..7d8a6566
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,5 @@
+{
+ "editor.tabSize": 2,
+ "editor.insertSpaces": false,
+ "editor.detectIndentation": false
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index c1f66dca..36eaf45d 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,14 @@
# MULTITOOLBOX FOR FLUXNODE OPERATORS
1) HOW RUN SCRIPT
-```bash -i <(curl -s https://raw.githubusercontent.com/XK4MiLX/zelnode/master/multitoolbox.sh)```
+```bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)```
+
+Note: If you are having difficulties, try fastgit.org provider
+
+```bash -i <(curl -s https://raw.fastgit.org/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)```
2) MENU:
-
+
3) HOW USE MULTITOOLBOX TO SETUP FLUXNODE:
https://medium.com/zelinsights/zelnode-setup-the-easy-peasy-lemon-squeezy-way-fd89706ea03c
@@ -12,14 +16,16 @@
4) BOOTSTRAP AUTODEPLOY SERVICE (ALWAYS FRESH COPY):
https://fluxnodeservice.com
+
+ 5) HARDWARE REQUIREMENTS DEPEND ON MongoDB
+ https://www.mongodb.com/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms
Any donations are welcomed and appreciated. Thanks.
-https://x4milx.coinrequest.io
+https://kamil.coinrequest.io
```
-CruxID: k4mil@zel.crux
-ZEL: t1f66kBo9xzpgPJV6wvzT7MY6unpm42kvST
+FLUX: t1f66kBo9xzpgPJV6wvzT7MY6unpm42kvST
BTC: 1NDVjrP1zg35nfSD1WBKyYSBf8dgJ8AKay
ETH: 0xf515e0e2ba9347c208418c88a7d75bee3288a010
LTC: LgST14gr5LH93U8NBeAdFZVwsLzxTBRTq8
diff --git a/apps_info.sh b/apps_info.sh
new file mode 100755
index 00000000..189ce017
--- /dev/null
+++ b/apps_info.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+if ! [[ -z $1 ]]; then
+ if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then
+ export ROOT_BRANCH="$1"
+ export BRANCH_ALREADY_REFERENCED='1'
+ bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/apps_info.sh) $ROOT_BRANCH $2
+ unset ROOT_BRANCH
+ unset BRANCH_ALREADY_REFERENCED
+ exit
+ fi
+else
+ export ROOT_BRANCH='master'
+fi
+
+function max(){
+ m="0"
+ for n in "$@"
+ do
+ if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then
+ [ "$n" -gt "$m" ] && m="$n"
+ fi
+ done
+ echo "$m"
+}
+
+network_url_1="explorer.zelcash.online"
+network_url_2="explorer.runonflux.io"
+
+apps_info=$(curl -SsL -m 10 https://api.runonflux.io/apps/globalappsspecifications)
+name=($(jq -r .data[].name <<< "$apps_info"))
+height=($(jq -r .data[].height <<< "$apps_info"))
+network_height_01=$(curl -sk -m 5 https://$network_url_1/api/status?q=getInfo | jq '.info.blocks')
+network_height_02=$(curl -sk -m 5 https://$network_url_2/api/status?q=getInfo | jq '.info.blocks')
+explorer_network_hight=$(max "$network_height_01" "$network_height_02")
+echo -e ""
+echo -e "Apps count: ${#name[@]}"
+echo -e "-------------------------------------"
+for((i=0;i<${#name[@]};i++));
+do
+ expire=$((${height[i]}+22000))
+ block_diff=$((expire-explorer_network_hight))
+ if [[ "$2" =~ '^[0-9]+$' ]]; then
+ block_limit="$2"
+ else
+ block_limit="1000"
+ fi
+ if [[ "$block_diff" -le "$block_limit" ]]; then
+ echo -e "Apps name: ${name[i]}"
+ echo -e "Registered height: ${height[i]}"
+ echo -e "Expire height: $expire"
+ if [[ "$block_diff" -gt "0" ]]; then
+ echo -e "Block till expire: $block_diff"
+ else
+ echo -e "Info: Apps expired!"
+ fi
+ echo -e "-------------------------------------"
+ fi
+done
+unset ROOT_BRANCH
+unset BRANCH_ALREADY_REFERENCED
diff --git a/cdn-speedtest.sh b/cdn-speedtest.sh
new file mode 100755
index 00000000..9ae19630
--- /dev/null
+++ b/cdn-speedtest.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+#
+# Usage:
+# bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) "" "" ""
+#
+# Example 1 ( for testing custom servers ):
+# export list=("http://cdn-11.runonflux.io/apps/fluxshare/getfile/" "http://cdn-11.runonflux.io/apps/fluxshare/getfile/")
+# bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) "6" "flux_explorer_bootstrap.tar.gz" "${list[@]}"
+#
+# Example 2 ( for testing cdn with 6s download test of each server )
+# bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) "6"
+#
+# Example 3 ( for testing cdn with default settings )
+# bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh)
+#
+#
+#color codes
+YELLOW='\033[1;33m'
+GREEN='\033[1;32m'
+CYAN='\033[1;36m'
+NC='\033[0m'
+#emoji codes
+ARROW="${SEA}\xE2\x96\xB6${NC}"
+RIGHT_ANGLE="${GREEN}\xE2\x88\x9F${NC}"
+CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}"
+#global variable
+failed_counter="0"
+
+if ! bc -v > /dev/null 2>&1 ; then
+ sudo apt install -y bc > /dev/null 2>&1 && sleep 1
+fi
+if [[ -z $1 ]]; then
+ dTime="5"
+else
+ dTime="$1"
+fi
+if [[ -z $2 || "$2" == "0" ]]; then
+ BOOTSTRAP_FILE="flux_explorer_bootstrap.tar.gz"
+else
+ BOOTSTRAP_FILE="$2"
+fi
+
+if [[ -z $3 ]]; then
+ rand_by_domain=("5" "6" "7" "8" "9" "10" "11" "12")
+else
+ msg="$3"
+ shift
+ shift
+ rand_by_domain=("$@")
+ custom_url="1"
+fi
+size_list=()
+i=0
+len=${#rand_by_domain[@]}
+echo -e "${ARROW} ${CYAN}Running quick download speed test for ${BOOTSTRAP_FILE}, Servers: ${GREEN}$len${NC}"
+start_test=`date +%s`
+while [ $i -lt $len ];
+do
+ if [[ "$custom_url" == "1" ]]; then
+ testing=$(curl -L -m ${dTime} ${rand_by_domain[$i]}${BOOTSTRAP_FILE} --output testspeed -fail --silent --show-error 2>&1)
+ else
+ testing=$(curl -L -m ${dTime} http://cdn-${rand_by_domain[$i]}.runonflux.io/apps/fluxshare/getfile/${BOOTSTRAP_FILE} --output testspeed -fail --silent --show-error 2>&1)
+ fi
+ testing_size=$(grep -Po "\d+" <<< "$testing" | paste - - - - | awk '{printf "%d\n",$3}')
+ mb=$(bc <<<"scale=2; $testing_size / 1048576 / $dTime" | awk '{printf "%2.2f\n", $1}')
+ if [[ "$custom_url" == "1" ]]; then
+ domain=$(sed -e 's|^[^/]*//||' -e 's|/.*$||' <<< ${rand_by_domain[$i]})
+ echo -e " ${RIGHT_ANGLE} ${GREEN}URL - ${YELLOW}${domain}${GREEN} - Bits Downloaded: ${YELLOW}$testing_size${NC} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+ else
+ echo -e " ${RIGHT_ANGLE} ${GREEN}cdn-${YELLOW}${rand_by_domain[$i]}${GREEN} - Bits Downloaded: ${YELLOW}$testing_size${NC} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+ fi
+ size_list+=($testing_size)
+ if [[ "$testing_size" == "0" ]]; then
+ failed_counter=$(($failed_counter+1))
+ fi
+ i=$(($i+1))
+done
+rServerList=$((${#size_list[@]}-$failed_counter))
+echo -e "${ARROW} ${CYAN}Valid servers: ${GREEN}${rServerList} ${CYAN}- Duration: ${GREEN}$((($(date +%s)-$start_test)/60)) min. $((($(date +%s)-$start_test) % 60)) sec.${NC}"
+sudo rm -rf testspeed > /dev/null 2>&1
+if [[ "$rServerList" == "0" ]]; then
+ exit
+fi
+arr_max=$(printf '%s\n' "${size_list[@]}" | sort -n | tail -1)
+for i in "${!size_list[@]}"; do
+ [[ "${size_list[i]}" == "$arr_max" ]] &&
+ max_indexes+=($i)
+done
+server_index=${rand_by_domain[${max_indexes[0]}]}
+if [[ "$custom_url" == "1" ]]; then
+ BOOTSTRAP_URL="$server_index"
+else
+ BOOTSTRAP_URL="http://cdn-${server_index}.runonflux.io/apps/fluxshare/getfile/"
+fi
+DOWNLOAD_URL="${BOOTSTRAP_URL}${BOOTSTRAP_FILE}"
+mb=$(bc <<<"scale=2; $arr_max / 1048576 / $dTime" | awk '{printf "%2.2f\n", $1}')
+if [[ "$custom_url" == "1" ]]; then
+ domain=$(sed -e 's|^[^/]*//||' -e 's|/.*$||' <<< ${server_index})
+ echo -e "${ARROW} ${CYAN}Best server is: ${YELLOW}${domain} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+else
+ echo -e "${ARROW} ${CYAN}Best server is: ${GREEN}cdn-${YELLOW}${rand_by_domain[${max_indexes[0]}]} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+fi
+echo -e "${CHECK_MARK} ${GREEN}Fastest Server: ${YELLOW}${DOWNLOAD_URL}${NC}"
diff --git a/flux_common.sh b/flux_common.sh
new file mode 100755
index 00000000..dade9332
--- /dev/null
+++ b/flux_common.sh
@@ -0,0 +1,3129 @@
+#!/bin/bash
+#disable bash history
+set +o history
+#trap EXIT call and unset vars and enable history if history if off
+trap toolbox_close EXIT
+function toolbox_close(){
+ unset ROOT_BRANCH
+ unset BRANCH_ALREADY_REFERENCE
+ if [[ $(set -o | grep history) == *"off"* ]]; then
+ set -o history
+ fi
+}
+trap ctrl_c INT
+# exit on ctl_c and call toolbox close from EXIT trap
+function ctrl_c() {
+ exit
+}
+# Collection of common vars and functions used throughout multitoolbox.
+#color codes
+RED='\033[1;31m'
+YELLOW='\033[1;33m'
+BLUE="\\033[38;5;27m"
+SEA="\\033[38;5;49m"
+GREEN='\033[1;32m'
+CYAN='\033[1;36m'
+NC='\033[0m'
+#emoji codes
+CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}"
+X_MARK="${RED}\xE2\x9C\x96${NC}"
+PIN="${RED}\xF0\x9F\x93\x8C${NC}"
+CLOCK="${GREEN}\xE2\x8C\x9B${NC}"
+ARROW="${SEA}\xE2\x96\xB6${NC}"
+BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
+HOT="${ORANGE}\xF0\x9F\x94\xA5${NC}"
+WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
+RIGHT_ANGLE="${GREEN}\xE2\x88\x9F${NC}"
+#bootstrap variable
+server_offline="0"
+failed_counter="0"
+#Explorers
+network_url_1="explorer.zelcash.online"
+network_url_2="explorer.runonflux.io"
+network_url_3="blockbook.zel.network"
+#Wallet variable
+COIN_NAME='flux'
+CONFIG_DIR='.flux'
+CONFIG_FILE='flux.conf'
+#FluxOS variable
+FLUX_DIR='zelflux'
+#Ports
+RPCPORT=16124
+PORT=16125
+#dialog color
+export NEWT_COLORS='
+title=black,
+'
+
+if [[ -z $FLUXOS_VERSION ]]; then
+ FLUXOS_PATH="/home/$USER/zelflux"
+ FLUX_WATCHDOG_PATH="/home/$USER/watchdog"
+ FLUX_DAEMON_PATH="/home/$USER/.flux"
+ FLUX_BENCH_PATH="/home/$USER/.fluxbenchmark"
+ DATA_PATH="/home/$USER"
+ MONGODB_DATA_PATH="/var/lib/mongodb"
+ MONGODB_LOG_PATH="/var/log/mongodb"
+ FLUX_DAEMON_SERVICE="zelflux"
+ FLUX_APPS_FOLDER="$FLUXOS_PATH/ZelApps"
+else
+ FLUXOS_PATH="/dat/usr/lib/fluxos"
+ FLUX_WATCHDOG_PATH="/dat/usr/lib/fluxwatchdog"
+ FLUX_DAEMON_PATH="/dat/var/lib/fluxd"
+ FLUX_BENCH_PATH="/dat/usr/lib/fluxbenchd"
+ DATA_PATH="/dat"
+ MONGODB_DATA_PATH="/dat/var/lib/mongodb"
+ MONGODB_LOG_PATH="/dat/var/log/mongodb"
+ FLUX_DAEMON_SERVICE="fluxd"
+ FLUX_APPS_FOLDER="/dat/var/lib/fluxos/flux-apps"
+fi
+
+##### CONFIGS SECTION ######################################
+function watchdog_conf_create(){
+ sudo touch $FLUX_WATCHDOG_PATH/config.js
+ sudo chown $USER:$USER $FLUX_WATCHDOG_PATH/config.js
+ cat <<- EOF >| $FLUX_WATCHDOG_PATH/config.js
+ module.exports = {
+ label: '${node_label}',
+ tier_eps_min: '${eps_limit}',
+ zelflux_update: '${flux_update}',
+ zelcash_update: '${daemon_update}',
+ zelbench_update: '${bench_update}',
+ action: '${fix_action}',
+ ping: '${ping}',
+ web_hook_url: '${discord}',
+ telegram_alert: '${telegram_alert}',
+ telegram_bot_token: '${telegram_bot_token}',
+ telegram_chat_id: '${telegram_chat_id}'
+ }
+ EOF
+}
+
+function fluxos_conf_create(){
+ if [[ "$1" == "true" ]]; then
+ testnet=true
+ else
+ testnet=false
+ fi
+
+ if [[ -n $FLUXOS_VERSION ]]; then
+ FLUXOS_CONFIG="/tmp"
+ else
+ FLUXOS_CONFIG="$FLUXOS_PATH/config"
+ fi
+
+ touch $FLUXOS_CONFIG/userconfig.js
+ cat <<- EOF >| $FLUXOS_CONFIG/userconfig.js
+module.exports = {
+ initial: {
+ ipaddress: '${WANIP}',
+ zelid: '${ZELID}',
+ development: false,
+ blockedPorts: [],
+ testnet: $testnet,
+ }
+}
+EOF
+if [[ -n $FLUXOS_VERSION ]]; then
+ sudo mv $FLUXOS_CONFIG/userconfig.js $FLUXOS_PATH/config/userconfig.js
+fi
+
+}
+
+function flux_daemon_conf_create() {
+ explorers=(
+ "explorer.runonflux.io"
+ "explorer.zelcash.online"
+ "blockbook.runonflux.io"
+ "explorer.flux.zelcore.io"
+ )
+ selected_ips=($(curl -s -m 20 https://api.runonflux.io/apps/enterprisenodes | jq -r '.data[] | select(.score >= 2200 and .score <= 3000) | .ip' 2>/dev/null | shuf -n 25))
+ nodes=("${selected_ips[@]}" "${explorers[@]}")
+ RPCUSER=$(pwgen -1 8 -n)
+ PASSWORD=$(pwgen -1 20 -n)
+ touch $FLUX_DAEMON_PATH/$CONFIG_FILE
+ {
+ cat <<- EOF
+ rpcuser=$RPCUSER
+ rpcpassword=$PASSWORD
+ rpcallowip=127.0.0.1
+ rpcallowip=172.18.0.1
+ rpcport=$RPCPORT
+ port=$PORT
+ zelnode=1
+ zelnodeprivkey=$zelnodeprivkey
+ zelnodeoutpoint=$zelnodeoutpoint
+ zelnodeindex=$zelnodeindex
+ server=1
+ daemon=1
+ txindex=1
+ addressindex=1
+ timestampindex=1
+ spentindex=1
+ insightexplorer=1
+ experimentalfeatures=1
+ listen=1
+ externalip=$WANIP
+ bind=0.0.0.0
+ maxconnections=256
+ zmqpubhashtx=tcp://127.0.0.1:16123
+ zmqpubhashblock=tcp://127.0.0.1:16123
+ zmqpubrawblock=tcp://127.0.0.1:16123
+ zmqpubrawtx=tcp://127.0.0.1:16123
+ zmqpubsequence=tcp://127.0.0.1:16123
+ # Addnode list
+EOF
+ IFS=$'\n'
+ for node in "${nodes[@]}"; do
+ echo "addnode=$node"
+ done
+ } | sed 's/^[[:space:]]*//' >| $FLUX_DAEMON_PATH/$CONFIG_FILE
+}
+
+function install_conf_create(){
+ sudo touch $DATA_PATH/install_conf.json
+ sudo chown $USER:$USER $DATA_PATH/install_conf.json
+ cat <<- EOF >| $DATA_PATH/install_conf.json
+ {
+ "import_settings": "${import_settings}",
+ "prvkey": "${prvkey}",
+ "outpoint": "${outpoint}",
+ "index": "${index}",
+ "zelid": "${zel_id}",
+ "firewall_disable": "${firewall_disable}",
+ "bootstrap_url": "${bootstrap_url}",
+ "bootstrap_zip_del": "${bootstrap_zip_del}",
+ "swapon": "${swapon}",
+ "use_old_chain": "${use_old_chain}",
+ "node_label": "${node_label}",
+ "zelflux_update": "${zelflux_update}",
+ "zelcash_update": "${zelcash_update}",
+ "zelbench_update": "${zelbench_update}",
+ "discord": "${discord}",
+ "ping": "${ping}",
+ "telegram_alert": "${telegram_alert}",
+ "telegram_bot_token": "${telegram_bot_token}",
+ "telegram_chat_id": "${telegram_chat_id}",
+ "eps_limit": "${eps_limit}",
+ "upnp_port": "${upnp_port}",
+ "gateway_ip": "${gateway_ip}",
+ "upnp_enabled": "${upnp_enabled}",
+ "thunder": "${thunder:-0}"
+ }
+ EOF
+}
+
+###### SMART CONFIG
+function padding() {
+ msg="$1"
+ padding=".................................................................................................................."
+ echo -e "$(printf "%s%s %s\n" "$msg" "${CYAN}${padding:${#msg}}" "${CYAN}[$2${CYAN}]${NC}")"
+}
+
+function insert() {
+ local file="$1" line="$2" newText="$3"
+ sudo sed -i -e "/$line/i"$'\\\n'"$newText"$'\n' "$file"
+}
+
+function RemoveLine(){
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD sed -i "/$1/d" $FLUXOS_PATH/config/userconfig.js
+}
+
+function ClearList() {
+ string="\[\]"
+ display=""
+}
+
+function buildBlockedPortsList() {
+ if [[ ! -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Config file does not exist...${NC}" "${X_MARK}"
+ exit
+ fi
+ if [[ "$1" == "" || "$2" == "" ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Empty key/value skipped${NC}" "${X_MARK}"
+ exit
+ fi
+ key="$1"
+ value="$2"
+ if [[ $(cat "$FLUXOS_PATH/config/userconfig.js" | grep "$key") == "" ]]; then
+ insert "$FLUXOS_PATH/config/userconfig.js" "testnet" " $key: $value,"
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}$3${NC}" "${CHECK_MARK}"
+ return
+ fi
+}
+
+function CreateBlockedPortsList() {
+ ADD=$(whiptail --inputbox "Enter the ports to the blocked list, separated by commas" 8 85 3>&1 1>&2 2>&3)
+ if [[ $? == 1 ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}The operation was canceled${NC}" "${X_MARK}"
+ echo -e ""
+ exit
+ fi
+ NumberCheck=$(sed 's/,/1/g' <<< $ADD)
+ ADD=$(sed 's/,/ /g' <<< $ADD)
+ if ! [[ "$NumberCheck" =~ ^[0-9]+$ ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Input contains non numerical value${NC}" "${X_MARK}"
+ exit
+ fi
+ array=($ADD)
+ sorted_unique_ids=($(echo "${array[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ printf -v joined '%s,' "${sorted_unique_ids[@]}"
+ if [[ "${joined%,}" != "" ]]; then
+ string="\[${joined%,}\]"
+ display="${joined%,}"
+ fi
+}
+
+function AddBlockedPorts() {
+ string=$(grep "blockedPorts" $FLUXOS_PATH/config/userconfig.js | awk -F'[][]' '{print $2}' )
+ delimiter=","
+ declare -a array=($(echo $string | tr "$delimiter" " "))
+ ADD=$(whiptail --inputbox "Enter the ports to the blocked list, separated by commas" 8 85 3>&1 1>&2 2>&3)
+ if [[ $? == 1 ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}The operation was canceled${NC}" "${X_MARK}"
+ echo -e ""
+ exit
+ fi
+ NumberCheck=$(sed 's/,/1/g' <<< $ADD)
+ ADD=$(sed 's/,/ /g' <<< $ADD)
+ if ! [[ "$NumberCheck" =~ ^[0-9]+$ ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Input contains non numerical value${NC}" "${X_MARK}"
+ exit
+ fi
+ array+=($ADD)
+ sorted_unique_ids=($(echo "${array[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ printf -v joined '%s,' "${sorted_unique_ids[@]}"
+ string="\[${joined%,}\]"
+ display="${joined%,}"
+
+}
+
+function ImportBlockedPorts(){
+ array=($(grep -w blockedPorts $FLUXOS_PATH/config/userconfig.js | grep -o '[[:digit:]]*'))
+ sorted_unique_ids=($(echo "${array[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ printf -v joined '%s,' "${sorted_unique_ids[@]}"
+ if [[ "${joined%,}" != "" ]]; then
+ blockedPortsList="\[${joined%,}\]"
+ display="${joined%,}"
+ fi
+}
+
+function blocked_ports(){
+ CHOICE=$(
+ whiptail --title "FluxOS Blocked Ports Management" --menu "Make your choice" 15 40 6 \
+ "1)" "Create new list" \
+ "2)" "Add ports" \
+ "3)" "Clear list" 3>&2 2>&1 1>&3 )
+
+ case $CHOICE in
+ "1)")
+ CreateBlockedPortsList
+ echo -e "${ARROW}${GREEN} BlockedPorts: [$display]${NC}"
+ RemoveLine "blockedPorts"
+ buildBlockedPortsList " blockedPorts" "$string" "Blocked ports list crated successful!" "fluxos"
+ ;;
+ "2)")
+ AddBlockedPorts
+ echo -e "${ARROW}${GREEN} BlockedPorts: [$display]${NC}"
+ RemoveLine "blockedPorts"
+ buildBlockedPortsList " blockedPorts" "$string" "Blocked ports list updated successful!" "fluxos"
+ ;;
+ "3)")
+ ClearList
+ RemoveLine "blockedPorts"
+ buildBlockedPortsList " blockedPorts" "$string" "Blocked ports list cleared successful!" "fluxos"
+ ;;
+ esac
+}
+
+function CreateBlockedRepositoryList() {
+ ADD=$(whiptail --inputbox "Enter the repositories to the blocked list, separated by commas" 8 85 3>&1 1>&2 2>&3)
+ if [[ $? == 1 ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}The operation was canceled${NC}" "${X_MARK}"
+ echo -e ""
+ exit
+ fi
+ ADD=$(sed 's/,/ /g' <<< $ADD)
+ temp_array=($ADD)
+ for i in ${temp_array[@]}
+ do
+ array+=("'$i'")
+ done
+ sorted_unique_ids=($(echo "${array[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ printf -v joined '%s,' "${sorted_unique_ids[@]}"
+ if [[ "${joined%,}" != "" ]]; then
+ string="\[${joined%,}\]"
+ display="${joined%,}"
+ fi
+}
+
+function AddBlockedRepository() {
+ string=$(grep "blockedRepositories" $FLUXOS_PATH/config/userconfig.js | awk -F'[][]' '{print $2}' )
+ delimiter=","
+ declare -a array=($(echo $string | tr "$delimiter" " "))
+ ADD=$(whiptail --inputbox "Enter the repositories to the blocked list, separated by commas" 8 85 3>&1 1>&2 2>&3)
+ if [[ $? == 1 ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}The operation was canceled${NC}" "${X_MARK}"
+ echo -e ""
+ exit
+ fi
+ ADD=$(sed 's/,/ /g' <<< $ADD)
+ temp_array=($ADD)
+ for i in ${temp_array[@]}
+ do
+ array+=("'$i'")
+ done
+ sorted_unique_ids=($(echo "${array[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ printf -v joined '%s,' "${sorted_unique_ids[@]}"
+ string="\[${joined%,}\]"
+ display="${joined%,}"
+}
+
+function buildBlockedRepositoryList() {
+ if [[ ! -f "$FLUXOS_PATH/config/userconfig.js" ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Config file does not exist...${NC}" "${X_MARK}"
+ exit
+ fi
+ if [[ "$1" == "" || "$2" == "" ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Empty key/value skipped${NC}" "${X_MARK}"
+ exit
+ fi
+ key="$1"
+ value="$2"
+ if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep "$key") == "" ]]; then
+ insert "$FLUXOS_PATH/config/userconfig.js" "testnet" " $key: $value,"
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}$3${NC}" "${CHECK_MARK}"
+ return
+ fi
+}
+
+function ImportBlockedRepository() {
+ string=$(grep "blockedRepositories" $FLUXOS_PATH/config/userconfig.js | awk -F'[][]' '{print $2}' )
+ delimiter=","
+ declare -a array=($(echo $string | tr "$delimiter" " "))
+ sorted_unique_ids=($(echo "${array[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ printf -v joined '%s,' "${sorted_unique_ids[@]}"
+ if [[ "${joined%,}" != "" ]]; then
+ blockedRepositoryList="\[${joined%,}\]"
+ display="${joined%,}"
+ fi
+}
+
+function blocked_repositories(){
+ CHOICE=$(
+ whiptail --title "FluxOS Blocked Repositories Management" --menu "Make your choice" 15 40 6 \
+ "1)" "Create new list" \
+ "2)" "Add Repositories" \
+ "3)" "Clear list" 3>&2 2>&1 1>&3 )
+
+ case $CHOICE in
+ "1)")
+ CreateBlockedRepositoryList
+ echo -e "${ARROW}${GREEN} BlockedRepositories: [$display]${NC}"
+ RemoveLine "blockedRepositories"
+ buildBlockedRepositoryList " blockedRepositories" "$string" "Blocked repositories list crated successful!" "fluxos"
+ ;;
+ "2)")
+ AddBlockedRepository
+ echo -e "${ARROW}${GREEN} BlockedRepositories: [$display]${NC}"
+ RemoveLine "blockedRepositories"
+ buildBlockedRepositoryList " blockedRepositories" "$string" "Blocked repositories list updated successful!" "fluxos"
+ ;;
+ "3)")
+ ClearList
+ RemoveLine "blockedRepositories"
+ buildBlockedRepositoryList " blockedRepositories" "$string" "Blocked repositories list cleared successful!" "fluxos"
+ ;;
+ esac
+ echo -e ""
+}
+
+function fluxosConfigBackup(){
+ ConfigFile="$FLUXOS_PATH/config/userconfig.js"
+ if [[ -f $ConfigFile ]]; then
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD cp -nf $ConfigFile $DATA_PATH/userconfig.js.backup > /dev/null 2>&1
+ if [[ -f $DATA_PATH/userconfig.js.backup ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs userconfig.js backup successfully${NC}" "${CHECK_MARK}"
+ else
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs userconfig.js backup failed${NC}" "${X_MARK}"
+ fi
+ else
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs userconfig.js file not exists${NC}" "${X_MARK}"
+ fi
+ echo -e ""
+}
+
+function fluxosConfigRestore(){
+ ConfigFile="$FLUXOS_PATH/config/userconfig.js"
+ if [[ -d $FLUXOS_PATH ]]; then
+ if [[ -f $DATA_PATH/userconfig.js.backup ]]; then
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD cp -nf $DATA_PATH/userconfig.js.backup $ConfigFile > /dev/null 2>&1
+ if [[ -f $ConfigFile ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs userconfig.js restored successfully${NC}" "${CHECK_MARK}"
+ else
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs userconfig.js restored failed${NC}" "${X_MARK}"
+ fi
+ else
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs userconfig.js backup not exists${NC}" "${X_MARK}"
+ fi
+ else
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}FluxOs not installed${NC}" "${X_MARK}"
+ fi
+ echo -e ""
+}
+
+function config_builder() {
+ ########################################################
+ if [[ "$4" == "fluxos" ]]; then
+ key="$1"
+ value_check=$2
+ if [[ "$2" == "false" || "$2" == "true" || "$2" =~ ^[0-9]+$ ]]; then
+ value=$2
+ else
+ value="\'$2\'"
+ fi
+ if [[ "$1" == "kadena" ]]; then
+ if [[ $( grep "chainid" <<< "$2") == "" ]]; then
+ value="\'kadena:$2?chainid=0\'"
+ fi
+ fi
+ if [[ ! -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Config file does not exist...${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ "$1" == "" || "$2" == "" ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}Empty key/value skipped${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep "$key") == "" ]]; then
+ insert "$FLUXOS_PATH/config/userconfig.js" "testnet" " $key: $value,"
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}$3 added successfully${NC}" "${CHECK_MARK}"
+ return
+ fi
+ if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep "$key" | grep "$value_check") != "" ]]; then
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}$3 skipped${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep "$key") != "" ]]; then
+ RemoveLine "$key"
+ insert "$FLUXOS_PATH/config/userconfig.js" "testnet" " $key: $value,"
+ padding "${ARROW}${GREEN} [FluxOS] ${CYAN}$3 changed successfully${NC}" "${CHECK_MARK}"
+ fi
+ fi
+ #####################################################
+ if [[ "$4" == "daemon" ]]; then
+ if [[ ! -f $FLUX_DAEMON_PATH/$CONFIG_FILE ]]; then
+ padding "${ARROW}${GREEN} [Daemon] ${CYAN}Config file does not exist...${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ "$1" == "" || "$2" == "" ]]; then
+ padding "${ARROW}${GREEN} [Daemon] ${CYAN}Empty key/value skipped${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ ! $(grep -w $1 $FLUX_DAEMON_PATH/$CONFIG_FILE) && -f $FLUX_DAEMON_PATH/$CONFIG_FILE ]]; then
+ echo "$1=$2" >> $FLUX_DAEMON_PATH/$CONFIG_FILE
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ padding "${ARROW}${GREEN} [Daemon] ${CYAN}$3 added successfully${NC}" "${CHECK_MARK}"
+ return
+ fi
+ fi
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ padding "${ARROW}${GREEN} [Daemon] ${CYAN}$3 skipped${NC}" "${X_MARK}"
+ return
+ else
+ sed -i "s/$(grep -e $1 $FLUX_DAEMON_PATH/$CONFIG_FILE)/$1=$2/" $FLUX_DAEMON_PATH/$CONFIG_FILE
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ padding "${ARROW}${GREEN} [Daemon] ${CYAN}$3 replaced successfully${NC}" "${CHECK_MARK}"
+ fi
+ fi
+ fi
+ ###################################################
+ if [[ "$4" == "benchmark" ]]; then
+ if [[ "$1" == "" || "$2" == "" ]]; then
+ padding "${ARROW}${GREEN} [BenchD] ${CYAN}Empty key/value skipped${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ ! -f "$FLUX_BENCH_PATH/fluxbench.conf" ]]; then
+ mkdir -p $FLUX_BENCH_PATH > /dev/null 2>&1
+ echo "$1=$2" >> $FLUX_BENCH_PATH/fluxbench.conf
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_BENCH_PATH/fluxbench.conf) ]]; then
+ padding "${ARROW}${GREEN} [BenchD] ${CYAN}$3 added successfully${NC}" "${CHECK_MARK}"
+ return
+ fi
+ fi
+ if [[ ! $(grep -w $1 $FLUX_BENCH_PATH/fluxbench.conf) ]]; then
+ echo "$1=$2" >> $FLUX_BENCH_PATH/fluxbench.conf
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_BENCH_PATH/fluxbench.conf) ]]; then
+ padding "${ARROW}${GREEN} [BenchD] ${CYAN}$3 added successfully${NC}" "${CHECK_MARK}"
+ return
+ fi
+ fi
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_BENCH_PATH/fluxbench.conf) ]]; then
+ padding "${ARROW}${GREEN} [BenchD] ${CYAN}$3 skipped${NC}" "${X_MARK}"
+ else
+ sed -i "s/$(grep -e $1 $FLUX_BENCH_PATH/fluxbench.conf)/$1=$2/" $FLUX_BENCH_PATH/fluxbench.conf
+ if [[ "$1=$2" == $(grep -w $1 $FLUX_BENCH_PATH/fluxbench.conf) ]]; then
+ padding "${ARROW}${GREEN} [BenchD] ${CYAN}$3 replaced successfully${NC}" "${CHECK_MARK}"
+ fi
+ fi
+ fi
+ ###################################################
+ if [[ "$4" == "watchdog" ]]; then
+ if [[ ! -f "$FLUX_WATCHDOG_PATH/config.js" ]]; then
+ padding "${ARROW}${GREEN} [WatchD] ${CYAN}Config file does not exist...${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ "$1" == "" || "$2" == "" ]]; then
+ padding "${ARROW}${GREEN} [WatchD] ${CYAN}Empty key/value skipped${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ $(cat $FLUX_WATCHDOG_PATH/config.js | grep "$1: '$2'") != "" ]]; then
+ padding "${ARROW}${GREEN} [WatchD] ${CYAN}$3 skipped${NC}" "${X_MARK}"
+ return
+ fi
+ if [[ $(cat $FLUX_WATCHDOG_PATH/config.js | grep "$1") != "" ]]; then
+ sed -i "s/$(grep -e $1 $FLUX_WATCHDOG_PATH/config.js)/ $1: '$2',/" $FLUX_WATCHDOG_PATH/config.js
+ if [[ $(grep -w $2 $FLUX_WATCHDOG_PATH/config.js) != "" ]]; then
+ padding "${ARROW}${GREEN} [WatchD] ${CYAN}$3 replaced successfully${NC}" "${CHECK_MARK}"
+ fi
+ fi
+ fi
+}
+
+function smart_reconfiguration(){
+ watchdog_settings_list=("label", "tier_eps_min", "zelflux_update", "zelcash_update", "zelbench_update", "action", "ping", "web_hook_url", "telegram_alert", "telegram_bot_token", "telegram_chat_id")
+ fluxos_settings_list=("kadena", "zelid", "apiport", "ipaddress", "development")
+ daemon_settings_list=("zelnodeprivkey", "zelnodeoutpoint", "zelnodeindex")
+ benchmark_settings_list=("fluxport", "thunder", "speedtestserverid")
+ config_list=$(cat <<-END
+{
+ "prvkey": [{"key": "zelnodeprivkey", "label": "Identity Key"}],
+ "outpoint": [{"key": "zelnodeoutpoint", "label": "Collateral TX ID"}],
+ "index": [{"key": "zelnodeindex", "label": "Output Index"}],
+ "node_label": [{"key": "label", "label": "Node Label"}],
+ "ping": [{"key": "ping", "label": "Discord Nick Ping"}],
+ "zelflux_update": [{"key": "zelflux_update", "label": "FluxOS Auto Update"}],
+ "zelcash_update": [{"key": "zelcash_update", "label": "Daemon Auto Update"}],
+ "zelbench_update": [{"key": "zelbench_update", "label": "Benchmark Auto Update"}],
+ "fluxport": [{"key": "fluxport", "label": "Multi Node Port"}],
+ "thunder": [{"key": "thunder", "label": "Thunder Mode"}],
+ "speedtestserverid": [{"key": "speedtestserverid", "label": "Speed Test Server ID"}],
+ "upnp_port": [{"key": "apiport", "label": "UPnP Port"}],
+ "development": [{"key": "development", "label": "Development Mode"}]
+ }
+END
+)
+
+ install_settings=($(jq -r 'keys | @sh' $DATA_PATH/install_conf.json))
+ for i in "${install_settings[@]}"
+ do
+ install_key=$(echo $i | tr -d "'")
+ key=$(jq -r .$install_key[].key 2> /dev/null <<< "$config_list")
+ if [[ "$key" == "" ]]; then
+ key=$install_key
+ fi
+
+ label=$(jq -r .$install_key[].label 2> /dev/null <<< "$config_list")
+ if [[ "$label" == "" ]]; then
+ label=${install_key^}
+ fi
+
+ if [[ $(echo ${daemon_settings_list[@]} | grep -ow "$key" | wc -l) == "1" ]]; then
+ config="daemon"
+ value=$(jq -r .$install_key $DATA_PATH/install_conf.json)
+ config_builder "$key" "$value" "$label" "$config"
+ fi
+
+ if [[ $(echo ${benchmark_settings_list[@]} | grep -ow "$key" | wc -l) == "1" ]]; then
+ config="benchmark"
+ value=$(jq -r .$install_key $DATA_PATH/install_conf.json)
+ config_builder "$key" "$value" "$label" "$config"
+ fi
+
+ if [[ $(echo ${fluxos_settings_list[@]} | grep -ow "$key" | wc -l) == "1" ]]; then
+ config="fluxos"
+ value=$(jq -r .$install_key $DATA_PATH/install_conf.json)
+ config_builder "$key" "$value" "$label" "$config"
+ fi
+
+ if [[ $(echo ${watchdog_settings_list[@]} | grep -ow "$key" | wc -l) == "1" ]]; then
+ config="watchdog"
+ value=$(jq -r .$install_key $DATA_PATH/install_conf.json)
+ config_builder "$key" "$value" "$label" "$config"
+ fi
+ done
+}
+
+function smart_install_conf(){
+ if [[ "$3" == "import" ]]; then
+ return
+ fi
+ if [[ ! -f $DATA_PATH/install_conf.json ]]; then
+ echo "{}" >| $DATA_PATH/install_conf.json
+ fi
+ echo "$(jq -r --arg key "$1" --arg value "$2" '.[$key]=$value' install_conf.json)" >| $DATA_PATH/install_conf.json
+}
+
+function config_smart_create() {
+ if [[ "$1" != "import" ]]; then
+ rm -rf $DATA_PATH/install_conf.json
+ fi
+ #daemon
+ if [[ -f $FLUX_DAEMON_PATH/$CONFIG_FILE ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Imported daemon settings:${NC}"
+ zelnodeprivkey=$(grep -w zelnodeprivkey $FLUX_DAEMON_PATH/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//' | sed 's/ //g')
+ echo -e "${PIN}${CYAN} Identity Key = ${GREEN}$zelnodeprivkey${NC}"
+ smart_install_conf "prvkey" "$zelnodeprivkey" "$1"
+ zelnodeoutpoint=$(grep -w zelnodeoutpoint $FLUX_DAEMON_PATH/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//' | sed 's/ //g')
+ echo -e "${PIN}${CYAN} Collateral TX ID = ${GREEN}$zelnodeoutpoint${NC}"
+ smart_install_conf "outpoint" "$zelnodeoutpoint" "$1"
+ zelnodeindex=$(grep -w zelnodeindex $FLUX_DAEMON_PATH/$CONFIG_FILE | sed -e 's/zelnodeindex=//' | sed 's/ //g')
+ echo -e "${PIN}${CYAN} Output Index = ${GREEN}$zelnodeindex${NC}"
+ smart_install_conf "index" "$zelnodeindex" "$1"
+ fi
+ #Benchmark
+ if [[ -f $FLUX_BENCH_PATH/fluxbench.conf ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Imported Benchmark settings:${NC}"
+ thunder=$(grep -Po "(?<=thunder=)\d+" $FLUX_BENCH_PATH/fluxbench.conf)
+ if [[ "$thunder" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Thunder Mode = ${GREEN}ENABLED${NC}"
+ smart_install_conf "thunder" "$thunder" "$1"
+ fi
+ speedtestserverid=$(grep -Po "(?<=speedtestserverid=)\d+" $FLUX_BENCH_PATH/fluxbench.conf)
+ if [[ "$speedtestserverid" != "" ]]; then
+ echo -e "${PIN}${CYAN} SpeedTest Server ID = ${GREEN}$speedtestserverid${NC}"
+ smart_install_conf "speedtestserverid" "$speedtestserverid" "$1"
+ fi
+ fluxport=$(grep -Po "(?<=fluxport=)\d+" $FLUX_BENCH_PATH/fluxbench.conf)
+ if [[ "$fluxport" != "" ]]; then
+ upnp_enabled=true
+ echo -e "${PIN}${CYAN} Flux Port = ${GREEN}$fluxport${NC}"
+ smart_install_conf "fluxport" "$fluxport" "$1"
+ smart_install_conf "upnp_enabled" "$upnp_enabled" "$1"
+ fi
+ fi
+ #fluxOS
+ if [[ -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Imported fluxOS settings:${NC}"
+ ZELID=$(grep -w zelid $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$ZELID" != "" ]]; then
+ echo -e "${PIN}${CYAN} Flux/SSP ID = ${GREEN}$ZELID${NC}"
+ smart_install_conf "zelid" "$ZELID" "$1"
+ fi
+ upnp_port=$(grep -w apiport $FLUXOS_PATH/config/userconfig.js | grep -o '[[:digit:]]*')
+ if [[ "$upnp_port" != "" ]]; then
+ gateway_ip=$(ip rout | head -n1 | awk '{print $3}' 2>/dev/null)
+ echo -e "${PIN}${CYAN} API Port = ${GREEN}$upnp_port${NC}"
+ if [[ "$upnp_enabled" == "true" ]]; then
+ echo -e "${PIN}${CYAN} Router IP = ${GREEN}$gateway_ip${NC}"
+ fi
+ smart_install_conf "upnp_port" "$upnp_port" "$1"
+ smart_install_conf "gateway_ip" "$gateway_ip" "$1"
+ fi
+ fi
+ #watchdog
+ if [[ -f $FLUX_WATCHDOG_PATH/config.js ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Imported watchdog settings:${NC}"
+ node_label=$(grep -w label $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*label: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Label = ${GREEN}$node_label${NC}"
+ smart_install_conf "node_label" "$node_label" "$1"
+ else
+ echo -e "${PIN}${CYAN} Label = ${RED}Disabled${NC}"
+ fi
+ eps_limit=$(grep -w tier_eps_min $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*tier_eps_min: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$eps_limit" != "" && "$eps_limit" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Tier_eps_min = ${GREEN}$eps_limit${NC}"
+ smart_install_conf "eps_limit" "$eps_limit" "$1"
+ fi
+ discord=$(grep -w web_hook_url $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*web_hook_url: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$discord" != "" && "$discord" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Discord alert = ${GREEN}Enabled${NC}"
+ smart_install_conf "discord" "$discord" "$1"
+ else
+ echo -e "${PIN}${CYAN} Discord alert = ${RED}Disabled${NC}"
+ fi
+ ping=$(grep -w ping $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*ping: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$ping" != "" && "$ping" != "0" ]]; then
+ if [[ "$discord" != "" && "$discord" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Discord nick ping = ${GREEN}Enabled${NC}"
+ smart_install_conf "ping" "$ping" "$1"
+ else
+ echo -e "${PIN}${CYAN} Discord nick ping = ${RED}Disabled${NC}"
+ fi
+ fi
+ telegram_alert=$(grep -w telegram_alert $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*telegram_alert: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$telegram_alert" != "" && "$telegram_alert" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Telegram alert = ${GREEN}Enabled${NC}"
+ smart_install_conf "telegram_alert" "$telegram_alert" "$1"
+ else
+ echo -e "${PIN}${CYAN} Telegram alert = ${RED}Disabled${NC}"
+ smart_install_conf "telegram_alert" "0" "$1"
+ fi
+ telegram_bot_token=$(grep -w telegram_bot_token $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*telegram_bot_token: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$telegram_alert" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Telegram bot token = ${GREEN}$telegram_bot_token${NC}"
+ smart_install_conf "telegram_bot_token" "$telegram_bot_token" "$1"
+ fi
+ telegram_chat_id=$(grep -w telegram_chat_id $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*telegram_chat_id: .//' | sed -e 's/.\{1\}$//')
+ if [[ "$telegram_alert" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Telegram chat id = ${GREEN}$telegram_chat_id${NC}"
+ smart_install_conf "telegram_chat_id" "$telegram_chat_id" "$1"
+ fi
+ zelflux_update=$(grep -w zelflux_update $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*zelflux_update: .//' | egrep -o '[0-9]')
+ if [[ "$zelflux_update" == "1" ]]; then
+ echo -e "${PIN}${CYAN} FluxOS auto update = ${GREEN}Enabled${NC}"
+ smart_install_conf "zelflux_update" "1" "$1"
+ else
+ echo -e "${PIN}${CYAN} FluxOS auto update = ${GREEN}Disabled${NC}"
+ smart_install_conf "zelflux_update" "0" "$1"
+ fi
+ zelcash_update=$(grep -w zelcash_update $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*zelcash_update: .//' | egrep -o '[0-9]')
+ if [[ "$zelcash_update" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Daemon auto update = ${GREEN}Enabled${NC}"
+ smart_install_conf "zelcash_update" "1" "$1"
+ else
+ echo -e "${PIN}${CYAN} Daemon auto update = ${GREEN}Disabled${NC}"
+ smart_install_conf "zelcash_update" "0" "$1"
+ fi
+ zelbench_update=$(grep -w zelbench_update $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*zelbench_update: .//' | egrep -o '[0-9]')
+ if [[ "$zelbench_update" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Benchmark auto update = ${GREEN}Enabled${NC}"
+ smart_install_conf "zelbench_update" "1" "$1"
+ else
+ echo -e "${PIN}${CYAN} Benchmark auto update = ${GREEN}Disabled${NC}"
+ smart_install_conf "zelbench_update" "0" "$1"
+ fi
+ action=$(grep -w action $FLUX_WATCHDOG_PATH/config.js | sed -e 's/.*action: .//' | egrep -o '[0-9]')
+ if [[ "$action" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Fix action = ${GREEN}Enabled${NC}"
+ smart_install_conf "action" "1" "$1"
+ else
+ echo -e "${PIN}${CYAN} Fix action = ${GREEN}Disabled${NC}"
+ smart_install_conf "action" "0" "$1"
+ fi
+ fi
+ echo -e ""
+ if [[ "$1" != "import" ]]; then
+ echo -e "${HOT}${CYAN} Config file created, path: ${GREEN}$DATA_PATH/install_conf.json${NC}"
+ echo -e ""
+ fi
+}
+
+function manual_build(){
+ skip_zelcash_config='0'
+ skip_bootstrap='0'
+ if [[ -d $FLUX_DAEMON_PATH ]]; then
+ if whiptail --yesno "Would you like import old settings from daemon and Flux?" 8 65; then
+ import_settings='1'
+ skip_zelcash_config='1'
+ sleep 1
+ else
+ import_settings='0'
+ sleep 1
+ fi
+ if whiptail --yesno "Would you like use exist Flux chain?" 8 65; then
+ use_old_chain='1'
+ skip_bootstrap='1'
+ sleep 1
+ else
+ use_old_chain='0'
+ sleep 1
+ fi
+ fi
+
+ if [[ "$skip_zelcash_config" == "1" ]]; then
+ prvkey=""
+ outpoint=""
+ index=""
+ zelid=""
+ node_label="0"
+ fix_action="1"
+ eps_limit="0"
+ discord="0"
+ ping="0"
+ telegram_alert="0"
+ telegram_bot_token="0"
+ telegram_chat_id="0"
+ else
+ prvkey=$(whiptail --inputbox "Enter your FluxNode Identity Key from Zelcore" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+ outpoint=$(whiptail --inputbox "Enter your FluxNode Collateral TX ID from Zelcore" 8 72 3>&1 1>&2 2>&3)
+ sleep 1
+ index=$(whiptail --inputbox "Enter your FluxNode Output Index from Zelcore" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+ while true
+ do
+ zel_id=$(whiptail --title "Flux Configuration" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)
+ if [ $(printf "%s" "$zel_id" | wc -c) -eq "34" ] || [ $(printf "%s" "$zel_id" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$zel_id") ]; then
+ echo -e "${ARROW} ${CYAN}Zel ID is valid${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ else
+ echo -e "${ARROW} ${CYAN}Zel ID is not valid try again...........[${X_MARK}${CYAN}]${NC}"
+ sleep 4
+ fi
+ done
+ sleep 1
+ if whiptail --yesno "Would you like enable autoupdate?" 8 65; then
+ zelflux_update='1'
+ zelcash_update='1'
+ zelbench_update='1'
+ else
+ zelflux_update='0'
+ zelcash_update='0'
+ zelbench_update='0'
+ fi
+ if whiptail --yesno "Would you like enable alert notification?" 8 65; then
+ whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60
+ sleep 1
+ CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \
+ "1" "Discord notification " ON \
+ "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 )
+ if [[ -z "$CHOICES" ]]; then
+ echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}"
+ sleep 1
+ discord="0"
+ ping="0"
+ telegram_alert="0"
+ telegram_bot_token="0"
+ telegram_chat_id="0"
+ node_label="0"
+ else
+ for CHOICE in $CHOICES; do
+ case "$CHOICE" in
+ "1")
+ discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+ if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then
+ while true
+ do
+ ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3)
+ if [[ $ping == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "UserID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "UserID is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ else
+ ping="0"
+ sleep 1
+ fi
+ ;;
+ "2")
+ telegram_alert="1"
+ while true
+ do
+ telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3)
+ if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then
+ string_limit_check_mark "Bot token is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Bot token is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ while true
+ do
+ telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3)
+ if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "Chat ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Chat ID is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ ;;
+ esac
+ done
+ fi
+ while true
+ do
+ node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3)
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ string_limit_check_mark "Node name is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Node name is not valid try again............................."
+ sleep 1
+ fi
+ done
+ else
+ discord="0"
+ ping="0"
+ telegram_alert="0"
+ telegram_bot_token="0"
+ telegram_chat_id="0"
+ node_label="0"
+ sleep 1
+ fi
+
+ if [[ "$discord" == 0 ]]; then
+ ping="0"
+ fi
+
+ if [[ "$telegram_alert" == 0 || "$telegram_alert" == "" ]]; then
+ telegram_alert="0"
+ telegram_bot_token="0"
+ telegram_chat_id="0"
+ fi
+ index_from_file="$index"
+ tx_from_file="$outpoint"
+ stak_info=$(curl -sSL -m 5 https://$network_url_1/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -sSL -m 5 https://$network_url_2/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ fi
+ if [[ $stak_info == ?(-)+([0-9]) ]]; then
+ case $stak_info in
+ "1000") eps_limit=240 ;;
+ "12500") eps_limit=640 ;;
+ "40000") eps_limit=1520 ;;
+ esac
+ else
+ eps_limit=0;
+ fi
+ fi
+ if [[ "$skip_bootstrap" == "0" ]]; then
+ if whiptail --yesno "Would you like use Flux bootstrap from script source?" 8 65; then
+ bootstrap_url=""
+ sleep 1
+ else
+ bootstrap_url=$(whiptail --inputbox "Enter your Flux bootstrap URL" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+ fi
+ if whiptail --yesno "Would you like keep bootstrap archive file localy?" 8 65; then
+ bootstrap_zip_del='0'
+ sleep 1
+ else
+ bootstrap_zip_del='1'
+ sleep 1
+ fi
+ fi
+ if whiptail --yesno "Would you like to enable UPnP for this node?" 8 65; then
+ upnp_enabled=true
+ router_ip=$(ip rout | head -n1 | awk '{print $3}' 2>/dev/null)
+ gateway_ip=$(whiptail --inputbox "Enter your UPnP Gateway IP: (This is usually your router: $router_ip)" 8 85 3>&1 1>&2 2>&3)
+ upnp_port=$(whiptail --title "Enter your FluxOS UPnP Port" --radiolist \
+ "Use the UP/DOWN arrows to highlight the port you want. Press Spacebar on the port you want to select, THEN press ENTER." 17 50 8 \
+ "16127" "" ON \
+ "16137" "" OFF \
+ "16147" "" OFF \
+ "16157" "" OFF \
+ "16167" "" OFF \
+ "16177" "" OFF \
+ "16187" "" OFF \
+ "16197" "" OFF 3>&1 1>&2 2>&3)
+ else
+ upnp_enabled=""
+ gateway_ip=""
+ upnp_port=""
+ fi
+ firewall_disable='1'
+ swapon='1'
+
+ if whiptail --yesno "Would you like enable thunder mode?" 8 60; then
+ thunder='1'
+ fi
+
+ rm $DATA_PATH/install_conf.json > /dev/null 2>&1
+ install_conf_create
+ config_file
+ echo -e
+}
+###### HELPERS SECTION
+function os_check(){
+ passed=0
+ avx_check=$(cat /proc/cpuinfo | grep -o avx | head -n1)
+ os_version=$(lsb_release -rs | tr -d '.')
+ architecture=$(dpkg --print-architecture)
+
+ if [[ $(lsb_release -d) = *Debian* ]]; then
+ if [[ "$os_version" -le "9" ]]; then
+ passed=1
+ fi
+ if [[ "$os_version" -ge "10" && "$architecture" == "amd64" && "$avx_check" != "" ]]; then
+ passed=1
+ fi
+ if [[ "$os_version" -ge "12" && "$architecture" == "arm64" ]]; then
+ passed=1
+ fi
+ fi
+
+ if [[ $(lsb_release -d) = *Ubuntu* ]]; then
+ if [[ "$os_version" -le "2010" ]]; then
+ passed=1
+ fi
+ if [[ "$os_version" -ge "2204" && "$architecture" == "amd64" && "$avx_check" != "" ]]; then
+ passed=1
+ fi
+ if [[ "$os_version" -ge "2310" && "$architecture" == "arm64" ]]; then
+ passed=1
+ fi
+ fi
+
+ if [[ "$passed" == "0" ]]; then
+ echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) - $(lsb_release -cs) not supported${NC}"
+ if [[ "$architecture" == "amd64" ]]; then
+ echo -e "${WORNING} ${CYNA}AVX CPU instruction set not found and is required to use MongoDB on $(lsb_release -cs)${NC}"
+ echo -e "${WORNING} ${CYNA}The last version supporting CPUs without AVX is Ubuntu 20.04 LTS. Please re-image and retry installation.${NC}"
+ fi
+ if [[ "$architecture" == "arm64" ]]; then
+ echo -e "${WORNING} ${CYNA}ARMv8.2-A or later microarchitecture is required to use MongoDB on $(lsb_release -cs)${NC}"
+ echo -e "${WORNING} ${CYNA}If you're using ARM architecture older than ARMv8.2-A, it's recommended to use Ubuntu 20.04 LTS. Please re-image and retry installation.${NC}"
+ fi
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+ fi
+}
+
+function fluxos_clean(){
+ docker_check=$(sudo docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
+ resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
+ if [[ $docker_check != 0 ]]; then
+ echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
+ sudo service docker restart > /dev/null 2>&1 && sleep 2
+ sudo docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" |
+ while read line; do
+ sudo docker stop $line > /dev/null 2>&1 && sleep 2
+ sudo docker rm $line > /dev/null 2>&1 && sleep 2
+ done
+ fi
+ echo -e "${ARROW} ${CYAN}Removing syncthing...${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo pkill -9 syncthing > /dev/null 2>&1
+ sudo apt-get remove --purge syncthing -y > /dev/null 2>&1
+ sudo apt-get autoremove -y > /dev/null 2>&1
+ else
+ sudo systemctl stop syncthing > /dev/null 2>&1
+ sudo rm /dat/usr/lib/syncthing/config.xml > /dev/null 2>&1
+ sudo cp /dat/usr/lib/syncthing/original.xml /dat/usr/lib/syncthing/config.xml > /dev/null 2>&1
+ fi
+ if [[ $resource_check != 0 ]]; then
+ echo -e "${ARROW} ${CYAN}Unmounting locked FluxOS resource...${NC}" && sleep 1
+ df | grep 'flux' | grep -v 'flux_crypt' | awk '{ print $1 }' |
+ while read line; do
+ sudo umount -l $line && sleep 1
+ done
+ fi
+ if [[ -d $FLUX_APPS_FOLDER && $(find $FLUX_APPS_FOLDER -maxdepth 1 -mindepth 1 -type d | wc -l) -gt 1 ]]; then
+ echo -e "${ARROW} ${CYAN}Cleaning FluxOS Apps directory...${NC}" && sleep 1
+ APPS_LIST=($(find $FLUX_APPS_FOLDER -maxdepth 1 -mindepth 1 -type d -printf '%P\n'))
+ LENGTH=${#APPS_LIST[@]}
+ for (( j=0; j<${LENGTH}; j++ ));
+ do
+ if [[ "${APPS_LIST[$j]}" != "ZelShare" && "${APPS_LIST[$j]}" != "" ]]; then
+ echo -e "${ARROW} ${CYAN}Apps directory removed, path: ${GREEN}$FLUX_APPS_FOLDER/${APPS_LIST[$j]}${NC}"
+ sudo rm -rf $FLUXOS_PATH/ZelApps/${APPS_LIST[$j]}
+ fi
+ done
+ fi
+}
+
+function round() {
+ LC_NUMERIC=C printf "%.${2}f" "${1}"
+}
+function insertAfter() {
+ local file="$1" line="$2" newText="$3"
+ sudo sed -i -e "/$line/a"$'\\\n'"$newText"$'\n' "$file"
+}
+function max(){
+ m="0"
+ for n in "$@"
+ do
+ if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then
+ [ "$n" -gt "$m" ] && m="$n"
+ fi
+ done
+ echo "$m"
+}
+function spinning_timer() {
+ animation=( ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ )
+ end=$((SECONDS+NUM))
+ while [ $SECONDS -lt $end ];
+ do
+ for i in "${animation[@]}";
+ do
+ echo -e ""
+ echo -ne "${RED}\r\033[1A\033[0K$i ${CYAN}${MSG1}${NC}"
+ sleep 0.1
+
+ done
+ done
+ echo -ne "${MSG2}"
+}
+function string_limit_x_mark() {
+ if [[ -z "$2" ]]; then
+ string="$1"
+ string=${string::50}
+ else
+ string=$1
+ string_color=$2
+ string_leght=${#string}
+ string_leght_color=${#string_color}
+ string_diff=$((string_leght_color-string_leght))
+ string=${string_color::50+string_diff}
+ fi
+ echo -e "${ARROW} ${CYAN}$string[${X_MARK}${CYAN}]${NC}"
+}
+function string_limit_check_mark_port() {
+ if [[ -z "$2" ]]; then
+ string="$1"
+ string=${string::65}
+ else
+ string=$1
+ string_color=$2
+ string_leght=${#string}
+ string_leght_color=${#string_color}
+ string_diff=$((string_leght_color-string_leght))
+ string=${string_color::65+string_diff}
+ fi
+ echo -e "${PIN}${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
+}
+function string_limit_check_mark() {
+ if [[ -z "$2" ]]; then
+ string="$1"
+ string=${string::40}
+ else
+ string=$1
+ string_color=$2
+ string_leght=${#string}
+ string_leght_color=${#string_color}
+ string_diff=$((string_leght_color-string_leght))
+ string=${string_color::40+string_diff}
+ fi
+ echo -e "${ARROW} ${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
+}
+function integration_check() {
+ FILE_ARRAY=( 'fluxbench-cli' 'fluxbenchd' 'flux-cli' 'fluxd' 'flux-fetch-params' 'flux-tx' )
+ ELEMENTS=${#FILE_ARRAY[@]}
+ for (( i=0;i<$ELEMENTS;i++)); do
+ string="${FILE_ARRAY[${i}]}......................................"
+ string=${string::40}
+ if [ -f "$COIN_PATH/${FILE_ARRAY[${i}]}" ]; then
+ echo -e "${ARROW}${CYAN} $string[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${ARROW}${CYAN} $string[${X_MARK}${CYAN}]${NC}"
+ CORRUPTED="1"
+ fi
+ done
+ if [[ "$CORRUPTED" == "1" ]]; then
+ echo -e "${WORNING} ${CYAN}Flux daemon package corrupted...${NC}"
+ echo -e "${WORNING} ${CYAN}Will exit out so try and run the script again...${NC}"
+ echo -e ""
+ exit
+ fi
+
+}
+
+function flux_block_height() {
+ if [[ "$1" != "-testnet" ]]; then
+ network_height_01=$(curl -sk -m 8 https://$network_url_1/api/status?q=getInfo 2> /dev/null | jq '.info.blocks' 2> /dev/null)
+ network_height_02=$(curl -sk -m 8 https://$network_url_2/api/status?q=getInfo 2> /dev/null | jq '.info.blocks' 2> /dev/null)
+ else
+ network_height_01=$(curl -sk -m 8 https://testnet.runonflux.io/api/status?q=getInfo 2> /dev/null | jq '.info.blocks' 2> /dev/null)
+ network_height_02=$(curl -sk -m 8 https://testnet.runonflux.io/api/status?q=getInfo 2> /dev/null | jq '.info.blocks' 2> /dev/null)
+ fi
+ EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_02")
+}
+
+function status_loop() {
+ flux_block_height "$1"
+ if [[ "$EXPLORER_BLOCK_HIGHT" == $(${COIN_CLI} $1 getinfo | jq '.blocks' 2> /dev/null) ]]; then
+ echo -e ""
+ echo -e "${CLOCK}${GREEN} FLUX DAEMON SYNCING...${NC}"
+ LOCAL_BLOCK_HIGHT=$(${COIN_CLI} $1 getinfo 2> /dev/null | jq '.blocks' 2> /dev/null)
+ CONNECTIONS=$(${COIN_CLI} $1 getinfo 2> /dev/null | jq '.connections' 2> /dev/null)
+ LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+ NUM='2'
+ MSG1="Syncing progress >> Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN}"
+ MSG2="${CYAN} ................[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo && echo
+ else
+ echo -e ""
+ echo -e "${CLOCK}${GREEN}FLUX DAEMON SYNCING...${NC}"
+ f=0
+ start_sync=`date +%s`
+ while true
+ do
+ flux_block_height "$1"
+ LOCAL_BLOCK_HIGHT=$(${COIN_CLI} $1 getinfo 2> /dev/null | jq '.blocks' 2> /dev/null)
+ CONNECTIONS=$(${COIN_CLI} $1 getinfo 2> /dev/null | jq '.connections' 2> /dev/null)
+ LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+ if [[ "$LEFT" == "0" ]]; then
+ time_break='5'
+ else
+ time_break='20'
+ fi
+ if [[ $LOCAL_BLOCK_HIGHT == "" ]]; then
+ f=$((f+1))
+ LOCAL_BLOCK_HIGHT="N/A"
+ LEFT="N/A"
+ CONNECTIONS="N/A"
+ sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
+ sudo systemctl start zelcash > /dev/null 2>&1
+ NUM='60'
+ MSG1="Syncing progress => Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN} Failed: ${RED}$f${NC}"
+ MSG2=''
+ spinning_timer
+ flux_block_height "$1"
+ LOCAL_BLOCK_HIGHT=$(${COIN_CLI} $1 getinfo 2> /dev/null | jq '.blocks')
+ CONNECTIONS=$(${COIN_CLI} $1 getinfo 2> /dev/null | jq '.connections')
+ LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+ fi
+ NUM="$time_break"
+ MSG1="Syncing progress >> Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN} Failed: ${RED}$f${NC}"
+ MSG2=''
+ spinning_timer
+ if [[ "$EXPLORER_BLOCK_HIGHT" == "$LOCAL_BLOCK_HIGHT" ]]; then
+ echo -e "${GREEN} Duration: $((($(date +%s)-$start_sync)/60)) min. $((($(date +%s)-$start_sync) % 60)) sec. ${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ fi
+ done
+ fi
+}
+
+function import_config_file() {
+ if [[ -f $DATA_PATH/install_conf.json ]]; then
+ import_settings=$(cat $DATA_PATH/install_conf.json | jq -r '.import_settings')
+ #Daemon
+ bootstrap_url=$(cat $DATA_PATH/install_conf.json | jq -r '.bootstrap_url')
+ bootstrap_zip_del=$(cat $DATA_PATH/install_conf.json | jq -r '.bootstrap_zip_del')
+ use_old_chain=$(cat $DATA_PATH/install_conf.json | jq -r '.use_old_chain')
+ prvkey=$(cat $DATA_PATH/install_conf.json | jq -r '.prvkey')
+ outpoint=$(cat $DATA_PATH/install_conf.json | jq -r '.outpoint')
+ index=$(cat $DATA_PATH/install_conf.json | jq -r '.index')
+ #FluxOS
+ ZELID=$(cat $DATA_PATH/install_conf.json | jq -r '.zelid')
+ #Benchmark
+ thunder=$(cat $DATA_PATH/install_conf.json | jq -r '.thunder')
+ #WatchDog
+ fix_action=$(cat $DATA_PATH/install_conf.json | jq -r '.action')
+ flux_update=$(cat $DATA_PATH/install_conf.json | jq -r '.zelflux_update')
+ daemon_update=$(cat $DATA_PATH/install_conf.json | jq -r '.zelcash_update')
+ bench_update=$(cat $DATA_PATH/install_conf.json | jq -r '.zelbench_update')
+ node_label=$(cat $DATA_PATH/install_conf.json | jq -r '.node_label')
+ eps_limit=$(cat $DATA_PATH/install_conf.json | jq -r '.eps_limit')
+ discord=$(cat $DATA_PATH/install_conf.json | jq -r '.discord')
+ ping=$(cat $DATA_PATH/install_conf.json | jq -r '.ping')
+ telegram_alert=$(cat $DATA_PATH/install_conf.json | jq -r '.telegram_alert')
+ telegram_bot_token=$(cat $DATA_PATH/install_conf.json | jq -r '.telegram_bot_token')
+ telegram_chat_id=$(cat $DATA_PATH/install_conf.json | jq -r '.telegram_chat_id')
+ #UPnP
+ upnp_enabled=$(cat $DATA_PATH/install_conf.json | jq -r '.upnp_enabled')
+ upnp_port=$(cat $DATA_PATH/install_conf.json | jq -r '.upnp_port')
+ gateway_ip=$(cat $DATA_PATH/install_conf.json | jq -r '.gateway_ip')
+ if [[ "$1" != "silent" ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Install config:"
+ if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then
+ echo -e "${PIN}${CYAN} Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ else
+ if [[ "$import_settings" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Import installation configurations...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ fi
+ fi
+
+ if [[ "$use_old_chain" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Diuring re-installation old chain will be use....................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ else
+ if [[ "$bootstrap_url" == "0" || "$bootstrap_url" == "" || $bootstrap_url == "null" ]]; then
+ echo -e "${PIN}${CYAN} Use Flux daemon bootstrap from source build in script............[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Use Flux daemon bootstrap from own source........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ fi
+ if [[ "$bootstrap_zip_del" == "1" || -z "$bootstrap_zip_del" ]]; then
+ echo -e "${PIN}${CYAN} Remove Flux daemon bootstrap archive file........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Leave Flux daemon bootstrap archive file.........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ fi
+ fi
+
+ if [[ ! -z "$gateway_ip" && ! -z "$upnp_port" ]]; then
+ if [[ "$upnp_port" != "null" ]]; then
+ echo -e "${PIN}${CYAN} Enable UPnP configuration........................................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+
+ if [[ "$discord" != "" && "$discord" != "0" ]] || [[ "$telegram_alert" == '1' ]]; then
+ echo -e "${PIN}${CYAN} Enable watchdog notification.....................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Disable watchdog notification....................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ fi
+
+ if [[ "$thunder" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Enable thunder mode..............................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+ fi
+
+ fi
+ fi
+}
+function get_ip() {
+ WANIP=$(curl --silent -m 15 https://api4.my-ip.io/ip | tr -dc '[:alnum:].')
+ if [[ "$WANIP" == "" || "$WANIP" = *htmlhead* ]]; then
+ WANIP=$(curl --silent -m 15 https://checkip.amazonaws.com | tr -dc '[:alnum:].')
+ fi
+ if [[ "$WANIP" == "" || "$WANIP" = *htmlhead* ]]; then
+ WANIP=$(curl --silent -m 15 https://api.ipify.org | tr -dc '[:alnum:].')
+ fi
+ if [[ "$1" == "install" ]]; then
+ if [[ "$WANIP" == "" || "$WANIP" = *htmlhead* ]]; then
+ echo -e "${ARROW} ${CYAN}IP address could not be found, installation stopped .........[${X_MARK}${CYAN}]${NC}"
+ echo
+ exit
+ fi
+ string_limit_check_mark "IP: $WANIP ..........................................." "IP: ${GREEN}$WANIP${CYAN} ..........................................."
+ fi
+}
+function check_benchmarks() {
+ var_benchmark=$($BENCH_CLI getbenchmarks | jq ".$1")
+ limit=$2
+ if [[ $(echo "$limit>$var_benchmark" | bc) == "1" ]]; then
+ var_round=$(round "$var_benchmark" 2)
+ echo -e "${X_MARK} ${CYAN}$3 $var_round $4${NC}"
+ fi
+}
+function display_banner() {
+ echo -e "${BLUE}"
+ figlet -t -k "FLUXNODE"
+ figlet -t -k "INSTALLATION COMPLETED"
+ echo -e "${YELLOW}================================================================================================================================"
+ echo -e ""
+ if pm2 -v > /dev/null 2>&1; then
+ pm2_flux_status=$(pm2 info flux 2> /dev/null | grep 'status' | sed -r 's/│//gi' | sed 's/status.//g' | xargs)
+ if [[ "$pm2_flux_status" == "online" ]]; then
+ pm2_flux_uptime=$(pm2 info flux | grep 'uptime' | sed -r 's/│//gi' | sed 's/uptime//g' | xargs)
+ pm2_flux_restarts=$(pm2 info flux | grep 'restarts' | sed -r 's/│//gi' | xargs)
+ echo -e "${BOOK} ${CYAN}Pm2 Flux info => status: ${GREEN}$pm2_flux_status${CYAN}, uptime: ${GREEN}$pm2_flux_uptime${NC} ${SEA}$pm2_flux_restarts${NC}"
+ else
+ if [[ "$pm2_flux_status" != "" ]]; then
+ pm2_flux_restarts=$(pm2 info flux | grep 'restarts' | sed -r 's/│//gi' | xargs)
+ echo -e "${PIN} ${CYAN}PM2 Flux status: ${RED}$pm2_flux_status${NC}, restarts: ${RED}$pm2_flux_restarts${NC}"
+ fi
+ fi
+ echo -e ""
+ fi
+ echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE FLUX DAEMON.${NC}"
+ echo -e "${PIN} ${CYAN}Start Flux daemon: ${SEA}sudo systemctl start zelcash${NC}"
+ echo -e "${PIN} ${CYAN}Stop Flux daemon: ${SEA}sudo systemctl stop zelcash${NC}"
+ echo -e "${PIN} ${CYAN}Help list: ${SEA}${COIN_CLI} help${NC}"
+ echo
+ echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE BENCHMARK.${NC}"
+ echo -e "${PIN} ${CYAN}Get info: ${SEA}${BENCH_CLI} $1 getinfo${NC}"
+ echo -e "${PIN} ${CYAN}Check benchmark: ${SEA}${BENCH_CLI} $1 getbenchmarks${NC}"
+ echo -e "${PIN} ${CYAN}Restart benchmark: ${SEA}${BENCH_CLI} $1 restartnodebenchmarks${NC}"
+ echo -e "${PIN} ${CYAN}Stop benchmark: ${SEA}${BENCH_CLI} $1 stop${NC}"
+ echo -e "${PIN} ${CYAN}Start benchmark: ${SEA}sudo systemctl restart zelcash${NC}"
+ echo
+ echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE FLUX.${NC}"
+ echo -e "${PIN} ${CYAN}Summary info: ${SEA}pm2 info flux${NC}"
+ echo -e "${PIN} ${CYAN}Logs in real time: ${SEA}pm2 logs flux${NC}"
+ echo -e "${PIN} ${CYAN}Stop Flux: ${SEA}pm2 stop flux${NC}"
+ echo -e "${PIN} ${CYAN}Start Flux: ${SEA}pm2 start flux${NC}"
+ echo -e ""
+ if [[ "$WATCHDOG_INSTALL" == "1" ]]; then
+ echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE WATCHDOG.${NC}"
+ echo -e "${PIN} ${CYAN}Stop watchdog: ${SEA}pm2 stop watchdog${NC}"
+ echo -e "${PIN} ${CYAN}Start watchdog: ${SEA}pm2 start watchdog --watch${NC}"
+ echo -e "${PIN} ${CYAN}Restart watchdog: ${SEA}pm2 reload watchdog --watch${NC}"
+ echo -e "${PIN} ${CYAN}Error logs: ${SEA}~/watchdog/watchdog_error.log${NC}"
+ echo -e "${PIN} ${CYAN}Logs in real time: ${SEA}pm2 logs watchdog${NC}"
+ echo
+ echo -e "${PIN} ${RED}IMPORTANT: After installation check ${SEA}'pm2 list'${RED} if not work, type ${SEA}'source /home/$USER/.bashrc'${NC}"
+ echo -e ""
+ fi
+ echo -e "${PIN} ${CYAN}To access your frontend to Flux enter this in as your url: ${SEA}${WANIP}:${ZELFRONTPORT}${NC}"
+ echo -e "${YELLOW}===================================================================================================================[${GREEN}Duration: $((($(date +%s)-$start_install)/60)) min. $((($(date +%s)-$start_install) % 60)) sec.${YELLOW}]${NC}"
+ sleep 1
+ cd $HOME
+ exec bash
+}
+function create_swap() {
+ if [[ -z "$swapon" ]]; then
+ #echo -e "${YELLOW}Creating swap if none detected...${NC}" && sleep 1
+ MEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
+ gb=$(awk "BEGIN {print $MEM/1048576}")
+ GB=$(echo "$gb" | awk '{printf("%d\n",$1 + 0.5)}')
+ if [ "$GB" -lt 2 ]; then
+ (( swapsize=GB*2 ))
+ swap="$swapsize"G
+ elif [[ $GB -ge 2 ]] && [[ $GB -le 16 ]]; then
+ swap=4G
+ elif [[ $GB -gt 16 ]] && [[ $GB -lt 32 ]]; then
+ swap=2G
+ fi
+ if ! grep -q "swapfile" /etc/fstab; then
+ # if whiptail --yesno "No swapfile detected would you like to create one?" 8 54; then
+ sudo fallocate -l "$swap" /swapfile > /dev/null 2>&1
+ sudo chmod 600 /swapfile > /dev/null 2>&1
+ sudo mkswap /swapfile > /dev/null 2>&1
+ sudo swapon /swapfile > /dev/null 2>&1
+ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Created ${SEA}${swap}${YELLOW} swapfile${NC}"
+ fi
+ else
+ if [[ "$swapon" == "1" ]]; then
+ MEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
+ gb=$(awk "BEGIN {print $MEM/1048576}")
+ GB=$(echo "$gb" | awk '{printf("%d\n",$1 + 0.5)}')
+ if [ "$GB" -lt 2 ]; then
+ (( swapsize=GB*2 ))
+ swap="$swapsize"G
+ elif [[ $GB -ge 2 ]] && [[ $GB -le 16 ]]; then
+ swap=4G
+ elif [[ $GB -gt 16 ]] && [[ $GB -lt 32 ]]; then
+ swap=2G
+ fi
+ if ! grep -q "swapfile" /etc/fstab; then
+ sudo fallocate -l "$swap" /swapfile > /dev/null 2>&1
+ sudo chmod 600 /swapfile > /dev/null 2>&1
+ sudo mkswap /swapfile > /dev/null 2>&1
+ sudo swapon /swapfile > /dev/null 2>&1
+ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Created ${SEA}${swap}${YELLOW} swapfile${NC}"
+ fi
+ fi
+ fi
+ sleep 2
+}
+######### EDIT FUNCTION
+function daemon_reconfiguration(){
+ echo -e "${GREEN}Module: Flux Daemon Reconfiguration${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ config_veryfity
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Fill in all the fields that you want to replace${NC}"
+ sleep 2
+ skip_change='3'
+ zelnodeprivkey="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)"
+ sleep 1
+ zelnodeoutpoint="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3)"
+ sleep 1
+ zelnodeindex="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Output Index" 8 60 3>&1 1>&2 2>&3)"
+ sleep 1
+ if [[ "$zelnodeprivkey" == "" ]]; then
+ skip_change=$((skip_change-1))
+ echo -e "${ARROW} ${CYAN}Replace FluxNode Identity Key skipped....................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ if [[ "$zelnodeoutpoint" == "" ]]; then
+ skip_change=$((skip_change-1))
+ echo -e "${ARROW} ${CYAN}Replace FluxNode Collateral TX ID skipped ..................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ if [[ "$zelnodeindex" == "" ]]; then
+ skip_change=$((skip_change-1))
+ echo -e "${ARROW} ${CYAN}Replace FluxNode Output Index skipped......................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ if [[ "$skip_change" == "0" ]]; then
+ echo -e "${ARROW} ${YELLOW}All fields are empty changes skipped...${NC}"
+ echo
+ exit
+ fi
+ echo -e "${ARROW} ${CYAN}Stopping Flux daemon service...${NC}"
+
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
+ sudo fuser -k 16125/tcp > /dev/null 2>&1
+ else
+ SUDO_CMD="sudo"
+ sudo systemctl stop flux-watchdog > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop fluxd > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop fluxos > /dev/null 2>&1 && sleep 2
+ fi
+
+ if [[ "$zelnodeprivkey" != "" ]]; then
+ if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}Replace FluxNode Identity Key skipped....................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ $SUDO_CMD sed -i "s/$(grep -e zelnodeprivkey $FLUX_DAEMON_PATH/$CONFIG_FILE)/zelnodeprivkey=$zelnodeprivkey/" $FLUX_DAEMON_PATH/$CONFIG_FILE
+ if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}FluxNode Identity Key replaced successful................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ fi
+
+ if [[ "$zelnodeoutpoint" != "" ]]; then
+ if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}Replace FluxNode Collateral TX ID outpoint skipped ..................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ $SUDO_CMD sed -i "s/$(grep -e zelnodeoutpoint $FLUX_DAEMON_PATH/$CONFIG_FILE)/zelnodeoutpoint=$zelnodeoutpoint/" $FLUX_DAEMON_PATH/$CONFIG_FILE
+ if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}FluxNode Collateral TX ID replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ fi
+
+ if [[ "$zelnodeindex" != "" ]]; then
+ if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}Replace FluxNode Output Index skipped......................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ $SUDO_CMD sed -i "s/$(grep -w zelnodeindex $FLUX_DAEMON_PATH/$CONFIG_FILE)/zelnodeindex=$zelnodeindex/" $FLUX_DAEMON_PATH/$CONFIG_FILE
+ if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex $FLUX_DAEMON_PATH/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}FluxNode Output Index replaced successful..................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ fi
+ if [[ -z $FLUXOS_VERSION ]]; then
+ pm2 restart flux > /dev/null 2>&1
+ sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2
+ else
+ sudo systemctl start fluxos > /dev/null 2>&1 && sleep 2
+ sudo systemctl start fluxd > /dev/null 2>&1 && sleep 2
+ sudo systemctl restart fluxbenchd > /dev/null 2>&1 && sleep 2
+ sudo systemctl start flux-watchdog > /dev/null 2>&1 && sleep 2
+ fi
+ NUM='35'
+ MSG1='Restarting daemon service...'
+ MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo -e "" && echo -e ""
+}
+function replace_zelid() {
+ while true
+ do
+ new_zelid="$(whiptail --title "MULTITOOLBOX" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)"
+ if [ $(printf "%s" "$new_zelid" | wc -c) -eq "34" ] || [ $(printf "%s" "$new_zelid" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$new_zelid") ]; then
+ string_limit_check_mark "Zel ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Zel ID is not valid try again..........................................."
+ sleep 2
+ fi
+ done
+ if [[ $(grep -w $new_zelid $FLUXOS_PATH/config/userconfig.js) != "" ]]; then
+ echo -e "${ARROW} ${CYAN}Replace ZEL ID skipped............................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ config_builder "zelid" "$new_zelid" "ZEL ID" "fluxos"
+ #if [[ $(grep -w $new_zelid /home/$USER/zelflux/config/userconfig.js) != "" ]]; then
+ #echo -e "${ARROW} ${CYAN}ZEL ID replaced successful........................[${CHECK_MARK}${CYAN}]${NC}"
+ #fi
+ fi
+}
+
+function thunder_mode(){
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ -d $FLUX_BENCH_PATH ]]; then
+ sudo chown -R $USER:$USER $FLUX_BENCH_PATH > /dev/null 2>&1
+ else
+ mkdir -p $FLUX_BENCH_PATH > /dev/null 2>&1
+ fi
+ fi
+ if [[ -f $FLUX_BENCH_PATH/fluxbench.conf ]]; then
+ if [[ $(grep -e "thunder" $FLUX_BENCH_PATH/fluxbench.conf) == "" ]]; then
+ config_builder "thunder" "1" "Thunder Mode" "benchmark"
+ else
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD sed -i "/$(grep -e "thunder" $FLUX_BENCH_PATH/fluxbench.conf)/d" $FLUX_BENCH_PATH/fluxbench.conf > /dev/null 2>&1
+ echo -e "${ARROW}${GREEN} [BenchD] ${CYAN}Thunder Mode disabled successful${NC}" "${CHECK_MARK}"
+ fi
+ else
+ config_builder "thunder" "1" "Thunder Mode" "benchmark"
+ fi
+ if [[ "$1" == "" ]]; then
+ echo -e "${ARROW}${GREEN} [BenchD] ${CYAN}Restarting service... ${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo systemctl restart zelcash > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxd > /dev/null 2>&1
+ sudo systemctl restart fluxbenchd > /dev/null 2>&1
+ fi
+ fi
+
+}
+
+function development_mode(){
+ if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep "development: 'false'") != "" ]] || [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep "development: false") ]]; then
+ echo -e "${ARROW}${GREEN} [FluxOS] ${CYAN}Enabling development mode... ${NC}"
+ config_builder "development" "true" "Development Mode" "fluxos"
+ cd $FLUXOS_PATH
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD git checkout development && git pull > /dev/null 2>&1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ pm2 restart flux > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxos > /dev/null 2>&1
+ fi
+ else
+ echo -e "${ARROW}${GREEN} [FluxOS] ${CYAN}Disabling development mode... ${NC}"
+ config_builder "development" "false" "Development Mode" "fluxos"
+ cd $FLUXOS_PATH
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD git checkout master && git pull > /dev/null 2>&1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ pm2 restart flux > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxos > /dev/null 2>&1
+ fi
+ fi
+}
+
+function fluxos_reconfiguration {
+ echo -e "${GREEN}Module: FluxOS reconfiguration${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ if ! [[ -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ echo -e "${WORNING} ${CYAN}FluxOS userconfig.js not exist, operation aborted${NC}"
+ echo -e ""
+ exit
+ fi
+ CHOICE=$(
+ whiptail --title "FluxOS Configuration" --menu "Make your choice" 15 40 6 \
+ "1)" "Replace Flux/SSP ID" \
+ "2)" "Enable/Disable thunder mode" \
+ "3)" "Enable/Disable development mode" \
+ "4)" "Blocked Ports Management" \
+ "5)" "Blocked Repositories Management" \
+ "6)" "FluxOS config backup" \
+ "7)" "FluxOS config restore" 3>&2 2>&1 1>&3
+ )
+ case $CHOICE in
+ "1)")
+ replace_zelid
+ ;;
+ "2)")
+ thunder_mode
+ ;;
+ "3)")
+ development_mode
+ ;;
+ "4)")
+ blocked_ports
+ ;;
+ "5)")
+ blocked_repositories
+ ;;
+ "6)")
+ fluxosConfigBackup
+ ;;
+ "7)")
+ fluxosConfigRestore
+ ;;
+ esac
+}
+######### BOOTSTRAP SECTION ############################
+function tar_file_unpack() {
+ local TARFILE=$1
+ local DEST_DIR=$2
+ local MIME_TYPE=$(file -b --mime-type $TARFILE)
+ local GZIP=""
+ # tar is application/x-tar
+ [[ "$MIME_TYPE" == "application/gzip" ]] && GZIP="-z"
+ echo -e "${ARROW} ${CYAN}Unpacking daemon bootstrap please be patient...${NC}"
+ pv $TARFILE | sudo tar $GZIP -x -C $DEST_DIR
+ if [[ -n $FLUXOS_VERSION ]]; then
+ sudo chown -R fluxd:fluxd $FLUX_DAEMON_PATH > /dev/null 2>&1
+ fi
+}
+function check_tar() {
+ echo -e "${ARROW} ${CYAN}Checking file integrity...${NC}"
+ if sudo tar -tf "$1" &>/dev/null; then
+ echo -e "${ARROW} ${CYAN}Bootstrap file is valid.................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
+ sudo rm -rf $1
+ fi
+}
+function tar_file_pack() {
+ echo -e "${ARROW} ${CYAN}Creating bootstrap archive file...${NC}"
+ tar -czf - $1 | (pv -p --timer --rate --bytes > $2) 2>&1
+}
+function cdn_speedtest() {
+ if [[ -z $1 || "$1" == "0" ]]; then
+ BOOTSTRAP_FILE="flux_explorer_bootstrap.tar.gz"
+ else
+ BOOTSTRAP_FILE="$1"
+ fi
+ if [[ -z $2 ]]; then
+ dTime="5"
+ else
+ dTime="$2"
+ fi
+ if [[ -z $3 ]]; then
+ rand_by_domain=("5" "6" "7" "8" "9" "10" "11" "12")
+ else
+ msg="$3"
+ shift
+ shift
+ rand_by_domain=("$@")
+ custom_url="1"
+ fi
+ size_list=()
+ i=0
+ len=${#rand_by_domain[@]}
+ echo -e "${ARROW} ${CYAN}Running quick download speed test for ${BOOTSTRAP_FILE}, Servers: ${GREEN}$len${NC}"
+ start_test=`date +%s`
+ while [ $i -lt $len ];
+ do
+ if [[ "$custom_url" == "1" ]]; then
+ testing=$(curl -L -m ${dTime} ${rand_by_domain[$i]}${BOOTSTRAP_FILE} --output testspeed -fail --silent --show-error 2>&1)
+ else
+ testing=$(curl -L -m ${dTime} http://cdn-${rand_by_domain[$i]}.runonflux.io/apps/fluxshare/getfile/${BOOTSTRAP_FILE} --output testspeed -fail --silent --show-error 2>&1)
+ fi
+ testing_size=$(grep -Po "\d+" <<< "$testing" | paste - - - - | awk '{printf "%d\n",$3}')
+ mb=$(bc <<<"scale=2; $testing_size / 1048576 / $dTime" | awk '{printf "%2.2f\n", $1}')
+ if [[ "$custom_url" == "1" ]]; then
+ domain=$(sed -e 's|^[^/]*//||' -e 's|/.*$||' <<< ${rand_by_domain[$i]})
+ echo -e " ${RIGHT_ANGLE} ${GREEN}URL - ${YELLOW}${domain}${GREEN} - Bits Downloaded: ${YELLOW}$testing_size${NC} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+ else
+ echo -e " ${RIGHT_ANGLE} ${GREEN}cdn-${YELLOW}${rand_by_domain[$i]}${GREEN} - Bits Downloaded: ${YELLOW}$testing_size${NC} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+ fi
+ size_list+=($testing_size)
+ if [[ "$testing_size" == "0" ]]; then
+ failed_counter=$(($failed_counter+1))
+ fi
+ i=$(($i+1))
+ done
+ rServerList=$((${#size_list[@]}-$failed_counter))
+ echo -e "${ARROW} ${CYAN}Valid servers: ${GREEN}${rServerList} ${CYAN}- Duration: ${GREEN}$((($(date +%s)-$start_test)/60)) min. $((($(date +%s)-$start_test) % 60)) sec.${NC}"
+ sudo rm -rf testspeed > /dev/null 2>&1
+ if [[ "$rServerList" == "0" ]]; then
+ server_offline="1"
+ return
+ fi
+ arr_max=$(printf '%s\n' "${size_list[@]}" | sort -n | tail -1)
+ for i in "${!size_list[@]}"; do
+ [[ "${size_list[i]}" == "$arr_max" ]] &&
+ max_indexes+=($i)
+ done
+ server_index=${rand_by_domain[${max_indexes[0]}]}
+ if [[ "$custom_url" == "1" ]]; then
+ BOOTSTRAP_URL="$server_index"
+ else
+ BOOTSTRAP_URL="http://cdn-${server_index}.runonflux.io/apps/fluxshare/getfile/"
+ fi
+ DOWNLOAD_URL="${BOOTSTRAP_URL}${BOOTSTRAP_FILE}"
+ #Print the results
+ mb=$(bc <<<"scale=2; $arr_max / 1048576 / $dTime" | awk '{printf "%2.2f\n", $1}')
+ if [[ "$custom_url" == "1" ]]; then
+ domain=$(sed -e 's|^[^/]*//||' -e 's|/.*$||' <<< ${server_index})
+ echo -e "${ARROW} ${CYAN}Best server is: ${YELLOW}${domain} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+ else
+ echo -e "${ARROW} ${CYAN}Best server is: ${GREEN}cdn-${YELLOW}${rand_by_domain[${max_indexes[0]}]} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}"
+ fi
+ #echo -e "${CHECK_MARK} ${GREEN}Fastest Server: ${YELLOW}$DOWNLOAD_URL${NC}"
+}
+
+function download_and_unpack() {
+ FILE_SIZE=$(curl -sSLI "$DOWNLOAD_URL" | grep -i "content-length" | tail -1 | awk '{print $2}' | tr -d '\r')
+ if [ -z "$FILE_SIZE" ]; then
+ echo "⚠️ Unable to retrieve file size. Progress will be approximate."
+ FILE_SIZE=0
+ fi
+ # Record the start time
+ START_TIME=$(date +%s)
+ # Download and extract with progress using pigz
+ echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$DOWNLOAD_URL ${NC}"
+ if curl -sSL "$DOWNLOAD_URL" | pv -s "$FILE_SIZE" | pigz -dc | tar -x -C "$FLUX_DAEMON_PATH"; then
+ # Record the end time
+ END_TIME=$(date +%s)
+ ELAPSED_TIME=$((END_TIME - START_TIME))
+ HOURS=$((ELAPSED_TIME / 3600))
+ MINUTES=$(( (ELAPSED_TIME % 3600) / 60 ))
+ SECONDS=$((ELAPSED_TIME % 60))
+ # Print completion message with formatted time
+ echo -e "${ARROW} ${CYAN}Download and extraction completed in ${GREEN}${HOURS}h ${MINUTES}m ${SECONDS}s${NC}"
+ if [[ -n $FLUXOS_VERSION ]]; then
+ sudo chown -R fluxd:fluxd $FLUX_DAEMON_PATH > /dev/null 2>&1
+ fi
+ else
+ echo -e "❌ Error: Download or extraction failed."
+ clean
+ echo -e ""
+ exit 1
+ fi
+}
+
+function bootstrap_new() {
+ echo -e "${ARROW} ${YELLOW}Restore daemon chain from bootstrap${NC}"
+ if ! wget --version > /dev/null 2>&1 ; then
+ sudo apt install -y wget > /dev/null 2>&1 && sleep 2
+ fi
+ if ! pigz --version > /dev/null 2>&1 ; then
+ sudo apt install -y pigz > /dev/null 2>&1 && sleep 2
+ fi
+ if ! wget --version > /dev/null 2>&1 ; then
+ echo -e "${WORNING} ${CYAN}Wget not installed, operation aborted.. ${NC}" && sleep 1
+ echo -e ""
+ return
+ fi
+ if ! pigz --version > /dev/null 2>&1 ; then
+ echo -e "${WORNING} ${CYAN}Pigz not installed, operation aborted.. ${NC}" && sleep 1
+ echo -e ""
+ return
+ fi
+ Mode="$1"
+
+ if [[ ! -f $DATA_PATH/install_conf.json ]]; then
+ bootstrap_manual
+ if [[ "$Mode" != "install" && "$server_offline" == "0" && $CHOICE == "1)" ]]; then
+ start_service
+ fi
+ return
+ fi
+
+ if [[ "$bootstrap_url" == "0" || "$bootstrap_url" == "" || "$bootstrap_url" == "null" ]]; then
+ cdn_speedtest "0" "6"
+ if [[ "$server_offline" == "1" ]]; then
+ echo -e "${WORNING} ${CYAN}All Bootstrap server offline, operation aborted.. ${NC}" && sleep 1
+ echo -e ""
+ return 1
+ fi
+ if [[ "$Mode" != "install" ]]; then
+ stop_service
+ fi
+ download_and_unpack
+ else
+ if [[ "$Mode" != "install" ]]; then
+ stop_service
+ fi
+ DOWNLOAD_URL="$bootstrap_url"
+ download_and_unpack
+ fi
+
+ if [[ "$Mode" != "install" ]]; then
+ start_service
+ fi
+}
+
+##### STREAM SECTION
+# Clean data directories
+clean() {
+ local silent_mode=$1
+ cd $DEST_PATH 2>/dev/null
+ sudo rm -rf blocks chainstate determ_zelnodes 2>/dev/null
+ cd 2>/dev/null
+ [ "$silent_mode" != "true" ] && echo -e "🧹 Cleaned data directories."
+}
+
+# Stop services
+stop_xservices() {
+ local silent_mode=$1
+ [ "$silent_mode" != "true" ] && echo -e "⏹️ Stopping services..."
+ sudo systemctl stop "$FLUXD_SERVICE"
+ if [ -n "$FLUXOS_VERSION" ]; then
+ sudo systemctl stop "$WATCHDOG_SERVICE"
+ else
+ pm2 stop watchdog
+ fi
+}
+
+# Start services
+start_xservices() {
+ local silent_mode=$1
+ [ "$silent_mode" != "true" ] && echo -e "▶️ Starting services..."
+ sudo systemctl start "$FLUXD_SERVICE"
+ if [ -n "$FLUXOS_VERSION" ]; then
+ sudo systemctl start "$WATCHDOG_SERVICE"
+ else
+ pm2 start watchdog --watch
+ fi
+}
+
+# Get local machine's IP address
+get_local_ip() {
+ local silent_mode=$1
+ [ "$silent_mode" != "true" ] && echo -e "🌐 Getting local LAN IP address..."
+ local_ip=$(upnpc -l 2>/dev/null | awk -F': ' '/Local LAN ip address/ {print $2}')
+
+ if [ -z "$local_ip" ]; then
+ [ "$silent_mode" != "true" ] && echo -e "❌ Local LAN IP not found." >&2
+ exit 1
+ else
+ [ "$silent_mode" != "true" ] && echo -e "✅ Local LAN IP: $local_ip"
+ fi
+
+ echo "$local_ip"
+}
+
+# Discover UPnP nodes and group them by tier
+discover_upnp_nodes() {
+ local silent_mode=$1
+ [ "$silent_mode" != "true" ] && echo -e "🔍 Discovering UPnP nodes..."
+
+ local_ip=$(get_local_ip "$silent_mode")
+ if [ -n "$local_ip" ]; then
+ local raw_nodes=($(upnpc -l 2>/dev/null | \
+ awk '/Flux_Backend_API/ && !/Flux_Backend_API_SSL/ {print $3}' | \
+ awk -F'->' '{print $2}' | \
+ grep -v "$local_ip" | \
+ sort -u))
+
+ unset node_map
+ declare -g -A node_map
+ tiers=("stratus_new" "nimbus_new" "cumulus_new") # Priority tiers
+
+ for node in "${raw_nodes[@]}"; do
+ [ "$silent_mode" != "true" ] && echo -e "🛠️ Checking tier information for node: $node"
+ response=$(curl -s --max-time 5 -X GET "http://${node}/flux/nodetier")
+ tier=$(echo "$response" | jq -r '.data' 2>/dev/null)
+ status=$(echo "$response" | jq -r '.status' 2>/dev/null)
+
+ if [ "$status" == "success" ] && [ -n "$tier" ]; then
+ if [[ " ${tiers[@]} " =~ " $tier " ]]; then
+ [ "$silent_mode" != "true" ] && echo -e "✨ Node $node belongs to tier: $tier"
+ node_map["$tier"]+="$node "
+ fi
+ else
+ [ "$silent_mode" != "true" ] && echo -e "❌ Node $node failed tier verification." >&2
+ fi
+ done
+
+ # Print grouped nodes by tier in order of priority
+ if [ ${#node_map[@]} -gt 0 ]; then
+ [ "$silent_mode" != "true" ] && echo -e "📊 Nodes grouped by tier:"
+ for tier in "${tiers[@]}"; do
+ if [ -n "${node_map[$tier]}" ]; then
+ [ "$silent_mode" != "true" ] && echo " - $tier: ${node_map[$tier]}"
+ fi
+ done
+ return 0
+ else
+ [ "$silent_mode" != "true" ] && echo -e "🚫 No valid nodes found for any tier." >&2
+ return 1
+ fi
+ else
+ return 1
+ fi
+}
+
+# Stream chain locally from prioritized nodes
+stream_chain_locally() {
+ local silent_mode=$1
+ [ "$silent_mode" != "true" ] && echo -e "📂 Starting local chain streaming..."
+ for tier in "stratus_new" "nimbus_new" "cumulus_new"; do
+ nodes=(${node_map[$tier]})
+ for node in "${nodes[@]}"; do
+ [ "$silent_mode" != "true" ] && echo -e "📡 Attempting to stream chain from node: $node"
+ preparation=$(curl -sSL http://${node}/flux/streamchainpreparation | jq -r '.status' 2>/dev/null)
+ if [ $preparation != "success" ]; then
+ continue
+ fi
+ curl -s -X POST "http://${node}/flux/streamchain" | tar -xv -C "$DEST_PATH"
+ if [ $? -eq 0 ]; then
+ [ "$silent_mode" != "true" ] && echo -e "✅ Successfully streamed chain from $node"
+ if [ -n "$FLUXOS_VERSION" ]; then
+ sudo chown -R fluxd:fluxd "$DEST_PATH"
+ fi
+ return 0
+ else
+ [ "$silent_mode" != "true" ] && echo -e "❌ Failed to stream chain from $node" >&2
+ clean "$silent_mode"
+ fi
+ done
+ done
+
+ [ "$silent_mode" != "true" ] && echo -e "🚫 Failed to stream chain locally from all nodes" >&2
+ clean "$silent_mode"
+ return 1
+}
+######################################################################################################
+function bootstrap_manual() {
+ discover_upnp_nodes "true"
+ if [ $? -eq 0 ]; then
+ CHOICE=$(
+ whiptail --title "FluxNode Installation" --menu "Choose a method how to get bootstrap file" 10 47 2 \
+ "1)" "Download from CDN servers" \
+ "2)" "Stream from local network" 3>&2 2>&1 1>&3
+ )
+ else
+ CHOICE="1)"
+ fi
+
+ case $CHOICE in
+ "1)")
+ #server_list=("http://cdn-11.runonflux.io/apps/fluxshare/getfile/" "http://cdn-12.runonflux.io/apps/fluxshare/getfile/" "http://cdn-13.runonflux.io/apps/fluxshare/getfile/" "http://cdn-10.runonflux.io/apps/fluxshare/getfile/")
+ #cdn_speedtest "0" "8" "${server_list[@]}"
+ cdn_speedtest "0" "6"
+ if [[ "$server_offline" == "1" ]]; then
+ echo -e "${WORNING} ${CYAN}All Bootstrap server offline, operation aborted.. ${NC}" && sleep 1
+ echo -e ""
+ return 1
+ fi
+ DB_HIGHT=$(curl -sSL -m 10 "${BOOTSTRAP_URL}flux_explorer_bootstrap.json" | jq -r '.block_height' 2>/dev/null)
+ if [[ "$DB_HIGHT" == "" ]]; then
+ DB_HIGHT=$(curl -sSL -m 10 "${BOOTSTRAP_URL}flux_explorer_bootstrap.json" | jq -r '.block_height' 2>/dev/null)
+ fi
+ if [[ "$DB_HIGHT" != "" ]]; then
+ echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
+ fi
+ if [[ "$Mode" != "install" ]]; then
+ stop_service
+ fi
+ download_and_unpack
+ ;;
+ "2)")
+ if [ -n "$FLUXOS_VERSION" ]; then
+ DEST_PATH="/dat/var/lib/fluxd"
+ FLUXD_SERVICE="fluxd"
+ WATCHDOG_SERVICE="flux-watchdog"
+ else
+ DEST_PATH="$HOME/.flux"
+ FLUXD_SERVICE="zelcash"
+ fi
+
+ SECONDS=0 # Start timer
+ silent_mode="false"
+
+ discover_upnp_nodes "$silent_mode"
+ if [ $? -eq 0 ]; then
+ [ "$silent_mode" != "true" ] && echo -e "✅ Successfully discovered and grouped nodes by tier."
+ # Stop services before streaming
+ stop_xservices "$silent_mode"
+ # Clean old data
+ clean "$silent_mode"
+ # Stream the chain locally
+ stream_chain_locally "$silent_mode"
+ if [ $? -ne 0 ]; then
+ [ "$silent_mode" != "true" ] && echo -e "❌ Chain streaming failed."
+ # Start services even if chain streaming fails
+ start_xservices "$silent_mode"
+ echo -e ""
+ exit 1
+ fi
+ # Start services after successful streaming
+ start_xservices "$silent_mode"
+ # Calculate elapsed time
+ elapsed=$SECONDS
+ hours=$((elapsed / 3600))
+ minutes=$(((elapsed % 3600) / 60))
+ seconds=$((elapsed % 60))
+ [ "$silent_mode" != "true" ] && echo -e "🎉 Chain streaming process completed successfully."
+ [ "$silent_mode" != "true" ] && echo -e "⏱️ Total execution time: ${hours}h ${minutes}m ${seconds}s."
+ echo -e ""
+ else
+ [ "$silent_mode" != "true" ] && echo -e "❌ Failed to discover and verify nodes."
+ echo -e ""
+ exit 1
+ fi
+ ;;
+ esac
+}
+function bootstrap_local() {
+ local BOOTSTRAP_STEM="flux_explorer_bootstrap"
+ local BOOTSTRAP_FILES=($(ls $DATA_PATH/$BOOTSTRAP_STEM.{tar,tar.gz} 2>/dev/null))
+
+ if [ "$BOOTSTRAP_FILES" -a ${#BOOTSTRAP_FILES[@]} ]; then
+ # we take the first bootstrap file
+ FILE_PATH="$BOOTSTRAP_FILES"
+ echo -e "${ARROW} ${CYAN}Local bootstrap file detected...${NC}"
+ check_tar "$FILE_PATH"
+ if [ -f "$FILE_PATH" ]; then
+ if [[ "$Mode" != "install" ]]; then
+ stop_service
+ fi
+ tar_file_unpack "$FILE_PATH" "$FLUX_DAEMON_PATH"
+ fi
+ fi
+}
+function flux_chain_date_wipe() {
+ if [[ -e $FLUX_DAEMON_PATH/blocks ]] && [[ -e $FLUX_DAEMON_PATH/chainstate ]]; then
+ echo -e "${ARROW} ${CYAN}Removing blocks, chainstate, determ_zelnodes directories...${NC}"
+ sudo rm -rf $FLUX_DAEMON_PATH/blocks $FLUX_DAEMON_PATH/chainstate $FLUX_DAEMON_PATH/determ_zelnodes > /dev/null 2>&1
+ fi
+}
+function stop_service() {
+ echo -e "${ARROW} ${CYAN}Stopping Flux daemon service${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ pm2 stop watchdog > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+ else
+ sudo systemctl stop flux-watchdog > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop fluxd > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop fluxbenchd > /dev/null 2>&1
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+ fi
+ flux_chain_date_wipe
+}
+function start_service() {
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo systemctl start zelcash > /dev/null 2>&1 && sleep 2
+ else
+ sudo systemctl start fluxd > /dev/null 2>&1 && sleep 2
+ sudo systemctl start fluxbenchd > /dev/null 2>&1
+ fi
+ NUM='35'
+ MSG1='Starting Flux daemon service...'
+ MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo -e "" && echo -e ""
+ if [[ -z $FLUXOS_VERSION ]]; then
+ pm2 restart flux > /dev/null 2>&1 && sleep 2
+ pm2 start watchdog --watch > /dev/null 2>&1 && sleep 2
+ else
+ sudo systemctl restart fluxos > /dev/null 2>&1 && sleep 2
+ sudo systemctl start flux-watchdog > /dev/null 2>&1 && sleep 2
+ fi
+}
+######### INSTALLATION SECTION ############################
+function install_mongod() {
+ source_set=0
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Removing any instances of Mongodb...${NC}"
+ sudo systemctl stop mongod > /dev/null 2>&1
+ sudo apt remove -f mongod* -y > /dev/null 2>&1
+ sudo apt purge --allow-change-held-packages mongod* -y > /dev/null 2>&1
+ sudo apt autoremove -y > /dev/null 2>&1
+ sudo rm /etc/apt/sources.list.d/mongodb*.list > /dev/null 2>&1
+ sudo rm /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Mongodb installing...${NC}"
+ avx_check=$(cat /proc/cpuinfo | grep -o avx | head -n1)
+ os_version=$(lsb_release -rs | tr -d '.')
+ architecture=$(dpkg --print-architecture)
+
+ if [[ $(lsb_release -d) = *Debian* ]]; then
+ os_name="Debian"
+ fi
+
+ if [[ $(lsb_release -d) = *Ubuntu* ]]; then
+ os_name="Ubuntu"
+ fi
+ #Ubuntu MongoDB 4.4
+ if [[ "$avx_check" == "" && "$os_name" == "Ubuntu" && "$architecture" == "amd64" && "$os_version" -le "2010" ]] || [[ "$os_name" == "Ubuntu" && "$architecture" == "arm64" && "$os_version" -le "2010" ]]; then
+ curl -fsSL https://pgp.mongodb.com/server-4.4.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
+ source_set=2
+ fi
+ #Debian MongoDB 4.4
+ if [[ "$avx_check" == "" && "$os_name" == "Debian" && "$architecture" == "amd64" && "$os_version" -le "9" ]] || [[ "$os_name" == "Debian" && "$architecture" == "arm64" && "$os_version" -le "9" ]]; then
+ curl -fsSL https://pgp.mongodb.com/server-4.4.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
+ source_set=2
+ fi
+ #ARM MongoDB 7.0
+ if [[ "$architecture" == "arm64" ]]; then
+ if [[ "$os_name" == "Debian" && "$os_version" -ge "12" ]]; then
+ curl -fsSL https://pgp.mongodb.com/server-7.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list > /dev/null 2>&1
+ source_set=1
+ fi
+ if [[ "$os_name" == "Ubuntu" && "$os_version" -ge "2304" ]]; then
+ curl -fsSL https://pgp.mongodb.com/server-7.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list > /dev/null 2>&1
+ source_set=1
+ fi
+ fi
+ #AVX with AMD64
+ if [[ "$avx_check" != "" && "$architecture" == "amd64" ]]; then
+ if [[ "$os_name" == "Ubuntu" ]]; then
+ if [[ "$os_version" -ge "2004" ]]; then
+ if [[ "$os_version" == "2004" ]]; then
+ codename="focal"
+ else
+ codename="jammy"
+ fi
+ curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu ${codename}/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list > /dev/null 2>&1
+ source_set=1
+ else
+ curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list > /dev/null 2>&1
+ source_set=1
+ fi
+ fi
+ if [[ "$os_name" == "Debian" ]]; then
+ if [[ "$os_version" -le "9" ]]; then
+ curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list > /dev/null 2>&1
+ source_set=1
+ else
+ curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/7.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list > /dev/null 2>&1
+ source_set=1
+ fi
+ fi
+ fi
+ if [[ "$source_set" == "0" ]]; then
+ echo -e "${WORNING} ${RED}OS type $(lsb_release -si) not supported..${NC}"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+ fi
+ sudo apt-get update -y > /dev/null 2>&1
+ if [[ "$source_set" == "2" ]]; then
+ sudo apt install -y mongodb-org=4.4.18 mongodb-org-server=4.4.18 mongodb-org-shell=4.4.18 mongodb-org-mongos=4.4.18 mongodb-org-tools=4.4.18 > /dev/null 2>&1 && sleep 2
+ echo "mongodb-org hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-server hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-shell hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-mongos hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-tools hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ else
+ DEBIAN_FRONTEND=noninteractive sudo apt-get --yes install mongodb-org > /dev/null 2>&1
+ fi
+ sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1
+ sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
+ sudo systemctl enable mongod > /dev/null 2>&1
+ sudo systemctl start mongod > /dev/null 2>&1
+ if mongod --version > /dev/null 2>&1; then
+ string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
+ echo
+ else
+ string_limit_x_mark "MongoDB was not installed................................."
+ echo
+ fi
+}
+function install_nodejs() {
+ echo -e "${ARROW} ${YELLOW}Removing any instances of Nodejs...${NC}"
+ n-uninstall -y > /dev/null 2>&1 && sleep 1
+ rm -rf ~/n
+ sudo apt-get remove nodejs npm nvm -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get purge nodejs nvm -y > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /usr/local/bin/npm
+ sudo rm -rf /usr/local/share/man/man1/node*
+ sudo rm -rf /usr/local/lib/dtrace/node.d
+ sudo rm -rf ~/.npm
+ sudo rm -rf ~/.nvm
+ sudo rm -rf ~/.pm2
+ sudo rm -rf ~/.node-gyp
+ sudo rm -rf /opt/local/bin/node
+ sudo rm -rf opt/local/include/node
+ sudo rm -rf /opt/local/lib/node_modules
+ sudo rm -rf /usr/local/lib/node*
+ sudo rm -rf /usr/local/include/node*
+ sudo rm -rf /usr/local/bin/node*
+ echo -e "${ARROW} ${YELLOW}Nodejs installing...${NC}"
+ curl -SsL -m 10 https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash > /dev/null 2>&1
+ . ~/.profile
+ . ~/.bashrc
+ sleep 1
+ nvm install 20.9.0 > /dev/null 2>&1
+ if node -v > /dev/null 2>&1; then
+ string_limit_check_mark "Nodejs $(node -v) installed................................." "Nodejs ${GREEN}$(node -v)${CYAN} installed................................."
+ echo
+ else
+ string_limit_x_mark "Nodejs was not installed................................."
+ echo
+ fi
+}
+function start_install() {
+ start_install=`date +%s`
+ sudo echo -e "$USER ALL=(ALL) NOPASSWD:ALL" | sudo EDITOR='tee -a' visudo
+ if jq --version > /dev/null 2>&1; then
+ echo -e ""
+ else
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}"
+ sudo apt install jq -y > /dev/null 2>&1
+ if jq --version > /dev/null 2>&1; then
+ string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................."
+ echo
+ else
+ string_limit_x_mark "JQ was not installed................................."
+ echo
+ exit
+ fi
+ fi
+ if [ "$USER" = "root" ]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}root${CYAN}, please switch to the username you just created.${NC}"
+ sleep 4
+ exit
+ fi
+ start_dir=$(pwd)
+ correct_dir="/home/$USER"
+ echo -e "${ARROW} ${YELLOW}Checking directory....${NC}"
+ if [[ "$start_dir" == "$correct_dir" ]]; then
+ echo -e "${ARROW} ${CYAN}Correct directory ${GREEN}$(pwd)${CYAN} ................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${ARROW} ${CYAN}Bad directory switching...${NC}"
+ cd
+ echo -e "${ARROW} ${CYAN}Current directory ${GREEN}$(pwd)${CYAN}${NC}"
+ fi
+ sleep 1
+ import_config_file
+ if [[ -z "$index" || -z "$outpoint" || -z "$prvkey" ]]; then
+ import_date
+ else
+ if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" && "$ZELID" != "" ]]; then
+ IMPORT_ZELCONF="1"
+ IMPORT_ZELID="1"
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Install conf settings:${NC}"
+ zelnodeprivkey="$prvkey"
+ echo -e "${PIN}${CYAN} Identity Key = ${GREEN}$zelnodeprivkey${NC}" && sleep 1
+ zelnodeoutpoint="$outpoint"
+ echo -e "${PIN}${CYAN} Collateral TX ID = ${GREEN}$zelnodeoutpoint${NC}" && sleep 1
+ zelnodeindex="$index"
+ echo -e "${PIN}${CYAN} Output Index = ${GREEN}$zelnodeindex${NC}" && sleep 1
+ if [[ "$ZELID" != "" ]]; then
+ echo -e "${PIN}${CYAN} Zel ID = ${GREEN}$ZELID${NC}" && sleep 1
+ fi
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Watchdog conf settings:${NC}"
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Label = ${GREEN}Enabled${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Label = ${RED}Disabled${NC}" && sleep 1
+ fi
+ if [[ "$eps_limit" != "" && "$eps_limit" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Tier_eps_min = ${GREEN}$eps_limit${NC}"
+ fi
+ if [[ "$discord" != "" && "$discord" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Discord alert = ${GREEN}Enabled${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Discord alert = ${RED}Disabled${NC}" && sleep 1
+ fi
+ if [[ "$ping" != "" && "$ping" != "0" ]]; then
+ if [[ "$discord" != "" && "$discord" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Discord ping = ${GREEN}Enabled${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Discord ping = ${RED}Disabled${NC}" && sleep 1
+ fi
+ fi
+ if [[ "$telegram_alert" != "" && "$telegram_alert" != "0" ]]; then
+ echo -e "${PIN}${CYAN} Telegram alert = ${GREEN}Enabled${NC}" && sleep 1
+ else
+ echo -e "${PIN}${CYAN} Telegram alert = ${RED}Disabled${NC}" && sleep 1
+ fi
+ if [[ "$telegram_alert" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Telegram bot token = ${GREEN}$telegram_alert${NC}" && sleep 1
+ fi
+ if [[ "$telegram_alert" == "1" ]]; then
+ echo -e "${PIN}${CYAN} Telegram chat id = ${GREEN}$telegram_chat_id${NC}" && sleep 1
+ fi
+ echo -e ""
+ fi
+ fi
+}
+function install_packages() {
+ echo -e "${ARROW} ${YELLOW}Installing Packages...${NC}"
+ if [[ $(lsb_release -d) = *Debian* ]] && [[ $(lsb_release -d) = *9* ]]; then
+ sudo apt-get install dirmngr apt-transport-https -y > /dev/null 2>&1
+ fi
+ if ! dirmngr --v > /dev/null 2>&1; then
+ sudo apt install dirmngr -y > /dev/null 2>&1
+ fi
+ sudo apt-get install software-properties-common ca-certificates -y > /dev/null 2>&1
+ sudo apt-get update -y > /dev/null 2>&1
+ sudo apt-get --with-new-pkgs upgrade -y > /dev/null 2>&1
+ sudo apt-get install nano htop pwgen ufw figlet tmux jq zip gzip pv unzip git -y > /dev/null 2>&1
+ sudo apt-get install build-essential libtool pkg-config -y > /dev/null 2>&1
+ sudo apt-get install libc6-dev m4 g++-multilib -y > /dev/null 2>&1
+ sudo apt-get install autoconf ncurses-dev python python-zmq -y > /dev/null 2>&1
+ sudo apt-get install wget curl bc bsdmainutils automake fail2ban -y > /dev/null 2>&1
+ sudo apt-get remove sysbench -y > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Packages complete...${NC}"
+}
+function pm2_install(){
+ tmux kill-server > /dev/null 2>&1 && sleep 1
+ echo -e "${ARROW} ${CYAN}PM2 installing...${NC}"
+ npm install pm2@latest -g > /dev/null 2>&1
+ if pm2 -v > /dev/null 2>&1; then
+ rm restart_zelflux.sh > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Configuring PM2...${NC}"
+ pm2 startup systemd -u $USER > /dev/null 2>&1
+ sudo env PATH=$PATH:/home/$USER/.nvm/versions/node/$(node -v)/bin pm2 startup systemd -u $USER --hp /home/$USER > /dev/null 2>&1
+ pm2 start ~/$FLUX_DIR/start.sh --name flux > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ pm2 install pm2-logrotate > /dev/null 2>&1
+ pm2 set pm2-logrotate:max_size 6M > /dev/null 2>&1
+ pm2 set pm2-logrotate:retain 6 > /dev/null 2>&1
+ pm2 set pm2-logrotate:compress true > /dev/null 2>&1
+ pm2 set pm2-logrotate:workerInterval 3600 > /dev/null 2>&1
+ pm2 set pm2-logrotate:rotateInterval '0 12 * * 0' > /dev/null 2>&1
+ source ~/.bashrc
+ string_limit_check_mark "PM2 v$(pm2 -v) installed....................................................." "PM2 ${GREEN}v$(pm2 -v)${CYAN} installed....................................................."
+ PM2_INSTALL="1"
+ else
+ string_limit_x_mark "PM2 was not installed....................................................."
+ echo
+ fi
+}
+function finalizing() {
+ cd
+ pm2 start /home/$USER/$FLUX_DIR/start.sh --max-memory-restart 1500M --restart-delay 30000 --max-restarts 40 --name flux --time > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ #sleep 120
+ #cd /home/$USER/zelflux
+ #pm2 stop flux
+ #npm install --legacy-peer-deps > /dev/null 2>&1
+ #pm2 start flux
+ #cd
+ NUM='300'
+ MSG1='Finalizing Flux installation please be patient this will take about ~5min...'
+ MSG2="${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
+ echo && spinning_timer
+ echo
+
+ if [[ "$gateway_ip" != "" && "$upnp_port" != "" ]] && [[ "$upnp_port" != "null" ]] ; then
+ error_check=$(tail -n10 /home/$USER/.pm2/logs/flux-out.log | grep "UPnP failed")
+ if [[ "$error_check" != "" ]]; then
+ echo -e "${WORNING} ${RED}Problem with UPnP detected, FluxOS Shutting down...${NC}"
+ echo -e ""
+ fi
+ fi
+
+ $BENCH_CLI restartnodebenchmarks > /dev/null 2>&1
+ NUM='300'
+ MSG1='Restarting benchmark...'
+ MSG2="${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo && echo
+ echo -e "${BOOK}${YELLOW} Flux benchmarks:${NC}"
+ echo -e "${YELLOW}======================${NC}"
+ bench_benchmarks=$($BENCH_CLI getbenchmarks)
+ if [[ "bench_benchmarks" != "" ]]; then
+ bench_status=$(jq -r '.status' <<< "$bench_benchmarks")
+ if [[ "$bench_status" == "failed" ]]; then
+ echo -e "${ARROW} ${CYAN}Flux benchmark failed...............[${X_MARK}${CYAN}]${NC}"
+ check_benchmarks "eps" "89.99" " CPU speed" "< 90.00 events per second"
+ check_benchmarks "ddwrite" "159.99" " Disk write speed" "< 160.00 events per second"
+ else
+ echo -e "${BOOK}${CYAN} STATUS: ${GREEN}$bench_status${NC}"
+ bench_cores=$(jq -r '.cores' <<< "$bench_benchmarks")
+ echo -e "${BOOK}${CYAN} CORES: ${GREEN}$bench_cores${NC}"
+ bench_ram=$(jq -r '.ram' <<< "$bench_benchmarks")
+ bench_ram=$(round "$bench_ram" 2)
+ echo -e "${BOOK}${CYAN} RAM: ${GREEN}$bench_ram${NC}"
+ bench_ssd=$(jq -r '.ssd' <<< "$bench_benchmarks")
+ bench_ssd=$(round "$bench_ssd" 2)
+ echo -e "${BOOK}${CYAN} SSD: ${GREEN}$bench_ssd${NC}"
+ bench_hdd=$(jq -r '.hdd' <<< "$bench_benchmarks")
+ bench_hdd=$(round "$bench_hdd" 2)
+ echo -e "${BOOK}${CYAN} HDD: ${GREEN}$bench_hdd${NC}"
+ bench_ddwrite=$(jq -r '.ddwrite' <<< "$bench_benchmarks")
+ bench_ddwrite=$(round "$bench_ddwrite" 2)
+ echo -e "${BOOK}${CYAN} DDWRITE: ${GREEN}$bench_ddwrite${NC}"
+ bench_eps=$(jq -r '.eps' <<< "$bench_benchmarks")
+ bench_eps=$(round "$bench_eps" 2)
+ echo -e "${BOOK}${CYAN} EPS: ${GREEN}$bench_eps${NC}"
+ fi
+ else
+ echo -e "${ARROW} ${CYAN}Flux benchmark not responding.................[${X_MARK}${CYAN}]${NC}"
+ fi
+}
+function zk_params() {
+ echo -e "${ARROW} ${YELLOW}Installing zkSNARK params...${NC}"
+ bash flux-fetch-params > /dev/null 2>&1 && sleep 2
+ sudo chown -R $USER:$USER /home/$USER > /dev/null 2>&1
+}
+function flux_package() {
+ sudo apt-get update -y > /dev/null 2>&1 && sleep 2
+ echo -e "${ARROW} ${YELLOW}Flux Daemon && Benchmark installing...${NC}"
+ DEBIAN_FRONTEND=noninteractive sudo apt-get --yes install $COIN_NAME $BENCH_NAME > /dev/null 2>&1 && sleep 2
+ sudo chmod 755 $COIN_PATH/* > /dev/null 2>&1 && sleep 2
+ integration_check
+}
+function create_service_scripts() {
+ echo -e "${ARROW} ${YELLOW}Creating Flux daemon service scripts...${NC}" && sleep 1
+ sudo touch /home/$USER/start_daemon_service.sh
+ sudo chown $USER:$USER /home/$USER/start_daemon_service.sh
+ cat <<-'EOF' > /home/$USER/start_daemon_service.sh
+ #!/bin/bash
+ #color codes
+ RED='\033[1;31m'
+ CYAN='\033[1;36m'
+ NC='\033[0m'
+ #emoji codes
+ BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
+ WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
+ directory="/usr/local/bin"
+ current_user="$USER"
+ sleep 2
+ # Check if the directory exists
+ if [ -d "$directory" ]; then
+ echo "Checking for files in $directory..."
+ # Use find to search for all files in the directory
+ all_files=$(find "$directory" -maxdepth 1)
+ if [ -n "$all_files" ]; then
+ # Identify files not owned by the current user
+ non_user_files=$(find "$directory" -maxdepth 1 ! -user "$current_user")
+ if [ -n "$non_user_files" ]; then
+ echo "Files not owned by $current_user found:"
+ echo "$non_user_files"
+ # Change ownership of non-user files to the current user
+ echo "Changing ownership to $current_user..."
+ sudo chown "$current_user":"$current_user" $non_user_files
+ echo "Ownership changed successfully."
+ else
+ echo "All files are owned by $current_user."
+ fi
+ else
+ echo "No files found in $directory."
+ fi
+ else
+ echo "Directory $directory does not exist."
+ fi
+ echo -e "${BOOK} ${CYAN}Pre-start process starting...${NC}"
+ echo -e "${BOOK} ${CYAN}Checking if benchmark or daemon is running${NC}"
+ bench_status_pind=$(pgrep fluxbenchd)
+ daemon_status_pind=$(pgrep fluxd)
+ if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then
+ echo -e "${BOOK} ${CYAN}No running instance detected...${NC}"
+ else
+ if [[ "$bench_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running benchmark process detected${NC}"
+ echo -e "${WORNING} Killing benchmark...${NC}"
+ sudo killall -9 fluxbenchd > /dev/null 2>&1 && sleep 2
+ fi
+ if [[ "$daemon_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running daemon process detected${NC}"
+ echo -e "${WORNING} Killing daemon...${NC}"
+ sudo killall -9 fluxd > /dev/null 2>&1 && sleep 2
+ fi
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+ fi
+ bench_status_pind=$(pgrep zelbenchd)
+ daemon_status_pind=$(pgrep zelcashd)
+ if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then
+ echo -e "${BOOK} ${CYAN}No running instance detected...${NC}"
+ else
+ if [[ "$bench_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running benchmark process detected${NC}"
+ echo -e "${WORNING} Killing benchmark...${NC}"
+ sudo killall -9 zelbenchd > /dev/null 2>&1 && sleep 2
+ fi
+ if [[ "$daemon_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running daemon process detected${NC}"
+ echo -e "${WORNING} Killing daemon...${NC}"
+ sudo killall -9 zelcashd > /dev/null 2>&1 && sleep 2
+ fi
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+ fi
+ if [[ -f /usr/local/bin/fluxd ]]; then
+ bash -c "fluxd"
+ exit
+ else
+ bash -c "zelcashd"
+ exit
+ fi
+ EOF
+ sudo touch /home/$USER/stop_daemon_service.sh
+ sudo chown $USER:$USER /home/$USER/stop_daemon_service.sh
+ cat <<-'EOF' > /home/$USER/stop_daemon_service.sh
+ #!/bin/bash
+ if [[ -f /usr/local/bin/flux-cli ]]; then
+ bash -c "flux-cli stop"
+ else
+ bash -c "zelcash-cli stop"
+ fi
+ exit
+ EOF
+ sudo chmod +x /home/$USER/stop_daemon_service.sh
+ sudo chmod +x /home/$USER/start_daemon_service.sh
+}
+function create_service() {
+ if [[ "$1" != "install" ]]; then
+ echo -e "${GREEN}Module: Flux Daemon service creator${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ echo -e ""
+ echo -e "${ARROW} ${CYAN}Cleaning...${NC}" && sleep 1
+ sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
+ sudo rm -rf /home/$USER/start_daemon_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/stop_daemon_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/start_zelcash_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/stop_zelcash_service.sh > /dev/null 2>&1
+ sudo rm -rf /etc/systemd/system/zelcash.service > /dev/null 2>&1
+ fi
+ echo -e "${ARROW} ${YELLOW}Creating Flux daemon service...${NC}" && sleep 1
+ sudo touch /etc/systemd/system/zelcash.service
+ sudo chown $USER:$USER /etc/systemd/system/zelcash.service
+ cat <<-EOF > /etc/systemd/system/zelcash.service
+ [Unit]
+ Description=Flux daemon service
+ After=network.target
+ [Service]
+ Type=forking
+ User=$USER
+ Group=$USER
+ ExecStart=/home/$USER/start_daemon_service.sh
+ ExecStop=-/home/$USER/stop_daemon_service.sh
+ Restart=always
+ RestartSec=10
+ PrivateTmp=true
+ TimeoutStopSec=60s
+ TimeoutStartSec=15s
+ StartLimitInterval=120s
+ StartLimitBurst=5
+ [Install]
+ WantedBy=multi-user.target
+ EOF
+ sudo chown root:root /etc/systemd/system/zelcash.service
+ sudo systemctl daemon-reload
+}
+#### LOGS SECTION
+function log_rotate() {
+ echo -e "${ARROW} ${YELLOW}Configuring log rotate function for $1 logs...${NC}"
+ sleep 1
+ if [ -f /etc/logrotate.d/$2 ]; then
+ sudo rm -rf /etc/logrotate.d/$2
+ sleep 1
+ fi
+ sudo touch /etc/logrotate.d/$2
+ sudo chown $USER:$USER /etc/logrotate.d/$2
+ cat <<-EOF > /etc/logrotate.d/$2
+ $3 {
+ compress
+ copytruncate
+ missingok
+ $4
+ rotate $5
+ }
+ EOF
+ sudo chown root:root /etc/logrotate.d/$2
+}
+#### UPnP
+function upnp_enable() {
+ if [[ -d $FLUX_BENCH_PATH && $FLUXOS_VERSION == "" ]]; then
+ sudo chown -R $USER:$USER $FLUX_BENCH_PATH > /dev/null 2>&1
+ fi
+ try="0"
+ echo -e ""
+ echo -e "${ARROW}${YELLOW} Creating UPnP configuration...${NC}"
+ if [[ ! -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ echo -e "${WORNING} ${CYAN}Missing FluxOS configuration file - install/re-install Flux Node...${NC}"
+ echo -e ""
+ return
+ fi
+ if [[ -z "$upnp_port" ]]; then
+ candidate_ports=(16127 16137 16147 16157 16167 16177 16187 16197)
+ current_mappings=$(upnpc -l 2>/dev/null)
+ local_ip=$(echo "$current_mappings" | grep -oP 'Local LAN ip address : \K[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
+ used_ports=()
+ used_ports_by_host=()
+
+ while IFS= read -r line; do
+ if echo "$line" | grep -q "TCP "; then
+ port=$(echo "$line" | sed -n 's/.*TCP \([0-9]\+\)->.*/\1/p')
+ host=$(echo "$line" | sed -n 's/.*->\([0-9\.]\+\):.*/\1/p')
+ used_ports+=("$port")
+ if [[ "$host" == "$local_ip" ]]; then
+ used_ports_by_host+=("$port")
+ fi
+ fi
+ done <<< "$current_mappings"
+
+ radio_list=()
+ for port in "${candidate_ports[@]}"; do
+ if [[ " ${used_ports_by_host[*]} " =~ " $port " ]]; then
+ radio_list+=("$port" "(In Use by Host) " ON)
+ elif [[ " ${used_ports[*]} " =~ " $port " ]]; then
+ radio_list+=("$port" "(In Use) " OFF)
+ else
+ radio_list+=("$port" "(Available) " OFF)
+ fi
+ done
+
+ FLUX_PORT=$(whiptail --title "Select Your FluxOS UPnP Port" --radiolist \
+ "Use the UP/DOWN arrows to highlight the port. Press Spacebar to select, THEN press ENTER." 17 50 8 \
+ "${radio_list[@]}" 3>&1 1>&2 2>&3)
+
+ if [[ $? -ne 0 || -z $FLUX_PORT ]]; then
+ echo -e "${WORNING} ${CYAN}No port selected. Operation aborted.${NC}"
+ echo -e ""
+ exit
+ fi
+ else
+ FLUX_PORT="$upnp_port"
+ fi
+
+ config_builder "apiport" "$FLUX_PORT" "MultiPort Mode" "fluxos"
+ if [[ ! -d $FLUX_BENCH_PATH ]]; then
+ sudo mkdir -p $FLUX_BENCH_PATH 2>/dev/null
+ config_builder "fluxport" "$FLUX_PORT" "MultiPort Mode" "benchmark"
+ else
+ config_builder "fluxport" "$FLUX_PORT" "MultiPort Mode" "benchmark"
+ fi
+ if [[ -f $FLUX_BENCH_PATH/fluxbench.conf ]]; then
+ #API PORT
+ sudo ufw allow $FLUX_PORT > /dev/null 2>&1
+ #HOME UI PORT
+ sudo ufw allow $(($FLUX_PORT-1)) > /dev/null 2>&1
+ #if ! route -h > /dev/null 2>&1 ; then
+ # sudo apt install net-tools > /dev/null 2>&1
+ #fi
+ #router_ip=$(route -n | sed -nr 's/(0\.0\.0\.0) +([^ ]+) +\1.*/\2/p' 2>/dev/null)
+ if [[ -z "$gateway_ip" ]]; then
+ router_ip=$(ip rout | head -n1 | awk '{print $3}' 2>/dev/null)
+ else
+ router_ip="$gateway_ip"
+ fi
+ if [[ "$router_ip" != "" ]]; then
+ if [[ -z "$gateway_ip" ]]; then
+ if (whiptail --yesno "Is your router's IP $router_ip ?" 8 70); then
+ is_correct="0"
+ fi
+ else
+ is_correct="0"
+ fi
+ if [[ "$is_correct" == "0" ]]; then
+ config_builder "routerIP" "$router_ip" "RouterIP" "fluxos"
+ sudo ufw allow out from any to 239.255.255.250 port 1900 proto udp > /dev/null 2>&1
+ sudo ufw allow from $router_ip port 1900 to any proto udp > /dev/null 2>&1
+ sudo ufw allow out from any to $router_ip proto tcp > /dev/null 2>&1
+ sudo ufw allow from $router_ip to any proto udp > /dev/null 2>&1
+ else
+ while true
+ do
+
+ router_ip=$(whiptail --inputbox "Enter your router's IP" 8 60 3>&1 1>&2 2>&3)
+
+ if [[ "$router_ip" =~ ^(([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\.){3}([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$ ]]; then
+ echo -e "${ARROW} ${CYAN}IP $router_ip format is valid........................[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ else
+ string_limit_x_mark "IP $router_ip is not valid ..............................."
+ sleep 1
+ fi
+
+ done
+ config_builder "routerIP" "$router_ip" "RouterIP" "fluxos"
+ sudo ufw allow out from any to 239.255.255.250 port 1900 proto udp > /dev/null 2>&1
+ sudo ufw allow from $router_ip port 1900 to any proto udp > /dev/null 2>&1
+ sudo ufw allow out from any to $router_ip proto tcp > /dev/null 2>&1
+ sudo ufw allow from $router_ip to any proto udp > /dev/null 2>&1
+ fi
+ else
+ while true
+ do
+ router_ip=$(whiptail --inputbox "Enter your router's IP" 8 60 3>&1 1>&2 2>&3)
+ if [[ "$router_ip" =~ ^(([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\.){3}([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$ ]]; then
+ echo -e "${ARROW} ${CYAN}IP $router_ip format is valid........................[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ else
+ string_limit_x_mark "IP $router_ip is not valid ..............................."
+ sleep 1
+ fi
+ done
+ config_builder "routerIP" "$router_ip" "RouterIP" "fluxos"
+ sudo ufw allow out from any to 239.255.255.250 port 1900 proto udp > /dev/null 2>&1
+ sudo ufw allow from $router_ip port 1900 to any proto udp > /dev/null 2>&1
+ sudo ufw allow out from any to $router_ip proto tcp > /dev/null 2>&1
+ sudo ufw allow from $router_ip to any proto udp > /dev/null 2>&1
+ fi
+ fi
+ if [[ "$1" != "install" ]]; then
+ echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark.....${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo systemctl restart zelcash > /dev/null 2>&1
+ pm2 restart flux > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxd > /dev/null 2>&1
+ sudo systemctl restart fluxos > /dev/null 2>&1
+ fi
+ sleep 180
+ echo -e "${ARROW}${CYAN} Checking FluxOS logs... ${NC}"
+ if [[ -n $FLUXOS_VERSION ]]; then
+ error_check=$(sudo journalctl -u fluxos.service -b -n 25 | grep "Deactivated successfully")
+ else
+ error_check=$(tail -n10 /home/$USER/.pm2/logs/flux-out.log | grep "UPnP failed")
+ fi
+ if [[ "$error_check" == "" ]]; then
+ echo -e ""
+ LOCAL_IP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
+ ZELFRONTPORT=$(($FLUX_PORT-1))
+ echo -e "${PIN} ${CYAN}To access your FluxOS use this url: ${SEA}http://${LOCAL_IP}:$ZELFRONTPORT${NC}"
+ echo -e ""
+ else
+ echo -e "${WORNING} ${RED}Problem with UPnP detected, FluxOS Shutting down...${NC}"
+ echo -e ""
+ fi
+ else
+ LOCAL_IP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
+ ZELFRONTPORT=$(($FLUX_PORT-1))
+ fi
+}
+#### TESTNET
+function testnet_binary(){
+ sudo rm -rf /tmp/*lux* 2>&1 && sleep 2
+ if [[ $(dpkg --print-architecture) = *amd* ]]; then
+ #DAEMON
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/halving-test-2/Flux-Linux-halving.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Flux-Linux-halving.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1
+ #BENCHMARK
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/halving-test-2/Fluxbench-Linux-v3.3.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Fluxbench-Linux-v3.3.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1
+ else
+ #DAEMON
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/halving-test-2/Flux-arm64-halving.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Flux-arm64-halving.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1
+ #BENCHMARK
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/halving-test-2/Fluxbench-arm-v3.3.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Fluxbench-arm-v3.3.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1
+ fi
+ sudo chmod 755 $COIN_PATH/* > /dev/null 2>&1 && sleep 2
+}
+#### MULTITOOLBOX OPTIONS SECTION
+function selfhosting_creator(){
+
+ echo -e "${GREEN}Module: Self-hosting ip cron service${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e ""
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+
+ CHOICE=$(
+ whiptail --title "FluxOS Selfhosting Configuration" --menu "Make your choice" 15 40 6 \
+ "1)" "Auto Detection (Recommended)" \
+ "2)" "Manual Configuration (Advance)" \
+ "3)" "Removing service" 3>&2 2>&1 1>&3
+ )
+ case $CHOICE in
+ "1)")
+ echo -e "${ARROW} ${YELLOW}Creating cron service for ip rotate...${NC}"
+ if [[ -f $DATA_PATH/device_conf.json ]]; then
+ sudo rm -rf $DATA_PATH/device_conf.json
+ echo -e "${ARROW} ${CYAN}Removing config file, path: ${GREEN}$DATA_PATH/device_conf.json${NC}"
+ fi
+ selfhosting
+ ;;
+ "2)")
+ echo -e "${ARROW} ${YELLOW}Creating cron service for ip rotate.....${NC}"
+ #device_setup=$(whiptail --inputbox "Enter your device name" 8 60 3>&1 1>&2 2>&3)
+ deviceList=($(sudo route -n | awk '{ if ($8 != "" && $8 != "Iface" && $8 != "docker0" ) printf("%s\n", $8); }' | uniq))
+ elements=${#deviceList[@]}
+ choices=();
+ for (( i=0;i<$elements;i++)); do
+ if [[ "$i" == "0" ]]; then
+ choices+=("${deviceList[i]}" "" "ON");
+ else
+ choices+=("${deviceList[i]}" "" "OFF");
+ fi
+ done;
+ device_setup=$(
+ whiptail --title " SELECT YOUR DEVICE INTERFACE " \
+ --radiolist " \n Use the UP/DOWN arrows to highlight the device name you want. Press Spacebar on the device name you want to select, THEN press ENTER." 25 55 10 \
+ "${choices[@]}" \
+ 3>&2 2>&1 1>&3
+ );
+ if [[ "$device_setup" != "" ]]; then
+ if [[ ! -f $DATA_PATH/device_conf.json ]]; then
+ echo "{}" > device_conf.json
+ fi
+ echo "$(jq -r --arg value "$device_setup" '.device_name=$value' device_conf.json)" > device_conf.json
+ echo -e "${ARROW} ${CYAN}Config created successful, path: ${SEA}/home/$USER/device_conf.json${CYAN}, device name: ${GREEN}$device_setup${NC}"
+ else
+ echo -e "${ARROW} ${CYAN}Operation aborted, device interface was not selected...${NC}"
+ echo -e ""
+ exit
+ fi
+ selfhosting
+ ;;
+ "3)")
+ echo -e "${ARROW} ${YELLOW}Disabling cron service for IP rotate...${NC}"
+ echo -e "${ARROW} ${CYAN}Removing cron jobs...${NC}"
+ crontab -u $USER -l | grep -v 'ip_check' | crontab -u $USER -
+ echo -e "${ARROW} ${CYAN}Removing of files related to IP rotation...${NC}"
+ rm -rf $DATA_PATH/device_conf.json > /dev/null 2>&1
+ rm -rf $DATA_PATH/ip_check.sh > /dev/null 2>&1
+ echo -e ""
+ esac
+}
+
+function selfhosting() {
+ if [[ "$1" == "install" ]]; then
+ echo -e "${ARROW} ${YELLOW}Creating cron service for ip rotate...${NC}"
+ fi
+
+ echo -e "${ARROW} ${CYAN}Adding IP for device...${NC}" && sleep 1
+ if [[ "$1" != "install" ]]; then
+ get_ip
+ fi
+
+ if [[ -z "$device_setup" ]]; then
+ device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}')
+ if [[ "$device_name" != "" ]]; then
+ echo -e "${ARROW} ${CYAN}Device auto detection, name: ${GREEN}$device_name ${NC}"
+ fi
+ else
+ device_name="$device_setup"
+ fi
+
+ if [[ "$device_name" != "" && "$WANIP" != "" ]]; then
+ echo -e "${ARROW} ${CYAN}Detected IP: ${GREEN}$WANIP ${NC}"
+ sudo ip addr add $WANIP dev $device_name > /dev/null 2>&1
+ else
+ echo -e "${WORNING} ${CYAN}Problem detected operation aborted! ${NC}" && sleep 1
+ echo -e ""
+ return 1
+ fi
+ echo -e "${ARROW} ${CYAN}Creating IP check script...${NC}" && sleep 1
+ sudo rm $DATA_PATH/ip_check.sh > /dev/null 2>&1
+ sudo touch $DATA_PATH/ip_check.sh
+ sudo chown $USER:$USER $DATA_PATH/ip_check.sh
+ cat <<-'EOF' > $DATA_PATH/ip_check.sh
+ #!/bin/bash
+ if [[ -z $FLUXOS_VERSION ]]; then
+ DATA_PATH="/home/$USER"
+ FLUXOS_PATH="/home/$USER/zelflux"
+ else
+ DATA_PATH="/dat"
+ FLUXOS_PATH="/dat/usr/lib/fluxos"
+ fi
+
+ function get_ip(){
+ WANIP=$(curl --silent -m 10 https://api4.my-ip.io/ip | tr -dc '[:alnum:].')
+ if [[ "$WANIP" == "" || "$WANIP" = *html* ]]; then
+ WANIP=$(curl --silent -m 10 https://checkip.amazonaws.com | tr -dc '[:alnum:].')
+ fi
+ if [[ "$WANIP" == "" || "$WANIP" = *html* ]]; then
+ WANIP=$(curl --silent -m 10 https://api.ipify.org | tr -dc '[:alnum:].')
+ fi
+ }
+
+ function get_device_name(){
+ if [[ -f $DATA_PATH/device_conf.json ]]; then
+ device_name=$(jq -r .device_name $DATA_PATH/device_conf.json)
+ else
+ device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}')
+ fi
+ }
+
+ if [[ $1 == "restart" ]]; then
+ #give 3min to connect with internet
+ sleep 180
+ get_ip
+ get_device_name
+ if [[ "$device_name" != "" && "$WANIP" != "" ]]; then
+ date_timestamp=$(date '+%Y-%m-%d %H:%M:%S')
+ echo -e "New IP detected during $1, IP: $WANIP was added to $device_name at $date_timestamp" >> $DATA_PATH/ip_history.log
+ sudo ip addr add $WANIP dev $device_name && sleep 2
+ fi
+ fi
+ if [[ $1 == "ip_check" ]]; then
+ get_ip
+ get_device_name
+ api_port=$(grep -w apiport $FLUXOS_PATH/config/userconfig.js | grep -o '[[:digit:]]*')
+ if [[ "$api_port" == "" ]]; then
+ api_port="16127"
+ fi
+ confirmed_ip=$(curl -SsL -m 10 http://localhost:$api_port/flux/info 2>/dev/null | jq -r .data.node.status.ip | sed -r 's/:.+//')
+ if [[ "$WANIP" != "" && "$confirmed_ip" != "" && "$confirmed_ip" != "null" ]]; then
+ if [[ "$WANIP" != "$confirmed_ip" ]]; then
+ date_timestamp=$(date '+%Y-%m-%d %H:%M:%S')
+ echo -e "New IP detected during $1, IP: $WANIP was added to $device_name at $date_timestamp" >> $DATA_PATH/ip_history.log
+ sudo ip addr add $WANIP dev $device_name && sleep 2
+ fi
+ fi
+ fi
+ EOF
+ sudo chmod +x $DATA_PATH/ip_check.sh
+ sudo [ -f /var/spool/cron/crontabs/$USER ] && crontab_check=$(sudo cat /var/spool/cron/crontabs/$USER | grep -o ip_check | wc -l) || crontab_check=0
+ if [[ "$crontab_check" != "0" ]]; then
+ echo -e "${ARROW} ${CYAN}Removing old cron jobs...${NC}"
+ crontab -u $USER -l | grep -v 'ip_check' | crontab -u $USER -
+ fi
+ echo -e "${ARROW} ${CYAN}Adding cron jobs...${NC}" && sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ (crontab -l -u "$USER" 2>/dev/null; echo "@reboot env USER=\$LOGNAME \$HOME/ip_check.sh restart") | crontab -
+ (crontab -l -u "$USER" 2>/dev/null; echo "*/15 * * * * env USER=\$LOGNAME \$HOME/ip_check.sh ip_check") | crontab -
+ else
+ (crontab -l -u "$USER" 2>/dev/null; echo "@reboot env USER=\$LOGNAME /dat/ip_check.sh restart") | crontab -
+ (crontab -l -u "$USER" 2>/dev/null; echo "*/15 * * * * env USER=\$LOGNAME /dat/ip_check.sh ip_check") | crontab -
+ fi
+ echo -e "${ARROW} ${CYAN}Script installed! ${NC}"
+ echo -e ""
+}
+function multinode(){
+ echo -e "${GREEN}Module: Multinode configuration with UPNP communication (Needs Router with UPNP support)${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ echo -e ""
+ echo -e "${ARROW} ${CYAN}OPTION ALLOWS YOU: ${NC}"
+ echo -e "${HOT} ${CYAN}Run node as selfhosting with upnp communication ${NC}"
+ echo -e "${HOT} ${CYAN}Create up to 8 node using same public address ${NC}"
+ echo -e ""
+ echo -e "${ARROW} ${RED}IMPORTANT:${NC}"
+ echo -e "${BOOK} ${RED}Each node need to set different port for communication${NC}"
+ echo -e "${BOOK} ${RED}If FluxOs fails to communicate with router or upnp fails it will shutdown FluxOS... ${NC}"
+ echo -e ""
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ ! -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ echo -e ""
+ echo -e "${WORNING} ${CYAN}First install FluxNode...${NC}"
+ echo -e "${WORNING} ${CYAN}Operation stopped...${NC}"
+ echo -e ""
+ exit
+ fi
+ sleep 8
+ if [[ -f "/usr/lib/multitoolbox/multinode.sh" ]]; then
+ bash -i "/usr/lib/multitoolbox/multinode.sh"
+ else
+ bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/multinode.sh)
+ fi
+}
+function analyzer_and_fixer(){
+ echo -e "${GREEN}Module: FluxNode Diagnostics${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ if [[ -f "/usr/lib/multitoolbox/nodeanalizerandfixer.sh" ]]; then
+ bash -i "/usr/lib/multitoolbox/nodeanalizerandfixer.sh"
+ else
+ bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/nodeanalizerandfixer.sh)
+ fi
+}
diff --git a/hardwarebench.sh b/hardwarebench.sh
new file mode 100755
index 00000000..be26c629
--- /dev/null
+++ b/hardwarebench.sh
@@ -0,0 +1,463 @@
+#!/usr/bin/env bash
+LC_ALL="en_US.UTF-8"
+LC_NUMERIC="en_US.UTF-8"
+LANG="en_US.UTF-8"
+LANGUAGE="en_US:en"
+SSD=0
+HDD=0
+SCORE=0
+RED='\033[1;31m'
+GREEN='\033[1;32m'
+NC='\033[0m'
+CYAN='\033[1;36m'
+command_exists()
+{
+ command -v "$@" > /dev/null 2>&1
+}
+
+Bps_to_MiBps()
+{
+ awk '{ printf "%.2f\n", $0 / 1024 / 1024 } END { if (NR == 0) { print "error" } }'
+}
+
+B_to_MiB()
+{
+ awk '{ printf "%.0f MiB\n", $0 / 1024 / 1024 } END { if (NR == 0) { print "error" } }'
+}
+
+finish()
+{
+ printf '\n'
+ sudo rm -f test_$$
+ exit
+}
+
+trap finish EXIT INT TERM
+
+dd_benchmark()
+{
+ cd $HOME && sudo LC_ALL=C timeout 25s dd if=/dev/zero of=$1/test_$$ bs=64k count=16k conv=fdatasync 2>&1 | \
+ awk -F, '
+ {
+ io=$NF
+ }
+ END {
+ if (io ~ /TB\/s/) {printf("%.0f\n", 1000*1000*1000*1000*io)}
+ else if (io ~ /GB\/s/) {printf("%.0f\n", 1000*1000*1000*io)}
+ else if (io ~ /MB\/s/) {printf("%.0f\n", 1000*1000*io)}
+ else if (io ~ /KB\/s/) {printf("%.0f\n", 1000*io)}
+ else { printf("%.0f", 1*io)}
+ }'
+ sudo rm -f $1/test_*
+}
+if ! command_exists dd; then
+ printf '%s\n' 'This script requires dd, but it could not be found.' 1>&2
+ exit 1
+fi
+if [[ "$(sysbench --version)" == "" ]]; then
+ curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sed 's/dist=${dist}/dist=focal/g' | sudo bash > /dev/null 2>&1
+ sudo apt -y install sysbench > /dev/null 2>&1
+ if [[ "$(sysbench --version)" == "" ]]; then
+ echo -e ""
+ echo -e "-------------------------------------------"
+ echo -e "| HARDWARE BENCHMARK"
+ echo -e "-------------------------------------------"
+ echo -e "| Benchmark: FAILED"
+ echo -e "| Error: Sysbench installation failed..."
+ echo -e "-------------------------------------------"
+ echo -e ""
+ exit
+ fi
+fi
+vcore=$(getconf _NPROCESSORS_ONLN)
+ram=$(LC_ALL=C free -b 2> /dev/null | awk 'NR==2 {print $2}' | grep -Eo '[0-9]+'| printf "%.0f\n" $(awk '{ print $1/1024/1024/1024 }') 2> /dev/null )
+core=$(awk -F: '/cpu cores/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \\t]*//;s/[ \\t]*$//')
+if [[ "$core" == "" ]]; then
+ core=$(grep 'processor' /proc/cpuinfo | wc -l)
+fi
+echo -e ""
+echo -e "-------------------------"
+echo -e "| MEMORY BENCHMARK"
+echo -e "-------------------------"
+echo -e "| RAM: ${CYAN}${ram}${NC}"
+echo -e "-------------------------"
+echo -e "| CPU BENCHMARK"
+echo -e "-------------------------"
+
+
+if [[ "$(dpkg --print-architecture)" = *"Jetson"* ]]; then
+ cumulus_ram=3
+else
+ cumulus_ram=7
+fi
+
+if [[ "$ram" -ge "$cumulus_ram" ]] && [[ "$vcore" -ge 4 ]]; then
+ status="CUMULUS"
+fi
+if [[ "$ram" -ge 30 ]] && [[ "$vcore" -ge 8 ]]; then
+ status="NIMBUS"
+fi
+if [[ "$ram" -ge 61 ]] && [[ "$vcore" -ge 16 ]]; then
+ status="STRATUS"
+fi
+if [[ "$status" == "" ]]; then
+ status="FAILED"
+fi
+
+
+echo -e "| CPU vcores: ${CYAN}${vcore}${NC}"
+
+if [[ "$ram" -ge "$cumulus_ram" ]] && [[ "$vcore" -ge 4 ]]; then
+ status="CUMULUS"
+fi
+if [[ "$ram" -ge 30 ]] && [[ "$vcore" -ge 8 ]]; then
+ status="NIMBUS"
+fi
+if [[ "$ram" -ge 61 ]] && [[ "$vcore" -ge 16 ]]; then
+ status="STRATUS"
+fi
+if [[ "$status" == "" ]]; then
+ status="FAILED"
+fi
+
+if [[ -n $FLUXOS_VERSION ]]; then
+ outputdiskbench="Disk Bench:";
+ mount_size=$(sudo lvs --units g --nosuffix --noheadings -o lv_size,vg_name | awk '/vg_flux/ {sum += $1} END {print sum}')
+ device_name=$(LC_ALL=C lsblk -l -b -n | grep 'crypt' | grep '/dat' | awk {'printf("%s\n", $1)'})
+ if [[ "$mount_size" != "" ]]; then
+ mount_path="/dat"
+ io1=$( dd_benchmark "$mount_path" )
+ io2=$( dd_benchmark "$mount_path" )
+ io3=$( dd_benchmark "$mount_path" )
+ if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ else
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps )
+ fi
+ outputdiskbench+=" $device_name $mount_size $ioavg"
+ if [[ "${ioavg%%.*}" -ge "180" ]]; then
+ SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$mount_size"')}')
+ else
+ HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$mount_size"')}')
+ fi
+ fi
+else
+ outputdiskbench="Disks Bench:";
+ #checking loop for lxc only if mount == '/'
+ loop_mount=$(cd $HOME && LC_ALL=C lsblk -l -b -n | grep 'loop' | awk '{ if ($7 == "/") printf("%.2f\n", $4/(1024*1024*1024))}')
+ if [[ "$loop_mount" != "" ]]; then
+
+ #echo -e "Device type: loop"
+ #echo -e ""
+ mount_path="/"
+ io1=$( dd_benchmark "$mount_path" )
+ #printf '1st run: %s\n' "$(printf '%d\n' "$io1" | Bps_to_MiBps)"
+ io2=$( dd_benchmark "$mount_path" )
+ #printf '2nd run: %s\n' "$(printf '%d\n' "$io2" | Bps_to_MiBps)"
+ io3=$( dd_benchmark "$mount_path" )
+ #printf '3rd run: %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)"
+ # Calculating avg I/O (better approach with awk for non int values)
+
+ if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ else
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps )
+ fi
+
+ #echo -e "-----------------------------"
+ outputdiskbench+=" loop $loop_mount $ioavg"
+ if [[ "${ioavg%%.*}" -ge "180" ]]; then
+ SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$loop_mount"')}')
+ else
+ HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$loop_mount"')}')
+ fi
+ echo -e "$outputdiskbench"
+ echo -e ""
+ exit
+ ###In this case we exit no other partition will be tested
+
+ fi
+ #################################
+ lvm_mount=""
+ raid_list=()
+ #create disk array ( check only disk > 2GB && name not mmcblk0/mmcblk0p1 to not run disk speed on microsd cards )
+ disc__array=($(cd $HOME && LC_ALL=C lsblk -o NAME,SIZE,TYPE -b -n | grep ' disk' | awk '{ if ($2 > 2147483648 && $1 != "mmcblk0" && $1 != "mmcblk0p1") print $1}'))
+ #echo -e ""
+ #echo -e "Disk count: ${#disc__array[@]}"
+ #echo -e "-----------------------------"
+ for((i=0;i<${#disc__array[@]};i++));
+ do
+ #checking if disk structure is accessable
+ cd $HOME && lsblk -l -b -n /dev/${disc__array[i]} > /dev/null 2>&1
+ if [ $? != 0 ]; then
+ #echo -e "Disk name: ${disc__array[i]}"
+ #echo -e "Error: Can't grab device stucture... device skipped!"
+ #echo -e "-----------------------------"
+ continue
+ fi
+ #checking direct mount
+ disk_mount_check=$(cd $HOME && LC_ALL=C lsblk -l -b -n /dev/${disc__array[i]} | egrep ' disk' | awk '{ if ( $7 == "") print "no"; else print "yes"}')
+ if [[ "$disk_mount_check" == "no" ]]; then
+ #checking lvm mount
+ lvm_mount=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{ print $7 }' )
+ lvm_name=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{ print $1 }' )
+
+ if [[ "$lvm_name" != "" ]]; then
+ count=$(echo ${mount_list[@]} | tr ' ' '\n' | awk '$1 == "'"$lvm_mount"'"{print $0}' | wc -l)
+ if [[ "$count" == "0" ]]; then
+ mount_list+=("$lvm_mount")
+ else
+ #echo -e "Disk name: ${disc__array[i]}"
+ #echo -e "Error: Mount point already checked... device skipped!"
+ #echo -e "-----------------------------"
+ continue
+ fi
+ fi
+
+ if [[ "$lvm_name" != "" && "$lvm_mount" == "" ]]; then
+
+ if [[ ! -d /.benchmark_test ]]; then
+ sudo mkdir /.benchmark_test
+ fi
+ sudo mount /dev/mapper/$lvm_name /.benchmark_test
+ fi
+
+ lvm_mount=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{ print $7 }' )
+
+ if [[ "$lvm_mount" != "" ]]; then
+ partition_output=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{print $1 " " $4/(1024*1024*1024) }')
+ else
+
+ #checking if disk partition type is LVM2_member
+ part_type_check=$(cd $HOME && LC_ALL=C lsblk -o NAME,TYPE,FSTYPE,SIZE -b -n /dev/${disc__array[i]} --sort SIZE | egrep ' part' | egrep 'LVM2_member' | tail -n1 | wc -l)
+ if [[ "$part_type_check" != "0" ]]; then
+ #skipp disk
+ partition_name=$(awk '{print $1}' <<< $part_type_check)
+ #echo -e "Disk name: ${disc__array[i]}"
+ #echo -e "Error: LVM2_member partition detected... device skipped!"
+ #echo -e "-----------------------------"
+ continue
+ fi
+
+ #checking raid
+ partition_output=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' raid' | tail -n1 | awk '{print $1 " " $4/(1024*1024*1024) }')
+
+ if [[ "$partition_output" == "" ]]; then
+ #checking part ( when not lvm and raid )
+ partition_output=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' part' | tail -n1 | awk '{print $1 " " $4/(1024*1024*1024) }')
+ else
+
+ partition_name=$(awk '{print $1}' <<< $partition_output)
+ #add raid name to skip list
+ if [[ ! " ${raid_list[@]} " =~ " ${partition_name} " ]]; then
+ raid_list+=("$partition_name")
+ else
+ #skipped raid already tested
+ #echo -e "Disk name: ${disc__array[i]}"
+ #echo -e "Info: Disk skipped - raid already tested!"
+ #echo -e "-----------------------------"
+ continue
+ fi
+ fi
+ fi
+
+ else
+ partition_output=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | tail -n1 | awk '{print $1 " " $4/(1024*1024*1024) }')
+ fi
+
+ partition_name=$(awk '{print $1}' <<< $partition_output)
+ partition_size=$(awk '{printf("%.2f",$2)}' <<< $partition_output)
+
+ if [[ "$lvm_mount" == "" && "$raid_list" == "" ]]; then
+ disk_size=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --noheadings | head -n1 | awk '{printf("%.2f",$4/(1024*1024*1024))}')
+ else
+ disk_size=$partition_size
+ fi
+ if [[ "$lvm_mount" == "" ]]; then
+ if [[ ! -d /.benchmark_test ]]; then
+ sudo mkdir /.benchmark_test
+ fi
+ sudo mount /dev/$partition_name /.benchmark_test
+ available_space=$(LC_ALL=C df /dev/$partition_name | grep $partition_name | tail -n1 | awk '{ if ($4 > 2097152) printf("%.2f",$4/(1024*1024)); else print "null"}')
+ else
+ available_space=$(LC_ALL=C df /dev/mapper/$partition_name | grep $partition_name | tail -n1 | awk '{ if ($4 > 2097152) printf("%.2f",$4/(1024*1024)); else print "null"}')
+ fi
+ #echo -e "Disk Name: ${disc__array[i]}"
+ #echo -e "Partition: /dev/$partition_name"
+ #echo -e "Size: $disk_size"
+ #echo -e "Available space: $available_space"
+ if [[ "$available_space" != "null" && "$available_space" != "" ]]; then
+
+ if [[ "$lvm_mount" == "" ]]; then
+ mount_path="/.benchmark_test"
+ else
+ mount_path="$lvm_mount"
+ fi
+ #echo -e "Mount point: $mount_path"
+ io1=$( dd_benchmark "$mount_path" )
+ #printf ' 1st run: %s\n' "$(printf '%d\n' "$io1" | Bps_to_MiBps)"
+ io2=$( dd_benchmark "$mount_path" )
+ #printf ' 2nd run: %s\n' "$(printf '%d\n' "$io2" | Bps_to_MiBps)"
+ io3=$( dd_benchmark "$mount_path" )
+ #printf ' 3rd run: %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)"
+ # Calculating avg I/O (better approach with awk for non int values)
+ if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ else
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps )
+ fi
+
+ outputdiskbench+=" ${disc__array[i]} $disk_size $ioavg"
+ if [[ "${ioavg%%.*}" -ge "180" ]]; then
+ SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$disk_size"')}')
+ else
+ HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$disk_size"')}')
+ fi
+ #echo -e "-----------------------------"
+ if [[ "$lvm_mount" == "" ]]; then
+ sudo umount /.benchmark_test
+ if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then
+ echo -e ""
+ else
+ sudo rm -rf /.benchmark_test
+ fi
+
+ fi
+ #check if test point mounted if exist unmount it LVM case
+ if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then
+ sudo umount /.benchmark_test
+ if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then
+ echo -e ""
+ else
+ sudo rm -rf /.benchmark_test
+ fi
+ fi
+
+ else
+
+ #echo -e "Error: space not enough... write test skipped!"
+ #echo -e "-----------------------------"
+ if [[ "$lvm_mount" == "" ]]; then
+
+ sudo umount /.benchmark_test
+ if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then
+ echo -e ""
+ else
+ sudo rm -rf /.benchmark_test
+ fi
+ fi
+ fi
+
+ done
+
+ if [[ "$outputdiskbench" == "Disks Bench:" ]]; then
+ # lsblk failed checking direct mount from df
+ df_direct_mount=$(LC_ALL=C df --output=source,fstype,size,avail,target | grep 'dev' | awk '{ if ($5 == "/") printf("%s %.2f %.2f\n", $1,$3/(1024*1024),$4/(1024*1024))}')
+
+ if [[ df_direct_mount != "" ]]; then
+
+ device_name=$(awk '{print $1}' <<< $df_direct_mount)
+ partition_size=$(awk '{print $2}' <<< $df_direct_mount)
+
+ #echo -e "Device name: $device_name"
+ #echo -e "Device size: $partition_size"
+ mount_path="/"
+ #echo -e "Mount point: $mount_path"
+ io1=$( dd_benchmark "$mount_path" )
+ #printf ' 1st run: %s\n' "$(printf '%d\n' "$io1" | Bps_to_MiBps)"
+ io2=$( dd_benchmark "$mount_path" )
+ #printf ' 2nd run: %s\n' "$(printf '%d\n' "$io2" | Bps_to_MiBps)"
+ io3=$( dd_benchmark "$mount_path" )
+ #printf ' 3rd run: %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)"
+ # Calculating avg I/O (better approach with awk for non int values)
+
+ if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps )
+ else
+ ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps )
+ fi
+
+ #echo -e "-----------------------------"
+ outputdiskbench+=" $device_name $partition_size $ioavg"
+ if [[ "${ioavg%%.*}" -ge "180" ]]; then
+ SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$partition_size"')}')
+ else
+ HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$partition_size"')}')
+ fi
+ #echo -e "$outputdiskbench"
+ #echo -e ""
+ fi
+ fi
+fi
+if [[ $status == "CUMULUS" ]]; then
+ SCORE=1
+fi
+if [[ $status == "NIMBUS" ]]; then
+ SCORE=2
+fi
+if [[ $status == "STRATUS" ]]; then
+ SCORE=3
+fi
+if [[ "$SSD" -lt 220 ]] || [[ "$SCORE" == 0 ]] ; then
+ status="FAILED"
+fi
+if [[ "$SSD" -ge 220 ]] && [[ "$SCORE" -ge 1 ]]; then
+ status="CUMULUS"
+ eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*4}')
+fi
+if [[ "$HDD" -ge 9200 ]] && [[ "$SCORE" -ge 1 ]]; then
+ status="THUNDER"
+ eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*4}')
+fi
+if [[ "$SSD" -ge 440 ]] && [[ "$SCORE" -ge 2 ]]; then
+ status="NIMBUS"
+ eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*8}')
+fi
+if [[ "$SSD" -ge 880 ]] && [[ "$SCORE" -ge 3 ]] ; then
+ if [[ "${ioavg%%.*}" -ge "400" ]] && [[ "$(dpkg --print-architecture)" == "amd64" ]]; then
+ status="STRATUS"
+ eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*16}')
+ else
+ status="NIMBUS"
+ eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*8}')
+ fi
+fi
+if [[ "${eps%%.*}" -lt 240 ]]; then
+ status="FAILED"
+fi
+if [[ "${eps%%.*}" -ge 240 && "$status" == "THUNDER" ]]; then
+ status="THUNDER"
+fi
+if [[ "${eps%%.*}" -ge 240 && "$status" == "CUMULUS" ]]; then
+ status="CUMULUS"
+fi
+if [[ "${eps%%.*}" -ge 640 && "$status" == "NIMBUS" ]]; then
+ status="NIMBUS"
+fi
+if [[ "${eps%%.*}" -ge 1520 && "$status" == "STRATUS" ]]; then
+ status="STRATUS"
+fi
+if [[ "$status" != "FAILED" ]]; then
+ echo -e "| EPS: ${CYAN}${eps}${NC}"
+fi
+echo -e "-------------------------"
+echo -e "| DISK BENCHMARK"
+echo -e "-------------------------"
+echo -e "| SSD: ${CYAN}${SSD}${NC}"
+echo -e "| HDD: ${CYAN}${HDD}${NC}"
+echo -e "| WRITESPEED: ${CYAN}${ioavg%%.*}${NC}"
+echo -e "-------------------------"
+if [[ "$status" != "FAILED" ]]; then
+echo -e "| Benchmark: ${GREEN}$status${NC}"
+else
+echo -e "| Benchmark: ${RED}$status${NC}"
+fi
+echo -e "-------------------------"
diff --git a/helper.sh b/helper.sh
deleted file mode 100644
index d9fc90d0..00000000
--- a/helper.sh
+++ /dev/null
@@ -1,1354 +0,0 @@
-#!/bin/bash
-
-#information
-FLUX_APPS_DIR='ZelApps'
-FLUX_DIR='zelflux'
-COIN_NAME='zelcash'
-COIN_DAEMON='zelcashd'
-COIN_CLI='zelcash-cli'
-COIN_PATH='/usr/local/bin'
-CONFIG_DIR='.flux'
-CONFIG_FILE='zelcash.conf'
-BENCH_NAME='zelbench'
-BENCH_DAEMON='zelbenchd'
-BENCH_CLI='zelbench-cli'
-#end of required details
-
-#color codes
-RED='\033[1;31m'
-YELLOW='\033[1;33m'
-BLUE="\\033[38;5;27m"
-SEA="\\033[38;5;49m"
-GREEN='\033[1;32m'
-CYAN='\033[1;36m'
-ORANGE='\e[38;5;202m'
-NC='\033[0m'
-FLUX_UPDATE="0"
-
-#emoji codes
-CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}"
-X_MARK="${RED}\xE2\x9C\x96${NC}"
-PIN="${RED}\xF0\x9F\x93\x8C${NC}"
-CLOCK="${GREEN}\xE2\x8C\x9B${NC}"
-ARROW="${SEA}\xE2\x96\xB6${NC}"
-BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
-HOT="${ORANGE}\xF0\x9F\x94\xA5${NC}"
-WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
-
-BOOTSTRAP_ZIP='https://fluxnodeservice.com/daemon_bootstrap.tar.gz'
-BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz'
-BOOTSTRAP_URL_MONGOD='https://fluxnodeservice.com/mongod_bootstrap.tar.gz'
-BOOTSTRAP_ZIPFILE_MONGOD='mongod_bootstrap.tar.gz'
-KDA_BOOTSTRAP_ZIPFILE='kda_bootstrap.tar.gz'
-KDA_BOOTSTRAP_ZIP='https://fluxnodeservice.com/kda_bootstrap.tar.gz'
-
-#dialog color
-export NEWT_COLORS='
-title=black,
-'
-# add to path
-PATH=$PATH:"$COIN_PATH"
-export PATH
-
-call_type="$1"
-type="$2"
-
-echo -e "${BOOK}${YELLOW}Helper action: ${GREEN}$1${NC}"
-
-
-function max(){
-
- local m="0"
- for n in "$@"
- do
- if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then
- [ "$n" -gt "$m" ] && m="$n"
- fi
- done
- echo "$m"
-
-}
-
-function spinning_timer()
-{
- animation=( ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ )
- end=$((SECONDS+NUM))
- while [ $SECONDS -lt $end ];
- do
- for i in "${animation[@]}";
- do
- echo -e ""
- echo -ne "${RED}\r\033[1A\033[0K$i ${CYAN}${MSG1}${NC}"
- sleep 0.1
-
- done
- done
- echo -ne "${MSG2}"
-}
-
-function string_limit_check_mark_port()
-{
-
- if [[ -z "$2" ]]; then
- string="$1"
- string=${string::65}
- else
- string=$1
- string_color=$2
- string_leght=${#string}
- string_leght_color=${#string_color}
- string_diff=$((string_leght_color-string_leght))
- string=${string_color::65+string_diff}
- fi
- echo -e "${PIN}${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
-}
-
-function string_limit_check_mark()
-{
-
- if [[ -z "$2" ]]; then
- string="$1"
- string=${string::50}
- else
- string=$1
- string_color=$2
- string_leght=${#string}
- string_leght_color=${#string_color}
- string_diff=$((string_leght_color-string_leght))
- string=${string_color::50+string_diff}
- fi
-
- echo -e "${ARROW} ${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
-}
-
-function string_limit_x_mark()
-{
-
- if [[ -z "$2" ]]; then
- string="$1"
- string=${string::50}
- else
- string=$1
- string_color=$2
- string_leght=${#string}
- string_leght_color=${#string_color}
- string_diff=$((string_leght_color-string_leght))
- string=${string_color::50+string_diff}
- fi
-
- echo -e "${ARROW} ${CYAN}$string[${X_MARK}${CYAN}]${NC}"
-}
-
-function local_version_check()
-{
-
- local_version=$(dpkg -l $1 | grep -w $1 | awk '{print $3}')
-}
-
-function remote_version_check(){
-
- #variable null
- remote_version=""
- package_name=""
-
- remote_version=$(curl -s -m 3 https://apt.zel.network/pool/main/z/"$1"/ | grep -o '[0-9].[0-9].[0-9]' | head -n1)
-
- if [[ "$remote_version" != "" ]]; then
- package_name=$(echo "$1_"$remote_version"_all.deb")
- fi
-}
-
-function install_package()
-{
-
- echo -e "${ARROW} ${CYAN}Install package for: ${GREEN}$1 $2${NC}"
- sudo apt-get purge "$1" "$2" -y >/dev/null 2>&1 && sleep 1
- sudo rm /etc/apt/sources.list.d/zelcash.list >/dev/null 2>&1 && sleep 1
- sudo rm /etc/apt/sources.list.d/flux.list >/dev/null 2>&1 && sleep 1
- echo -e "${ARROW} ${CYAN}Adding apt source...${NC}"
-
- echo 'deb https://apt.runonflux.io/ '$(lsb_release -cs)' main' | sudo tee --append /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
- gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B69CA27A986265D > /dev/null 2>&1
- gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
-
- if ! gpg --list-keys Zel > /dev/null; then
- gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
- gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
- fi
-
- sudo apt-get update >/dev/null 2>&1
- sudo apt-get install "$1" "$2" -y > /dev/null 2>&1
- sudo chmod 755 "$COIN_PATH/"* && sleep 2
-
-}
-
-start_fluxdaemon()
-{
-
- serive_check=$(sudo systemctl list-units --full -all | grep -o "$COIN_NAME.service" | head -n1)
-
- if [[ "$serive_check" != "" ]]; then
- echo -e "${ARROW} ${CYAN}Starting Flux daemon service...${NC}"
- sudo systemctl start $COIN_NAME >/dev/null 2>&1
- else
- echo -e "${ARROW} ${CYAN}Starting Flux daemon process...${NC}"
- "$COIN_DAEMON" >/dev/null 2>&1
- fi
-
-}
-
-stop_fluxdaemon() {
-
- echo -e "${ARROW} ${CYAN}Stopping Flux daemon...${NC}"
- sudo systemctl stop $COIN_NAME >/dev/null 2>&1 && sleep 5
- "$COIN_CLI" stop >/dev/null 2>&1 && sleep 5
- sudo killall "$COIN_DAEMON" fluxd >/dev/null 2>&1
- sudo killall -s SIGKILL $BENCH_NAME fluxbench >/dev/null 2>&1 && sleep 1
- sleep 4
-
-}
-
-function reindex()
-{
- echo -e "${ARROW} ${CYAN}Reindexing...${NC}"
- stop_fluxdaemon
- "$COIN_DAEMON" -reindex
- serive_check=$(sudo systemctl list-units --full -all | grep -o "$COIN_NAM.service" | head -n1)
- if [[ "$serive_check" != "" ]]; then
- sleep 60
- stop_fluxdaemon
- start_fluxdaemon
- fi
-}
-
-function restart_fluxdaemon()
-{
-
- echo -e "${ARROW} ${CYAN}Restarting Flux daemon...${NC}"
- serive_check=$(sudo systemctl list-units --full -all | grep -o "$COIN_NAME.service" | head -n1)
- if [[ "$serive_check" != "" ]]; then
- sudo systemctl restart $COIN_NAME >/dev/null 2>&1 && sleep 3
- else
- stop_fluxdaemon
- start_fluxdaemon
- fi
-
-}
-
-function fluxbench_update()
-{
-
- local_version=$(dpkg -l $BENCH_NAME | grep -w "$BENCH_NAME" | awk '{print $3}')
-
- if [[ "$type" == "force" ]]; then
- echo -e "${ARROW} ${CYAN}Force Flux benchmark updating...${NC}"
- stop_fluxdaemon
- install_package "$BENCH_NAME" "fluxbench"
- dpkg_version_after_install=$(dpkg -l $BENCH_NAME | grep -w "$BENCH_NAME" | awk '{print $3}')
- echo -e "${ARROW} ${CYAN}Flux benchmark version before update: ${GREEN}$local_version${NC}"
- echo -e "${ARROW} ${CYAN}Flux benchmark version after update: ${GREEN}$dpkg_version_after_install${NC}"
- start_fluxdaemon
- return
- fi
-
- remote_version_check "$BENCH_NAME"
- #remote_version=$(curl -s -m 3 https://zelcore.io/zelflux/zelbenchinfo.php | jq -r .version)
-
- if [[ "$call_type" != "update_all" ]]; then
-
- if [[ "$remote_version" == "" ]]; then
- echo -e "${ARROW} ${CYAN}Problem with version veryfication...Flux benchmark installation skipped...${NC}"
- return
- fi
-
- if [[ "$remote_version" == "$local_version" ]]; then
- echo -e "${ARROW} ${CYAN}You have the current version of Flux benchamrk ${GREEN}($remote_version)${NC}"
- return
- fi
-
- fi
-
- echo -e "${ARROW} ${CYAN}Updating Flux benchmark...${NC}"
- #stop_zelcash
- echo -e "${ARROW} ${CYAN}Flux benchmark stopping...${NC}"
- $BENCH_CLI stop >/dev/null 2>&1 && sleep 2
- sudo killall -s SIGKILL $BENCH_DAEMON >/dev/null 2>&1 && sleep 1
- sudo apt-get update >/dev/null 2>&1
- sudo apt-get install --only-upgrade $BENCH_NAME fluxbench -y >/dev/null 2>&1
- sudo chmod 755 "$COIN_PATH/"*
- sleep 2
-
- dpkg_version_after_install=$(dpkg -l $BENCH_NAME | grep -w "$BENCH_NAME" | awk '{print $3}')
- echo -e "${ARROW} ${CYAN}Flux benchmark version before update: ${GREEN}$local_version${NC}"
- #echo -e "${ARROW} ${CYAN}Zelbench version after update: ${GREEN}$dpkg_version_after_install${NC}"
-
- if [[ "$dpkg_version_after_install" == "" ]]; then
-
- install_package "$BENCH_NAME" "fluxbench"
- dpkg_version_after_install=$(dpkg -l $BENCH_NAME | grep -w "$BENCH_NAME" | awk '{print $3}')
-
- if [[ "$dpkg_version_after_install" != "" ]]; then
- echo -e "${ARROW} ${CYAN}Flux benchmark update successful ${CYAN}(${GREEN}$dpkg_version_after_install${CYAN})${NC}"
- fi
-
- start_fluxdaemon
- echo -e "${ARROW} ${CYAN}Flux benchmark starting...${NC}"
- #zelbenchd -daemon >/dev/null 2>&1
- else
-
- if [[ "$remote_version" == "$dpkg_version_after_install" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux benchmark update successful ${CYAN}(${GREEN}$dpkg_version_after_install${CYAN})${NC}"
- start_fluxdaemon
- echo -e "${ARROW} ${CYAN}Flux benchmark starting...${NC}"
- #zelbenchd -daemon >/dev/null 2>&1
- else
-
- if [[ "$local_version" == "$dpkg_version_after_install" ]]; then
-
- install_package "$BENCH_NAME" "fluxbench"
- dpkg_version_after_install=$(dpkg -l $BENCH_NAME | grep -w "$BENCH_NAME" | awk '{print $3}')
-
- if [[ "dpkg_version_after_install" == "$remote_version" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux benchmark update successful ${CYAN}(${GREEN}$dpkg_version_after_install${CYAN})${NC}"
-
- fi
-
- start_fluxdaemon
- echo -e "${ARROW} ${CYAN}Flux benchmark starting...${NC}"
- #zelbenchd -daemon >/dev/null 2>&1
- fi
- fi
- fi
-
-}
-
-function flux_update()
-{
-
- current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
- required_ver=$(curl -s -m 3 https://raw.githubusercontent.com/zelcash/zelflux/master/package.json | jq -r '.version')
-
- if [[ "$required_ver" != "" && "$call_type" != "update_all" ]]; then
-
- if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
-
- echo -e "${ARROW} ${CYAN}You have the current version of Flux ${GREEN}($required_ver)${NC}"
- return
-
- else
- #echo -e "${HOT} ${CYAN}New version of Flux available ${SEA}$required_ver${NC}"
- FLUX_UPDATE="1"
- fi
-
- fi
-
- if [[ "$FLUX_UPDATE" == "1" ]]; then
- cd /home/$USER/$FLUX_DIR && git pull > /dev/null 2>&1 && cd
- current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
- required_ver=$(curl -s -m 3 https://raw.githubusercontent.com/zelcash/zelflux/master/package.json | jq -r '.version')
- if [[ "$required_ver" == "$current_ver" ]]; then
- echo -e "${ARROW} ${CYAN}Flux updated successfully ${GREEN}($required_ver)${NC}"
- else
- echo -e "${ARROW} ${CYAN}Flux was not updated.${NC}"
- echo -e "${ARROW} ${CYAN}Flux force update....${NC}"
- rm /home/$USER/$FLUX_DIR/.git/HEAD.lock >/dev/null 2>&1
- #cd /home/$USER/$FLUX_DIR && npm run hardupdatezelflux
- cd /home/$USER/$FLUX_DIR && git reset --hard HEAD && git clean -f -d && git pull
-
- current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
- required_ver=$(curl -s -m 3 https://raw.githubusercontent.com/zelcash/zelflux/master/package.json | jq -r '.version')
-
- if [[ "$required_ver" == "$current_ver" ]]; then
- echo -e "${ARROW} ${CYAN}Flux updated successfully ${GREEN}($required_ver)${NC}"
- fi
- fi
-
- else
-
- echo -e "${ARROW} ${CYAN}Problem with version veryfication...Flux installation skipped...${NC}"
- fi
-
-}
-
-function fluxdaemon_update()
-{
-
- local_version=$(dpkg -l $COIN_NAME | grep -w "$COIN_NAME" | awk '{print $3}')
-
- if [[ "$type" == "force" ]]; then
- echo -e "${ARROW} ${CYAN}Force Flux daemon updating...${NC}"
- stop_fluxdaemon
- install_package "$COIN_NAME" "flux"
- dpkg_version_after_install=$(dpkg -l $COIN_NAME | grep -w "$COIN_NAME" | awk '{print $3}')
- echo -e "${ARROW} ${CYAN}Flux daemon version before update: ${GREEN}$local_version${NC}"
- echo -e "${ARROW} ${CYAN}Flux daemon version after update: ${GREEN}$dpkg_version_after_install${NC}"
- start_fluxdaemon
- return
- fi
-
-
- remote_version_check "$COIN_NAME"
- #local_version=$($COIN_CLI getinfo | jq -r .version)
- #remote_version=$(curl -s -m3 https://zelcore.io/zelflux/zelcashinfo.php | jq -r .version)
-
- if [[ "$call_type" != "update_all" ]]; then
-
- if [[ "$local_version" == "" || "$remote_version" == "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Problem with version veryfication...Flux daemon installation skipped...${NC}"
- return
-
- fi
-
- if [[ "$local_version" == "$remote_version" ]]; then
-
- echo -e "${ARROW} ${CYAN}You have the current version of Flux daemon ${GREEN}($remote_version)${NC}"
- return
-
- fi
-
- fi
-
- dpkg_version_before_install=$(dpkg -l $COIN_NAME | grep -w "$COIN_NAME" | awk '{print $3}')
- stop_fluxdaemon
-
- sudo apt-get update >/dev/null 2>&1
- sudo apt-get install --only-upgrade $COIN_NAME flux -y >/dev/null 2>&1
- sudo chmod 755 "$COIN_PATH/"*
- sleep 2
-
- dpkg_version_after_install=$(dpkg -l $COIN_NAME | grep -w "$COIN_NAME" | awk '{print $3}')
- echo -e "${ARROW} ${CYAN}Flux daemon version before update: ${GREEN}$local_version${NC}"
- #echo -e "${ARROW} ${CYAN}Flux daemon version after update: ${GREEN}$dpkg_version_after_install${NC}"
-
- if [[ "$dpkg_version_after_install" == "" ]]; then
-
- install_package "$COIN_NAME" "flux"
- dpkg_version_after_install=$(dpkg -l $COIN_NAME | grep -w "$COIN_NAME" | awk '{print $3}')
-
- if [[ "$dpkg_version_after_install" != "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux daemon update successful ${CYAN}(${GREEN}$dpkg_version_after_install${CYAN})${NC}"
- fi
-
- start_fluxdaemon
-
- else
-
- if [[ "$local_version" != "$dpkg_version_after_install" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux daemon update successful ${CYAN}(${GREEN}$dpkg_version_after_install${CYAN})${NC}"
- start_fluxdaemon
-
- fi
-
- if [[ "local_version" == "$dpkg_version_after_install" ]]; then
-
- install_package "$COIN_NAME" "flux"
- dpkg_version_after_install=$(dpkg -l $COIN_NAME | grep -w "$COIN_NAME" | awk '{print $3}')
-
- if [[ "$dpkg_version_after_install" == "$remote_version" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux daemon update successful ${CYAN}(${GREEN}$dpkg_version_after_install${CYAN})${NC}"
- fi
-
- start_fluxdaemon
- fi
-
- fi
-
-}
-
-function check_update()
-{
-
- update_fluxbench="0"
- update_fluxdaemon="0"
- update_flux="0"
-
- local_version_check "$COIN_NAME"
- remote_version_check "$COIN_NAME"
-
- if [[ "$local_version" == "" || "$remote_version" == "" ]]; then
- echo -e "${RED}${ARROW} ${CYAN}Problem with version veryfication...Flux daemon installation skipped...${NC}"
- else
-
- if [[ "$local_version" != "$remote_version" ]]; then
-
- echo -e "${RED}${HOT}${CYAN}New version of Flux daemon available ${SEA}$remote_version${NC}"
- update_fluxdaemon="1"
-
- else
-
- echo -e "${ARROW} ${CYAN}You have the current version of Flux daemon ${GREEN}($remote_version)${NC}"
-
- fi
-
- fi
-
- local_version_check "$BENCH_NAME"
- remote_version_check "$BENCH_NAME"
-
- if [[ "$local_version" == "" || "$remote_version" == "" ]]; then
- echo -e "${RED}${ARROW} ${CYAN}Problem with version veryfication...Flux benchmark installation skipped...${NC}"
- else
-
- if [[ "$local_version" != "$remote_version" ]]; then
-
- echo -e "${RED}${HOT}${CYAN}New version of Flux benchmark available ${SEA}$remote_version${NC}"
- update_fluxbench="1"
-
- else
-
- echo -e "${ARROW} ${CYAN}You have the current version of Flux benchmark ${GREEN}($remote_version)${NC}"
-
- fi
-
- fi
-
- local_version=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
- remote_version=$(curl -s -m 3 https://raw.githubusercontent.com/zelcash/zelflux/master/package.json | jq -r '.version')
-
- if [[ "$local_version" == "" || "$remote_version" == "" ]]; then
- echo -e "${RED}${ARROW} ${CYAN}Problem with version veryfication...Flux installation skipped...${NC}"
- else
-
- if [[ "$local_version" != "$remote_version" ]]; then
-
- echo -e "${RED}${HOT}${CYAN}New version of Flux available ${SEA}$remote_version${NC}"
- update_flux="1"
- FLUX_UPDATE="1"
-
- else
-
- echo -e "${ARROW} ${CYAN}You have the current version of Flux ${GREEN}($remote_version)${NC}"
-
- fi
-
- fi
-
- if [[ "$update_fluxbench" == "1" || "$update_fluxdaemon" == "1" || "$update_flux" == "1" ]]; then
- echo -e ""
- fi
-
-}
-
-#tar_file_unpack file/file_path dir_to_compress
-function tar_file_unpack()
-{
- echo -e "${ARROW} ${YELLOW}Unpacking bootstrap archive file...${NC}"
- pv $1 | tar -zx -C $2
-}
-
-
-#tar_file_pack path_to_pack path_to_archive_file_to_save
-function tar_file_pack()
-{
- echo -e "${ARROW} ${YELLOW}Creating bootstrap archive file...${NC}"
- tar -c --use-compress-program=pigz -f $2 $1
- #tar -czf --use-compress-program=pigz - $1 | (pv -p --timer --rate --bytes > $2) 2>&1
-}
-
-
-
-
-#check_tar file_name
-function check_tar()
-{
- echo -e "${ARROW} ${YELLOW}Checking bootstrap file integration...${NC}"
-
- if gzip -t "$1" &>/dev/null; then
-
- echo -e "${ARROW} ${CYAN}Bootstrap file is valid.................[${CHECK_MARK}${CYAN}]${NC}"
-
- else
-
- echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
- rm -rf $1
-
- fi
-
-}
-
-
-function create_daemon_bootstrap()
-{
-
- sudo apt install zip >/dev/null 2>&1
-
- if "$COIN_CLI" getinfo > /dev/null 2>&1; then
-
-
- local_network_hight=$("$COIN_CLI" getinfo | jq -r .blocks)
- echo -e "${ARROW} ${CYAN}Local Network Block Hight: ${GREEN}$local_network_hight${NC}"
-
- network_height_01=$(curl -sk -m 5 https://explorer.zel.network/api/status?q=getInfo | jq '.info.blocks')
- network_height_02=$(curl -sk -m 5 https://explorer2.zel.network/api/status?q=getInfo | jq '.info.blocks')
- network_height_03=$(curl -sk -m 5 https://explorer.zel.zelcore.io/api/status?q=getInfo | jq '.info.blocks')
-
- explorer_network_hight=$(max "$network_height_01" "$network_height_02" "$network_height_03")
-
- echo -e "${ARROW} ${CYAN}Global Network Block Hight: ${GREEN}$explorer_network_hight${NC}"
-
- if [[ "$explorer_network_hight" == "" || "$local_network_hight" == "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux network veryfication failed...${NC}"
- return
-
- fi
-
-
- check_height=$((explorer_network_hight-local_network_hight))
-
- if [[ "$check_height" -lt 0 ]]; then
-
- check_height=$((check_height*(-1)))
-
- fi
-
- if [[ "$check_height" -lt 15 ]]; then
-
- echo -e "${ARROW} ${CYAN}Local and Global network are synced, diff: ${GREEN}$check_height${NC}"
- else
-
- echo -e "${ARROW} ${CYAN}Local and Global network are not synced, try again later (diff: ${RED}$check_height${CYAN})${NC}"
- return
- fi
-
- data=$(date -u)
- unix=$(date +%s)
- stop_fluxdaemon
- check_zip=$(zip -L | head -n1)
-
- if [[ "$check_zip" != "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- rm -rf /home/$USER/$BOOTSTRAP_ZIPFILE >/dev/null 2>&1 && sleep 5
- #echo -e "${ARROW} ${CYAN}Flux daemon bootstrap creating...${NC}"
- cd /home/$USER/$CONFIG_DIR
- tar_file_pack "blocks chainstate determ_zelnodes" "/home/$USER/$BOOTSTRAP_ZIPFILE"
- #zip /home/$USER/$BOOTSTRAP_ZIPFILE -r blocks chainstate determ_zelnodes
- cd
-
- if [[ -f /home/$USER/$BOOTSTRAP_ZIPFILE ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux daemon bootstrap created successful ${GREEN}($local_network_hight)${NC}"
- rm -rf /home/$USER/daemon_bootstrap.json >/dev/null 2>&1
-
- sudo touch /home/$USER/daemon_bootstrap.json
- sudo chown $USER:$USER /home/$USER/daemon_bootstrap.json
- cat << EOF > /home/$USER/daemon_bootstrap.json
- {
- "block_height": "${explorer_network_hight}",
- "time": "${data}",
- "unix_timestamp": "${unix}"
- }
-EOF
- else
-
- echo -e "${ARROW} ${CYAN}Flux daemon bootstrap creating failed${NC}"
-
- fi
-
- fi
-
- start_fluxdaemon
-
- else
-
- echo -e "${ARROW} ${CYAN}Flux network veryfication failed...Flux daemon not working...${NC}"
- echo
-
- fi
-
-}
-
-function create_mongod_bootstrap()
-{
-
- WANIP=$(wget --timeout=3 --tries=2 http://ipecho.net/plain -O - -q)
-
- if [[ "$WANIP" == "" ]]; then
-
- WANIP=$(curl -s -m 3 ifconfig.me)
-
- if [[ "$WANIP" == "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Public IP address could not be found, action stopped .........[${X_MARK}${CYAN}]${NC}"
- echo
- exit
-
- fi
- fi
-
- local_network_hight=$(curl -s -m 3 http://"$WANIP":16127/explorer/scannedheight | jq '.data.generalScannedHeight')
- echo -e "${ARROW} ${CYAN}Mongod Network Block Hight: ${GREEN}$local_network_hight${NC}"
-
- #explorer_network_hight=$(curl -s -m 3 https://explorer.zel.network/api/status?q=getInfo | jq '.info.blocks')
-
- network_height_01=$(curl -sk -m 5 https://explorer.zel.network/api/status?q=getInfo | jq '.info.blocks')
- network_height_02=$(curl -sk -m 5 https://explorer2.zel.network/api/status?q=getInfo | jq '.info.blocks')
- network_height_03=$(curl -sk -m 5 https://explorer.zel.zelcore.io/api/status?q=getInfo | jq '.info.blocks')
-
- explorer_network_hight=$(max "$network_height_01" "$network_height_02" "$network_height_03")
-
- echo -e "${ARROW} ${CYAN}Global Network Block Hight: ${GREEN}$explorer_network_hight${NC}"
-
- if [[ "$explorer_network_hight" == "" || "$local_network_hight" == "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Flux network veryfication failed...${NC}"
- return
-
- fi
-
- check_height=$((explorer_network_hight-local_network_hight))
-
- if [[ "$check_height" -lt 0 ]]; then
-
- check_height=$((check_height*(-1)))
-
- fi
-
- if [[ "$check_height" -lt 15 ]]; then
-
- echo -e "${ARROW} ${CYAN}Local and Global network are synced, diff: ${GREEN}$check_height${NC}"
-
- else
-
- echo -e "${ARROW} ${CYAN}Local and Global network are not synced, try again later (diff: ${RED}$check_height${CYAN})${NC}"
- return
-
- fi
-
- data=$(date -u)
- unix=$(date +%s)
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- sudo rm -rf /home/$USER/dump >/dev/null 2>&1 && sleep 2
- sudo rm -rf /home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD >/dev/null 2>&1 && sleep 2
-
- echo -e "${ARROW} ${CYAN}Exporting Mongod datetable...${NC}"
- mongodump --port 27017 --db zelcashdata --out /home/$USER/dump/ >/dev/null 2>&1
-
- tar_file_pack "dump" "/home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD"
- #tar -cvzf /home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD dump
- sudo rm -rf /home/$USER/dump >/dev/null 2>&1 && sleep 2
-
- if [[ -f /home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD ]]; then
- echo -e "${ARROW} ${CYAN}Mongod bootstrap created successful ${GREEN}($local_network_hight)${NC}"
- rm -rf /home/$USER/mongodb_bootstrap.json >/dev/null 2>&1
-
- sudo touch /home/$USER/mongodb_bootstrap.json
- sudo chown $USER:$USER /home/$USER/mongodb_bootstrap.json
- cat << EOF > /home/$USER/mongodb_bootstrap.json
- {
- "block_height": "${explorer_network_hight}",
- "time": "${data}",
- "unix_timestamp": "${unix}"
- }
-EOF
-
- else
-
- echo -e "${ARROW} ${CYAN}Mongod bootstrap creating failed${NC}"
-
- fi
-
-}
-
-function clean_mongod() {
-
- echo -e "${ARROW} ${CYAN}Stopping Flux...${NC}"
- pm2 stop flux >/dev/null 2>&1 && sleep 2
- echo -e "${ARROW} ${CYAN}Stopping MongoDB...${NC}"
- sudo systemctl stop mongod >/dev/null 2>&1 && sleep 2
- echo -e "${ARROW} ${CYAN}Removing MongoDB datatable...${NC}"
- # sudo rm -r /var/lib/mongodb >/dev/null 2>&1 && sleep 2
- install_mongod
-
- pm2 start flux > /dev/null 2>&1
- pm2 save > /dev/null 2>&1
-
- NUM='60'
- MSG1='Flux starting...'
- MSG2="${CYAN}.....................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo
-
- #mongodb_bootstrap
-
-}
-
-function mongodb_bootstrap(){
-
- WANIP=$(wget --timeout=3 --tries=2 http://ipecho.net/plain -O - -q)
-
- if [[ "$WANIP" == "" ]]; then
-
- WANIP=$(curl -s -m 3 ifconfig.me)
-
- if [[ "$WANIP" == "" ]]; then
-
- echo -e "${ARROW} ${CYAN}Public IP address could not be found, action stopped .........[${X_MARK}${CYAN}]${NC}"
- echo
- exit
-
- fi
- fi
-
- BLOCKHIGHT=100
- #DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
- DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
- echo -e "${ARROW} ${CYAN}Bootstrap block hight: ${GREEN}$DB_HIGHT${NC}"
-
- if [[ "$BLOCKHIGHT" -gt "0" && "$BLOCKHIGHT" -lt "$DB_HIGHT" ]]; then
-
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$BOOTSTRAP_URL_MONGOD${NC}"
- wget $BOOTSTRAP_URL_MONGOD -q --show-progress
- echo -e "${ARROW} ${CYAN}Unpacking...${NC}"
- #tar xvf $BOOTSTRAP_ZIPFILE_MONGOD -C /home/$USER > /dev/null 2>&1 && sleep 1
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD" "/home/$USER"
-
- echo -e "${ARROW} ${CYAN}Importing mongodb datatable...${NC}"
- mongorestore --port 27017 --db zelcashdata /home/$USER/dump/zelcashdata --drop
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- sudo rm -rf /home/$USER/dump > /dev/null 2>&1 && sleep 1
- sudo rm -rf $BOOTSTRAP_ZIPFILE_MONGOD > /dev/null 2>&1 && sleep 1
- pm2 start flux > /dev/null 2>&1
- pm2 save > /dev/null 2>&1
-
- NUM='120'
- MSG1='Flux starting...'
- MSG2="${CYAN}.....................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo
- BLOCKHIGHT_AFTER_BOOTSTRAP=$(curl -s -m 3 http://"$WANIP":16127/explorer/scannedheight | jq '.data.generalScannedHeight')
- echo -e ${ARROW} ${CYAN}Node block hight after restored: ${GREEN}$BLOCKHIGHT_AFTER_BOOTSTRAP${NC}
-
- if [[ "$BLOCKHIGHT" != "" ]]; then
-
- if [[ "$BLOCKHIGHT" -gt "0" && "$BLOCKHIGHT" -lt "$DB_HIGHT" ]]; then
-
- #echo -e "${ARROW} ${CYAN}Mongo bootstrap installed successful.${NC}"
- string_limit_check_mark "Mongo bootstrap installed successful.................................."
- echo -e ""
- else
- #echo -e "${ARROW} ${CYAN}Mongo bootstrap installation failed.${NC}"
- string_limit_x_mark "Mongo bootstrap installation failed.................................."
- echo -e ""
- fi
-
- else
- echo -e "${ARROW} ${CYAN}Current Node block hight ${RED}$BLOCKHIGHT${CYAN} > Bootstrap block hight ${RED}$DB_HIGHT${CYAN}. Datatable is out of date.${NC}"
- echo -e ""
- fi
- fi
-
-}
-
-function install_mongod() {
-
- sudo rm /etc/apt/sources.list.d/mongodb*.list > /dev/null 2>&1
- if [[ $(lsb_release -r) = *16.* ]]; then
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc 2> /dev/null | sudo apt-key add - > /dev/null 2>&1
- echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- elif [[ $(lsb_release -r) = *18.* || $(lsb_release -r) = *19.* ]]; then
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc 2> /dev/null | sudo apt-key add - > /dev/null 2>&1
- echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- elif [[ $(lsb_release -r) = *20.* ]]; then
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc 2> /dev/null | sudo apt-key add - > /dev/null 2>&1
- echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- elif [[ $(lsb_release -d) = *Debian* ]] && [[ $(lsb_release -d) = *9* ]]; then
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc 2> /dev/null | sudo apt-key add - > /dev/null 2>&1
- echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.4 main" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- elif [[ $(lsb_release -d) = *Debian* ]] && [[ $(lsb_release -d) = *10* ]]; then
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc 2> /dev/null | sudo apt-key add - > /dev/null 2>&1
- echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
-
- else
- echo -e "${WORNING}${CYAN}ERROR: OS version not supported"
- echo -e "${WORNING}${CYAN}Installation stopped..."
- echo
- exit
- fi
-
- sleep 2
- echo -e "${ARROW} ${YELLOW}Removing any instances of Mongodb...${NC}"
- sudo apt remove mongod* -y > /dev/null 2>&1 && sleep 1
- sudo apt purge mongod* -y > /dev/null 2>&1 && sleep 1
- sudo apt autoremove -y > /dev/null 2>&1 && sleep 1
- echo -e "${ARROW} ${YELLOW}Mongodb installing...${NC}"
- sudo apt-get update -y > /dev/null 2>&1
- sudo apt-get install mongodb-org -y > /dev/null 2>&1 && sleep 2
- sudo systemctl enable mongod > /dev/null 2>&1
- sudo systemctl start mongod > /dev/null 2>&1
-
- if mongod --version > /dev/null 2>&1
- then
- #echo -e "${ARROW} ${CYAN}MongoDB version: ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed${NC}"
- string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
- echo
- else
- #echo -e "${ARROW} ${CYAN}MongoDB was not installed${NC}"
- string_limit_x_mark "MongoDB was not installed................................."
- echo
- fi
-}
-
-function swapon_create()
-{
- MEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
- gb=$(awk "BEGIN {print $MEM/1048576}")
- GB=$(echo "$gb" | awk '{printf("%d\n",$1 + 0.5)}')
- if [ "$GB" -lt 2 ]; then
- (( swapsize=GB*2 ))
- swap="$swapsize"G
- #echo -e "${YELLOW}Swap set at $swap...${NC}"
- elif [[ $GB -ge 2 ]] && [[ $GB -le 16 ]]; then
- swap=4G
- # echo -e "${YELLOW}Swap set at $swap...${NC}"
- elif [[ $GB -gt 16 ]] && [[ $GB -lt 32 ]]; then
- swap=2G
- #echo -e "${YELLOW}Swap set at $swap...${NC}"
- fi
-
- if ! grep -q "swapfile" /etc/fstab; then
-
- if whiptail --yesno "No swapfile detected would you like to create one?" 8 54; then
- sudo fallocate -l "$swap" /swapfile > /dev/null 2>&1
- sudo chmod 600 /swapfile > /dev/null 2>&1
- sudo mkswap /swapfile > /dev/null 2>&1
- sudo swapon /swapfile > /dev/null 2>&1
- echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab > /dev/null 2>&1
- echo -e "${ARROW} ${YELLOW}Created ${SEA}${swap}${YELLOW} swapfile${NC}"
- else
- echo -e "${ARROW} ${YELLOW}Creating a swapfile skipped...${NC}"
- fi
-
- fi
-}
-
-
-
-function unlock_flux_resouce()
-{
-
- docker_check=$(docker ps | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
- resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
- mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
-
- if [[ "$mongod_check" != "" && "$mongod_check" != "null" && "$1" == "clean_db" ]]; then
-
- echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1
- echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1
- echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
-
- fi
-
- if [[ $docker_check != 0 ]]; then
- echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1
- echo -e "${ARROW} ${CYAN}Stopping containers...${NC}"
- docker ps | grep -Eo "^[0-9a-z]{8,}\b" |
-
- while read line; do
- sudo docker stop $line && sleep 2
- sudo docker rm $line && sleep 2
- done
- fi
-
- if [[ $resource_check != 0 ]]; then
- echo -e "${ARROW} ${YELLOW}Detected locked resource${NC}" && sleep 1
- echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}" && sleep 1
- df | egrep 'flux' | awk '{ print $1}' |
-
- while read line; do
- sudo umount $line && sleep 1
- done
- fi
-
- echo
-}
-
-
-function create_kda_bootstrap {
-
- kda_bootstrap_daemon="0"
-
- WANIP=$(wget --timeout=3 --tries=2 http://ipecho.net/plain -O - -q)
- if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl -s -m 3 ifconfig.me)
- if [[ "$WANIP" == "" ]]; then
- echo -e "${ARROW} ${CYAN}Local IP address could not be found, action stopped .........[${X_MARK}${CYAN}]${NC}"
- echo
- exit
- fi
- fi
-
- if [ ! -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db ]; then
- echo -e "${ARROW} ${CYAN}Kadena Node chain directory does not exist, operation stopped...${NC}"
- echo
- exit
- fi
-
- network_height_node_01=$(curl -sk -m 3 https://us-e1.chainweb.com/chainweb/0.0/mainnet01/cut | jq '.height')
- network_height_node_02=$(curl -sk -m 3 https://us-e2.chainweb.com/chainweb/0.0/mainnet01/cut | jq '.height')
- network_height_node_03=$(curl -sk -m 3 https://fr1.chainweb.com/chainweb/0.0/mainnet01/cut | jq '.height')
-
- network_height=$(max "$network_height_node_01" "$network_height_node_02" "$network_height_node_03")
- echo -e "${ARROW} ${CYAN}Kadena Global Network Height: ${GREEN}$network_height${NC}"
- kda_height=$(curl -sk https://$WANIP:30004/chainweb/0.0/mainnet01/cut | jq '.height')
- echo -e "${ARROW} ${CYAN}Kadena Local Node Height: ${GREEN}$kda_height${NC}"
-
- check_height=$((network_height-kda_height))
-
- if [[ "$check_height" -lt 0 ]]; then
- check_height=$((check_height*(-1)))
- fi
-
- if [[ "$check_height" -lt 2000 ]]; then
- echo -e "${ARROW} ${CYAN}Local and Global network are synced, diff: ${GREEN}$check_height${NC}"
- echo
- else
- echo -e "${ARROW} ${CYAN}Local and Global network are not synced, try again later (diff: ${RED}$check_height${CYAN})${NC}"
- echo
- exit
- fi
-
- if [[ "$kda_height" != "" && "$kda_height" != "null" ]]; then
-
- sudo rm -rf /home/$USER/$KDA_BOOTSTRAP_ZIPFILE >/dev/null 2>&1 && sleep 2
-
- data=$(date -u)
- unix=$(date +%s)
- docker_check=$(docker ps | grep 'zelKadenaChainWebNode' | wc -l)
-
- if [[ "$docker_check" != "" && "$docker_check" != "0" ]]; then
-
- echo -e "${ARROW} ${CYAN}Stopping Kadena Node...${NC}"
- docker stop zelKadenaChainWebNode > /dev/null 2>&1
-
- #echo -e "${ARROW} ${CYAN}Bootstrap file creating...${NC}"
- cd /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0
- #zip /home/$USER/$KDA_BOOTSTRAP_ZIPFILE -r chainweb-db
- tar_file_pack "rocksDb sqlite" "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE"
- cd
-
- if [[ -f /home/$USER/$KDA_BOOTSTRAP_ZIPFILE ]]; then
- kda_bootstrap_daemon="1"
- rm -rf /home/$USER/kda_bootstrap.json >/dev/null 2>&1
-
- sudo touch /home/$USER/kda_bootstrap.json
- sudo chown $USER:$USER /home/$USER/kda_bootstrap.json
- cat << EOF > /home/$USER/kda_bootstrap.json
- {
- "block_height": "${kda_height}",
- "time": "${data}",
- "unix_timestamp": "${unix}"
- }
-EOF
- fi
-
- echo -e "${ARROW} ${CYAN}Starting Kadena Node...${NC}"
- docker start zelKadenaChainWebNode > /dev/null 2>&1
-
- fi
-
- fi
-
-
- if [[ "$kda_bootstrap_daemon" == "0" ]]; then
- echo -e "${ARROW} ${CYAN}Kadena Node bootstrap creating failed...${NC}"
- else
- echo -e "${ARROW} ${CYAN}Kadena Node bootstrap created successful ${GREEN}($kda_height)${NC}"
- fi
-
-}
-
-function daemon_bootstrap() {
-
-
- echo -e "${ARROW} ${CYAN}Stopping Flux daemon service${NC}"
- sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
- sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
-
- if [[ -e ~/$CONFIG_DIR/blocks ]] && [[ -e ~/$CONFIG_DIR/chainstate ]]; then
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- rm -rf ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate ~/$CONFIG_DIR/determ_zelnodes
- fi
-
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
- echo -e "${ARROW} ${CYAN}Local bootstrap file detected...${NC}"
- check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
-
- fi
-
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
-
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- #unzip -o $KDA_BOOTSTRAP_ZIPFILE -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode > /dev/null 2>&1
-
- else
-
- echo -e "${ARROW} ${CYAN}Bootstrap file downloading...${NC}" && sleep 2
-
- CHOICE=$(
- whiptail --title "Bootstrap installation" --menu "Choose a method how to get bootstrap file" 10 47 2 \
- "1)" "Download from source build in script" \
- "2)" "Download from own source" 3>&2 2>&1 1>&3
- )
-
-
- case $CHOICE in
- "1)")
- DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
- echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
-
- ;;
- "2)")
- BOOTSTRAP_ZIP="$(whiptail --title "Flux daemon bootstrap source" --inputbox "Enter your URL" 8 72 3>&1 1>&2 2>&3)"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- #unzip -o $KDA_BOOTSTRAP_ZIPFILE -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode > /dev/null 2>&1
- ;;
- esac
-
- fi
-
- if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
-
- sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2
- NUM='35'
- MSG1='Starting Flux daemon service...'
- MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo -e "" && echo -e ""
-
-}
-
-function kda_bootstrap() {
-
- sudo chown -R $USER:$USER /home/$USER/$FLUX_DIR
- echo -e "${ARROW} ${CYAN}Stopping Kadena Node...${NC}"
- docker stop zelKadenaChainWebNode > /dev/null 2>&1 && sleep 2
-
- if [[ -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db ]]; then
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- rm -rf /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db
- fi
-
- mkdir -p /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0 > /dev/null 2>&1
-
-
- if [ -f "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" ]; then
-
- echo -e "${ARROW} ${CYAN}Local bootstrap file detected...${NC}"
- check_tar "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE"
-
- fi
-
-
- if [ -f "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" ]; then
-
- tar_file_unpack "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" "/home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0"
- sleep 2
- #unzip -o $KDA_BOOTSTRAP_ZIPFILE -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode > /dev/null 2>&1
-
- else
-
- echo -e "${ARROW} ${CYAN}Bootstrap file downloading...${NC}" && sleep 2
-
- CHOICE=$(
- whiptail --title "Bootstrap installation" --menu "Choose a method how to get bootstrap file" 10 47 2 \
- "1)" "Download from source build in script" \
- "2)" "Download from own source" 3>&2 2>&1 1>&3
- )
-
-
- case $CHOICE in
- "1)")
- DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/kda_bootstrap.json | jq -r '.block_height')
- echo -e "${ARROW} ${CYAN}KDA Bootstrap height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$KDA_BOOTSTRAP_ZIP ${NC}"
- wget -O $KDA_BOOTSTRAP_ZIPFILE $KDA_BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" "/home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0"
- sleep 2
-
- ;;
- "2)")
- KDA_BOOTSTRAP_ZIP="$(whiptail --title "Kadena node bootstrap source (*.tar.gz, *.zip file supported)" --inputbox "Enter your URL" 8 72 3>&1 1>&2 2>&3)"
- KDA_BOOTSTRAP_ZIPFILE="${KDA_BOOTSTRAP_ZIP##*/}"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$KDA_BOOTSTRAP_ZIP ${NC}"
- wget -O $KDA_BOOTSTRAP_ZIPFILE $KDA_BOOTSTRAP_ZIP -q --show-progress
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $KDA_BOOTSTRAP_ZIPFILE -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0 > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" "/home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0"
-
- fi
- sleep 2
- ;;
- esac
-
- fi
-
- if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
- rm -rf $KDA_BOOTSTRAP_ZIPFILE
- fi
-
- docker start zelKadenaChainWebNode > /dev/null 2>&1
- NUM='15'
- MSG1='Starting Kadena Node...'
- MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo -e ""
- echo -e "${ARROW} ${CYAN}Kadena Node initial process can take about ~15min. ${NC}"
- echo -e ""
-
-}
-
-if ! pv -V > /dev/null 2>&1
-then
-sudo apt-get install -y pv > /dev/null 2>&1
-fi
-
-if ! gzip -V > /dev/null 2>&1
-then
-sudo apt-get install -y gzip > /dev/null 2>&1
-fi
-
-if ! zip -v > /dev/null 2>&1
-then
-sudo apt-get install -y zip > /dev/null 2>&1
-fi
-
-if ! pigz -V > /dev/null 2>&1
-then
-sudo apt-get install -y pigz > /dev/null 2>&1
-fi
-
-
-
-
-
- case $call_type in
-
- "update_all")
-
- check_update
- if [[ "$update_flux" == "1" ]]; then
- flux_update
- fi
-
- if [[ "$update_fluxbench" == "1" ]]; then
- fluxbench_update
- fi
-
- if [[ "$update_fluxdaemon" == "1" ]]; then
- fluxdaemon_update
- fi
- echo
- ;;
-
- "fluxdaemon_update")
- echo
- fluxdaemon_update
- echo
- ;;
-
- "fluxbench_update")
- echo
- fluxbench_update
- echo
- ;;
-
- "flux_update")
- echo
- flux_update
- echo
- ;;
-
- "flux_restart")
- echo
- restart_fluxdaemon
- echo
- ;;
-
- "flux_reindex")
- echo
- reindex
- echo
- ;;
-
- "create_daemon_bootstrap")
- echo
- create_daemon_bootstrap
- echo
- ;;
-
- "daemon_bootstrap")
- echo
- daemon_bootstrap
- echo
- ;;
-
- "mongod_bootstrap")
- echo
- echo -e "${ARROW} ${CYAN}Stopping Flux...${NC}"
- pm2 stop flux >/dev/null 2>&1 && sleep 2
- mongodb_bootstrap
- echo
- ;;
-
- "create_mongod_bootstrap")
- echo
- create_mongod_bootstrap
- echo
- ;;
-
- "create_kda_bootstrap")
- echo
- create_kda_bootstrap
- echo
- ;;
-
- "clean_mongod")
- echo
- clean_mongod
- echo
- ;;
-
- "swapon_create")
- echo
- swapon_create
- echo
- ;;
-
- "unlock_flux_resouce")
- echo
- unlock_flux_resouce "$type"
- echo
- ;;
-
- "kda_bootstrap")
- echo
- kda_bootstrap
- echo
- ;;
-
- esac
diff --git a/image/Menu12.jpg b/image/Menu12.jpg
new file mode 100644
index 00000000..575b4db4
Binary files /dev/null and b/image/Menu12.jpg differ
diff --git a/image/development.jpg b/image/development.jpg
new file mode 100644
index 00000000..0473a31d
Binary files /dev/null and b/image/development.jpg differ
diff --git a/image/discord1.png b/image/discord1.png
new file mode 100644
index 00000000..a24149b8
Binary files /dev/null and b/image/discord1.png differ
diff --git a/image/main.jpg b/image/main.jpg
new file mode 100644
index 00000000..323d2f6f
Binary files /dev/null and b/image/main.jpg differ
diff --git a/image/new_menu_v3.jpg b/image/new_menu_v3.jpg
new file mode 100644
index 00000000..33ec4485
Binary files /dev/null and b/image/new_menu_v3.jpg differ
diff --git a/image/update_menu.png b/image/update_menu.png
new file mode 100644
index 00000000..abb5ef86
Binary files /dev/null and b/image/update_menu.png differ
diff --git a/image/v6.png b/image/v6.png
new file mode 100644
index 00000000..92495a25
Binary files /dev/null and b/image/v6.png differ
diff --git a/install_pro.sh b/install_pro.sh
old mode 100644
new mode 100755
index c3dc5523..ce51041e
--- a/install_pro.sh
+++ b/install_pro.sh
@@ -1,1932 +1,649 @@
#!/bin/bash
-# Bootstrap settings
-BOOTSTRAP_ZIP='https://fluxnodeservice.com/daemon_bootstrap.tar.gz'
-BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz'
-BOOTSTRAP_URL_MONGOD='https://fluxnodeservice.com/mongod_bootstrap.tar.gz'
-BOOTSTRAP_ZIPFILE_MONGOD='mongod_bootstrap.tar.gz'
-
+source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/flux_common.sh)"
#wallet information
COIN_NAME='flux'
CONFIG_DIR='.flux'
CONFIG_FILE='flux.conf'
-
BENCH_NAME='fluxbench'
BENCH_CLI='fluxbench-cli'
BENCH_DIR_LOG='.fluxbenchmark'
-
COIN_DAEMON='fluxd'
COIN_CLI='flux-cli'
COIN_PATH='/usr/local/bin'
-
USERNAME="$(whoami)"
FLUX_DIR='zelflux'
-
#Install variable
IMPORT_ZELCONF="0"
IMPORT_ZELID="0"
CORRUPTED="0"
BOOTSTRAP_SKIP="0"
WATCHDOG_INSTALL="0"
-
+SKIP_OLD_CHAIN="0"
#Zelflux ports
ZELFRONTPORT=16126
LOCPORT=16127
ZELNODEPORT=16128
-MDBPORT=27017
-RPCPORT=16124
-PORT=16125
-
-#color codes
-RED='\033[1;31m'
-YELLOW='\033[1;33m'
-BLUE="\\033[38;5;27m"
-SEA="\\033[38;5;49m"
-GREEN='\033[1;32m'
-CYAN='\033[1;36m'
-NC='\033[0m'
-
-#emoji codes
-CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}"
-X_MARK="${RED}\xE2\x9C\x96${NC}"
-PIN="${RED}\xF0\x9F\x93\x8C${NC}"
-CLOCK="${GREEN}\xE2\x8C\x9B${NC}"
-ARROW="${SEA}\xE2\x96\xB6${NC}"
-BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
-HOT="${ORANGE}\xF0\x9F\x94\xA5${NC}"
-WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
-
-#dialog color
-export NEWT_COLORS='
-title=black,
-'
-function string_limit_check_mark() {
-if [[ -z "$2" ]]; then
-string="$1"
-string=${string::40}
-else
-string=$1
-string_color=$2
-string_leght=${#string}
-string_leght_color=${#string_color}
-string_diff=$((string_leght_color-string_leght))
-string=${string_color::40+string_diff}
-fi
-echo -e "${ARROW} ${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
-}
-
-function max(){
-
- m="0"
- for n in "$@"
- do
- if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then
- [ "$n" -gt "$m" ] && m="$n"
- fi
- done
-
- echo "$m"
-
-}
-
-function string_limit_x_mark() {
-if [[ -z "$2" ]]; then
-string="$1"
-string=${string::40}
-else
-string=$1
-string_color=$2
-string_leght=${#string}
-string_leght_color=${#string_color}
-string_diff=$((string_leght_color-string_leght))
-string=${string_color::40+string_diff}
-fi
-echo -e "${ARROW} ${CYAN}$string[${X_MARK}${CYAN}]${NC}"
-}
-
-
-function integration_check() {
-FILE_ARRAY=( 'fluxbench-cli' 'fluxbenchd' 'flux-cli' 'fluxd' 'flux-fetch-params.sh' 'flux-tx' )
-ELEMENTS=${#FILE_ARRAY[@]}
-
-for (( i=0;i<$ELEMENTS;i++)); do
-
-string="${FILE_ARRAY[${i}]}................................."
-string=${string::40}
-
-if [ -f "$COIN_PATH/${FILE_ARRAY[${i}]}" ]; then
- echo -e "${ARROW}${CYAN} $string[${CHECK_MARK}${CYAN}]${NC}"
-else
- echo -e "${ARROW}${CYAN} $string[${X_MARK}${CYAN}]${NC}"
- CORRUPTED="1"
-fi
-
-done
-
-if [[ "$CORRUPTED" == "1" ]]; then
- echo -e "${WORNING} ${CYAN}Flux daemon package corrupted...${NC}"
- echo -e "${WORNING} ${CYAN}Will exit out so try and run the script again...${NC}"
- echo
- exit
-fi
-echo -e ""
-}
-
-
-function config_file() {
-
-if [[ -f /home/$USER/install_conf.json ]]; then
-import_settings=$(cat /home/$USER/install_conf.json | jq -r '.import_settings')
-ssh_port=$(cat /home/$USER/install_conf.json | jq -r '.ssh_port')
-firewall_disable=$(cat /home/$USER/install_conf.json | jq -r '.firewall_disable')
-bootstrap_url=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_url')
-bootstrap_zip_del=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_zip_del')
-swapon=$(cat /home/$USER/install_conf.json | jq -r '.swapon')
-mongo_bootstrap=$(cat /home/$USER/install_conf.json | jq -r '.mongo_bootstrap')
-watchdog=$(cat /home/$USER/install_conf.json | jq -r '.watchdog')
-use_old_chain=$(cat /home/$USER/install_conf.json | jq -r '.use_old_chain')
-prvkey=$(cat /home/$USER/install_conf.json | jq -r '.prvkey')
-outpoint=$(cat /home/$USER/install_conf.json | jq -r '.outpoint')
-index=$(cat /home/$USER/install_conf.json | jq -r '.index')
-ZELID=$(cat /home/$USER/install_conf.json | jq -r '.zelid')
-KDA_A=$(cat /home/$USER/install_conf.json | jq -r '.kda_address')
-
-echo
-echo -e "${ARROW} ${YELLOW}Install config:"
-
-if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then
-echo -e "${PIN}${CYAN} Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-
-if [[ "$import_settings" == "1" ]]; then
-echo -e "${PIN}${CYAN} Import settings from Flux..............[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-fi
-
-if [[ "$ssh_port" != "" ]]; then
-echo -e "${PIN}${CYAN} SSH port set.....................................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$firewall_disable" == "1" ]]; then
-echo -e "${PIN}${CYAN} Firewall disabled diuring installation...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-echo -e "${PIN}${CYAN} Firewall enabled diuring installation............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$use_old_chain" == "1" ]]; then
-echo -e "${PIN}${CYAN} Diuring re-installation old chain will be use....................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-
-else
-
-if [[ "$bootstrap_url" == "" ]]; then
-echo -e "${PIN}${CYAN} Use Flux daemon bootstrap from source build in scripts...............[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-echo -e "${PIN}${CYAN} Use Flux daemon bootstrap from own source............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$bootstrap_zip_del" == "1" ]]; then
-echo -e "${PIN}${CYAN} Remove Flux daemon bootstrap archive file............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-echo -e "${PIN}${CYAN} Leave Flux daemon bootstrap archive file.............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-fi
-
-if [[ "$swapon" == "1" ]]; then
-echo -e "${PIN}${CYAN} Create a file that will be used for swap.........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$mongo_bootstrap" == "1" ]]; then
-echo -e "${PIN}${CYAN} Use Bootstrap for MongoDB........................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$watchdog" == "1" ]]; then
-echo -e "${PIN}${CYAN} Install watchdog.................................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
+#MDBPORT=27017
-
-fi
-}
-
-function round() {
- printf "%.${2}f" "${1}"
-}
-
-function check_benchmarks() {
-
- var_benchmark=$($BENCH_CLI getbenchmarks | jq ".$1")
- limit=$2
- if [[ $(echo "$limit>$var_benchmark" | bc) == "1" ]]
- then
- var_round=$(round "$var_benchmark" 2)
- echo -e "${X_MARK} ${CYAN}$3 $var_round $4${NC}"
- fi
-
+function config_veryfity(){
+ if [[ -f /home/$USER/.flux/flux.conf ]]; then
+ echo -e "${ARROW} ${YELLOW}Checking config file...${NC}"
+ insightexplorer=$(cat /home/$USER/.flux/flux.conf | grep 'insightexplorer=1' | wc -l)
+ if [[ "$insightexplorer" == "1" ]]; then
+ echo -e "${ARROW} ${CYAN}Insightexplorer enabled.................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${ARROW} ${CYAN}Insightexplorer enabled.................[${X_MARK}${CYAN}]${NC}"
+ echo -e "${ARROW} ${CYAN}Removing wallet.dat...${NC}"
+ echo -e "${ARROW} ${CYAN}Use old chain will be skipped...${NC}"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/wallet.dat && sleep 1
+ SKIP_OLD_CHAIN="1"
+ fi
+ fi
}
-
function import_date() {
-
-if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE || -f /home/$USER/.zelcash/zelcash.conf ]]; then
-
- if [[ -z "$import_settings" ]]; then
-
- if whiptail --yesno "Would you like to import data from Flux config files Y/N?" 8 60; then
-
- OLD_CONFIG=0
-
- if [[ -d /home/$USER/.zelcash ]]; then
- CONFIG_DIR='.zelcash'
- CONFIG_FILE='zelcash.conf'
- OLD_CONFIG=1
- fi
-
- IMPORT_ZELCONF="1"
- echo
- echo -e "${ARROW} ${YELLOW}Imported settings:${NC}"
- zelnodeprivkey=$(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//')
- echo -e "${PIN}${CYAN} Private Key = ${GREEN}$zelnodeprivkey${NC}" && sleep 1
- zelnodeoutpoint=$(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
- echo -e "${PIN}${CYAN} Output TX ID = ${GREEN}$zelnodeoutpoint${NC}" && sleep 1
- zelnodeindex=$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
- echo -e "${PIN}${CYAN} Output Index = ${GREEN}$zelnodeindex${NC}" && sleep 1
-
- if [[ "$OLD_CONFIG" == "1" ]]; then
- CONFIG_DIR='.flux'
- CONFIG_FILE='flux.conf'
- fi
-
- if [[ -f ~/$FLUX_DIR/config/userconfig.js ]]; then
-
- ZELID=$(grep -w zelid ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
-
- if [[ "$ZELID" != "" ]]; then
- echo -e "${PIN}${CYAN} Zel ID = ${GREEN}$ZELID${NC}" && sleep 1
- IMPORT_ZELID="1"
- fi
-
- KDA_A=$(grep -w kadena ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
- if [[ "$KDA_A" != "" ]]; then
- echo -e "${PIN}${CYAN} KDA address = ${GREEN}$KDA_A${NC}" && sleep 1
- fi
-
- fi
- fi
-
-else
-
- if [[ "$import_settings" == "1" ]]; then
-
- OLD_CONFIG=0
-
- if [[ -d /home/$USER/.zelcash ]]; then
- CONFIG_DIR='.zelcash'
- CONFIG_FILE='zelcash.conf'
- OLD_CONFIG=1
- fi
-
- IMPORT_ZELCONF="1"
- echo
- echo -e "${ARROW} ${YELLOW}Imported settings:${NC}"
- zelnodeprivkey=$(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//')
- echo -e "${PIN}${CYAN} Private Key = ${GREEN}$zelnodeprivkey${NC}" && sleep 1
- zelnodeoutpoint=$(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
- echo -e "${PIN}${CYAN} Output TX ID = ${GREEN}$zelnodeoutpoint${NC}" && sleep 1
- zelnodeindex=$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
- echo -e "${PIN}${CYAN} Output Index = ${GREEN}$zelnodeindex${NC}" && sleep 1
-
- if [[ "$OLD_CONFIG" == "1" ]]; then
- CONFIG_DIR='.flux'
- CONFIG_FILE='flux.conf'
- fi
-
-
- if [[ -f ~/$FLUX_DIR/config/userconfig.js ]]; then
-
- ZELID=$(grep -w zelid ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
-
- if [[ "$ZELID" != "" ]]; then
- echo -e "${PIN}${CYAN} Zel ID = ${GREEN}$ZELID${NC}" && sleep 1
- IMPORT_ZELID="1"
- fi
-
- KDA_A=$(grep -w kadena ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
- if [[ "$KDA_A" != "" ]]; then
- echo -e "${PIN}${CYAN} KDA address = ${GREEN}$KDA_A${NC}" && sleep 1
- fi
- fi
- fi
-
- fi
-fi
-sleep 1
-echo
-}
-
-function tar_file_unpack()
-{
- echo -e "${ARROW} ${YELLOW}Unpacking bootstrap archive file...${NC}"
- pv $1 | tar -zx -C $2
-}
-
-
-function check_tar()
-{
- echo -e "${ARROW} ${YELLOW}Checking bootstrap file integration...${NC}"
-
- if gzip -t "$1" &>/dev/null; then
-
- echo -e "${ARROW} ${CYAN}Bootstrap file is valid.................[${CHECK_MARK}${CYAN}]${NC}"
-
- else
-
- echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
- rm -rf $1
-
- fi
+ if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then
+ if [[ -z "$import_settings" ]]; then
+ if whiptail --yesno "Would you like to import data from Flux config files Y/N?" 8 60; then
+ config_smart_create "import"
+ IMPORT_ZELCONF="1"
+ if [[ "$ZELID" != "" ]]; then
+ IMPORT_ZELID="1"
+ fi
+ fi
+ else
+ if [[ "$import_settings" == "1" ]]; then
+ config_smart_create "import"
+ IMPORT_ZELCONF="1"
+ if [[ "$ZELID" != "" ]]; then
+ IMPORT_ZELID="1"
+ fi
+ fi
+ fi
+ fi
+ echo -e ""
}
-
-
function install_watchdog() {
-echo -e "${ARROW} ${YELLOW}Install watchdog for FluxNode${NC}"
-if pm2 -v > /dev/null 2>&1
-then
-WATCHDOG_INSTALL="1"
-echo -e "${ARROW} ${YELLOW}Downloading...${NC}"
-cd && git clone https://github.com/XK4MiLX/watchdog.git > /dev/null 2>&1
-echo -e "${ARROW} ${YELLOW}Installing git hooks....${NC}"
-wget https://raw.githubusercontent.com/XK4MiLX/zelnode/master/post-merge > /dev/null 2>&1
-mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
-sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
-echo -e "${ARROW} ${YELLOW}Installing watchdog module....${NC}"
-cd watchdog && npm install > /dev/null 2>&1
-echo -e "${ARROW} ${YELLOW}Starting watchdog...${NC}"
-pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 10 > /dev/null 2>&1
-pm2 save > /dev/null 2>&1
-if [[ -f /home/$USER/watchdog/watchdog.js ]]
-then
-current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
-#echo -e "${ARROW} ${CYAN}Watchdog ${GREEN}v$current_ver${CYAN} installed successful.${NC}"
-string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................."
-else
-#echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}"
-string_limit_x_mark "Watchdog was not installed................................."
-fi
-else
-#echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}"
-string_limit_x_mark "Watchdog was not installed................................."
-fi
-}
-
-function mongodb_bootstrap(){
-
- echo -e ""
- echo -e "${ARROW} ${YELLOW}Restore mongodb datatable from bootstrap${NC}"
-
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
- if [[ "$DB_HIGHT" == "" ]]; then
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
- fi
-
- #BLOCKHIGHT=$(curl -s -m 6 http://"$WANIP":16127/explorer/scannedheight | jq '.data.generalScannedHeight')
- echo -e "${ARROW} ${CYAN}Bootstrap block height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$BOOTSTRAP_URL_MONGOD${NC}"
- wget --tries=5 $BOOTSTRAP_URL_MONGOD -q --show-progress
-
- if [[ -f /home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD ]]; then
-
- echo -e "${ARROW} ${CYAN}Unpacking...${NC}"
- tar xvf $BOOTSTRAP_ZIPFILE_MONGOD -C /home/$USER > /dev/null 2>&1 && sleep 1
- echo -e "${ARROW} ${CYAN}Importing mongodb datatable...${NC}"
- mongorestore --port 27017 --db zelcashdata /home/$USER/dump/zelcashdata --drop > /dev/null 2>&1
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- sudo rm -rf /home/$USER/dump > /dev/null 2>&1 && sleep 1
- sudo rm -rf $BOOTSTRAP_ZIPFILE_MONGOD > /dev/null 2>&1 && sleep 1
-
-
- BLOCKHIGHT_AFTER_BOOTSTRAP=$(mongoexport -d zelcashdata -c scannedheight --jsonArray --pretty --quiet | jq -r .[].generalScannedHeight)
- echo -e ${ARROW} ${CYAN}Node block hight after restored: ${GREEN}$BLOCKHIGHT_AFTER_BOOTSTRAP${NC}
-
- else
-
- echo -e "${ARROW} ${RED}MongoDB bootstrap server offline...try again later use option 5${NC}"
- fi
-
- echo -e ""
-
- #if [[ "$BLOCKHIGHT_AFTER_BOOTSTRAP" -ge "$DB_HIGHT" ]]; then
- #echo -e "${ARROW} ${CYAN}Mongo bootstrap installed successful.${NC}"
- #echo -e ""
- # else
- # echo -e "${ARROW} ${CYAN}Mongo bootstrap installation failed.${NC}"
- # echo -e ""
- # fi
-
+ echo -e "${ARROW} ${YELLOW}Watchdog installing...${NC}"
+ if pm2 -v > /dev/null 2>&1; then
+ WATCHDOG_INSTALL="1"
+ cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1
+ wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1
+ mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
+ sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
+ cd watchdog && npm install > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Creating config file....${NC}"
+ fix_action='1'
+ if [[ "$import_settings" == "0" && -f /home/$USER/install_conf.json ]]; then
+ watchdog_conf_create
+ if [[ -f /home/$USER/watchdog/watchdog.js ]]; then
+ current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
+ string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................."
+ pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ else
+ string_limit_x_mark "Watchdog was not installed................................."
+ fi
+ return
+ fi
+ if [[ "$IMPORT_ZELCONF" == "1" ]]; then
+ watchdog_conf_create
+ if [[ -f /home/$USER/watchdog/watchdog.js ]]; then
+ current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
+ string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................."
+ pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ else
+ string_limit_x_mark "Watchdog was not installed................................."
+ fi
+ return
+ fi
+ if whiptail --yesno "Would you like enable autoupdate?" 8 60; then
+ flux_update='1'
+ daemon_update='1'
+ bench_update='1'
+ else
+ flux_update='0'
+ daemon_update='0'
+ bench_update='0'
+ fi
+ discord='0'
+ if whiptail --yesno "Would you like enable alert notification?" 8 60; then
+ sleep 1
+ whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60
+ sleep 1
+ CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \
+ "1" "Discord notification " ON \
+ "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 )
+ if [ -z "$CHOICES" ]; then
+ echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}"
+ sleep 1
+ discord="0"
+ ping="0"
+ telegram_alert="0"
+ telegram_bot_token="0"
+ telegram_chat_id="0"
+ node_label="0"
+ else
+ for CHOICE in $CHOICES;
+ do
+ case "$CHOICE" in
+ "1")
+ discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+ if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then
+ try="0"
+ while true
+ do
+ ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3)
+ if [[ $ping == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "UserID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "UserID is not valid try again............................."
+ sleep 1
+ try=$(($try+1))
+ if [[ "$try" -gt "3" ]]; then
+ echo -e "${WORNING} ${CYAN}You have reached the maximum number of attempts...${NC}"
+ echo -e "${WORNING} ${CYAN}Disabling ping but continue watchdog install ...${NC}"
+ ping=0;
+ break
+ fi
+ fi
+ done
+ sleep 1
+ else
+ ping=0;
+ sleep 1
+ fi
+ ;;
+ "2")
+ telegram_alert="1"
+ while true
+ do
+ telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3)
+ if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then
+ string_limit_check_mark "Bot token is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Bot token is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ while true
+ do
+ telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3)
+ if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "Chat ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Chat ID is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ ;;
+ esac
+ done
+ fi
+ while true
+ do
+ node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3)
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ string_limit_check_mark "Node name is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Node name is not valid try again............................."
+ sleep 1
+ fi
+ done
+ else
+ discord="0"
+ ping="0"
+ telegram_alert="0"
+ telegram_bot_token="0"
+ telegram_chat_id="0"
+ node_label="0"
+ sleep 1
+ fi
+ if [[ "$discord" == 0 ]]; then
+ ping="0";
+ fi
+ if [[ "$telegram_alert" == 0 ]]; then
+ telegram_bot_token="0";
+ telegram_chat_id="0";
+ fi
+ if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then
+ index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ tx_from_file=$(grep -w zelnodeoutpoint /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
+ stak_info=$(curl -s -m 5 https://$network_url_1/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -s -m 5 https://$network_url_2/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ fi
+ fi
+ if [[ $stak_info == ?(-)+([0-9]) ]]; then
+
+ case $stak_info in
+ "1000") eps_limit=240 ;;
+ "12500") eps_limit=640 ;;
+ "40000") eps_limit=1520 ;;
+ esac
+ else
+ eps_limit=0;
+ fi
+ watchdog_conf_create
+ pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ if [[ -f /home/$USER/watchdog/watchdog.js ]]; then
+ current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
+ string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................."
+ else
+ string_limit_x_mark "Watchdog was not installed................................."
+ fi
+ else
+ string_limit_x_mark "Watchdog was not installed................................."
+ fi
}
-
function wipe_clean() {
- echo -e "${ARROW} ${YELLOW}Removing any instances of FluxNode${NC}"
- apt_number=$(ps aux | grep 'apt' | wc -l)
-
- if [[ "$apt_number" > 1 ]]; then
-
- sudo killall apt > /dev/null 2>&1
- sudo killall apt-get > /dev/null 2>&1
- sudo dpkg --configure -a > /dev/null 2>&1
-
- fi
-
- echo -e "${ARROW} ${CYAN}Stopping all services and running processes...${NC}"
-
- # NEW CLEAN_UP
-
- sudo killall nano > /dev/null 2>&1
- $COIN_CLI stop > /dev/null 2>&1 && sleep 2
- sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
- sudo killall -s SIGKILL $COIN_DAEMON > /dev/null 2>&1 && sleep 2
- $BENCH_CLI stop > /dev/null 2>&1 && sleep 2
- sudo killall -s SIGKILL $BENCH_NAME > /dev/null 2>&1 && sleep 1
- sudo fuser -k 16127/tcp > /dev/null 2>&1 && sleep 1
- sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
- sudo rm -rf /usr/bin/flux* > /dev/null 2>&1 && sleep 1
-
- echo -e "${ARROW} ${CYAN}Removing daemon && benchmark...${NC}"
- sudo apt-get remove $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1
- sudo apt-get purge $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1
- sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1
- sudo rm -rf /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1
- tmux kill-server > /dev/null 2>&1 && sleep 1
-
- echo -e "${ARROW} ${CYAN}Removing PM2...${NC}"
- pm2 del zelflux > /dev/null 2>&1 && sleep 1
- pm2 del flux > /dev/null 2>&1 && sleep 1
- pm2 del watchdog > /dev/null 2>&1 && sleep 1
- pm2 save > /dev/null 2>&1
- pm2 unstartup > /dev/null 2>&1 && sleep 1
- pm2 flush > /dev/null 2>&1 && sleep 1
- pm2 save > /dev/null 2>&1 && sleep 1
- pm2 kill > /dev/null 2>&1 && sleep 1
- npm remove pm2 -g > /dev/null 2>&1 && sleep 1
-
- echo -e "${ARROW} ${CYAN}Removing others files and scripts...${NC}"
- sudo rm -rf watchgod > /dev/null 2>&1 && sleep 1
- sudo rm -rf $BENCH_DIR_LOG && sleep 1
-
- #FILE OF OLD ZEL NODE
- sudo rm -rf /etc/logrotate.d/mongolog > /dev/null 2>&1
- sudo rm -rf /etc/logrotate.d/zeldebuglog > /dev/null 2>&1
- rm update.sh > /dev/null 2>&1
- rm restart_zelflux.sh > /dev/null 2>&1
- rm zelnodeupdate.sh > /dev/null 2>&1
- rm start.sh > /dev/null 2>&1
- rm update-zelflux.sh > /dev/null 2>&1
- sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
- zelcash-cli stop > /dev/null 2>&1 && sleep 2
- sudo killall -s SIGKILL zelcashd > /dev/null 2>&1
- zelbench-cli stop > /dev/null 2>&1
- sudo killall -s SIGKILL zelbenchd > /dev/null 2>&1
- sudo rm /usr/local/bin/zel* > /dev/null 2>&1 && sleep 1
- sudo apt-get purge zelcash zelbench -y > /dev/null 2>&1 && sleep 1
- sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1
- sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1
- sudo rm -rf zelflux > /dev/null 2>&1 && sleep 1
- #sudo rm -rf ~/.zelcash/determ_zelnodes ~/.zelcash/sporks ~/$CONFIG_DIR/database ~/.zelcash/blocks ~/.zelcashchainstate > /dev/null 2>&1 && sleep 1
- #sudo rm -rf ~/.zelcash > /dev/null 2>&1 && sleep 1
- sudo rm -rf .zelbenchmark > /dev/null 2>&1 && sleep 1
- sudo rm -rf /home/$USER/stop_zelcash_service.sh > /dev/null 2>&1
- sudo rm -rf /home/$USER/start_zelcash_service.sh > /dev/null 2>&1
-
- if [[ -d /home/$USER/.zelcash ]]; then
-
- echo -e "${ARROW} ${CYAN}Moving ~/.zelcash to ~/.flux${NC}"
- #echo -e "${ARROW} ${CYAN}Renaming zelcash.conf to flux.conf${NC}"
- sudo mv /home/$USER/.zelcash /home/$USER/.flux > /dev/null 2>&1 && sleep 1
- sudo mv /home/$USER/.flux/zelcash.conf /home/$USER/.flux/flux.conf > /dev/null 2>&1 && sleep 1
-
- fi
-
-
- if [[ -d /home/$USER/$CONFIG_DIR ]]; then
-
- if [[ -z "$use_old_chain" ]]; then
-
- if ! whiptail --yesno "Would you like to use old chain from Flux daemon config directory?" 8 60; then
- echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
- sudo rm -rf ~/$CONFIG_DIR/determ_zelnodes ~/$CONFIG_DIR/sporks ~/$CONFIG_DIR/database ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate && sleep 2
- sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 && sleep 2
-
- else
- BOOTSTRAP_SKIP="1"
- sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat
- sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf
- sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat
- sudo rm -rf /home/$USER/$CONFIG_DIR/db.log
- sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/database && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/sporks && sleep 1
- fi
-
- else
-
- if [[ "$use_old_chain" == "1" ]]; then
-
- BOOTSTRAP_SKIP="1"
- sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat
- sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf
- sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat
- sudo rm -rf /home/$USER/$CONFIG_DIR/db.log
- sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/database && sleep 1
- sudo rm -rf /home/$USER/$CONFIG_DIR/sporks && sleep 1
-
- else
-
- echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
- sudo rm -rf ~/$CONFIG_DIR/determ_zelnodes ~/$CONFIG_DIR/sporks ~/$CONFIG_DIR/database ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate && sleep 2
- sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 && sleep 2
-
-
- fi
-
- fi
-fi
-
- sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
- sudo rm -rf /home/$USER/stop_daemon_service.sh > /dev/null 2>&1
- sudo rm -rf /home/$USER/start_daemon_service.sh > /dev/null 2>&1
- echo -e ""
-
- echo -e "${ARROW} ${YELLOW}Checking firewall status...${NC}" && sleep 1
- if [[ $(sudo ufw status | grep "Status: active") ]]
- then
- if [[ -z "$firewall_disable" ]]; then
- if whiptail --yesno "Firewall is active and enabled. Do you want disable it during install process?(Recommended)" 8 60; then
- sudo ufw disable > /dev/null 2>&1
- echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
- else
- echo -e "${ARROW} ${CYAN}Firewall status: ${GREEN}Enabled${NC}"
- fi
- else
-
- if [[ "$firewall_disable" == "1" ]]; then
- sudo ufw disable > /dev/null 2>&1
- echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
- else
- echo -e "${ARROW} ${CYAN}Firewall status: ${GREEN}Enabled${NC}"
- fi
- fi
-
- else
- echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
- fi
-
-}
-
-function spinning_timer() {
- animation=( ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ )
- end=$((SECONDS+NUM))
- while [ $SECONDS -lt $end ];
- do
- for i in "${animation[@]}";
- do
- echo -e ""
- echo -ne "${RED}\r\033[1A\033[0K$i ${CYAN}${MSG1}${NC}"
- sleep 0.1
-
- done
- done
- echo -ne "${MSG2}"
-}
-
-
-function ssh_port() {
-
- if [[ -z "$ssh_port" ]]; then
-
- SSHPORT=$(grep -w Port /etc/ssh/sshd_config | sed -e 's/.*Port //')
- if ! whiptail --yesno "Detected you are using $SSHPORT for SSH is this correct?" 8 56; then
- SSHPORT=$(whiptail --inputbox "Please enter port you are using for SSH" 8 43 3>&1 1>&2 2>&3)
- echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
- else
- echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
- fi
-
- else
- pettern='^[0-9]+$'
- if [[ $ssh_port =~ $pettern ]] ; then
- SSHPORT="$ssh_port"
- echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
+ echo -e "${ARROW} ${YELLOW}Removing any instances of FluxNode${NC}"
+ apt_number=$(ps aux | grep 'apt' | wc -l)
+ if [[ "$apt_number" > 1 ]]; then
+ sudo killall apt > /dev/null 2>&1
+ sudo killall apt-get > /dev/null 2>&1
+ sudo dpkg --configure -a > /dev/null 2>&1
+ fi
+ echo -e "${ARROW} ${CYAN}Stopping all services and running processes...${NC}"
+ sudo killall nano > /dev/null 2>&1
+ $COIN_CLI stop > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
+ sudo killall -s SIGKILL $COIN_DAEMON > /dev/null 2>&1 && sleep 2
+ $BENCH_CLI stop > /dev/null 2>&1 && sleep 2
+ sudo killall -s SIGKILL $BENCH_NAME > /dev/null 2>&1 && sleep 1
+ sudo fuser -k 16127/tcp > /dev/null 2>&1 && sleep 1
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /usr/bin/flux* > /dev/null 2>&1 && sleep 1
+ echo -e "${ARROW} ${CYAN}Removing daemon && benchmark...${NC}"
+ sudo apt-get remove $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get purge $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1
+ tmux kill-server > /dev/null 2>&1 && sleep 1
+ echo -e "${ARROW} ${CYAN}Removing PM2...${NC}"
+ pm2 del zelflux > /dev/null 2>&1 && sleep 1
+ pm2 del flux > /dev/null 2>&1 && sleep 1
+ pm2 del watchdog > /dev/null 2>&1 && sleep 1
+ pm2 save > /dev/null 2>&1
+ pm2 unstartup > /dev/null 2>&1 && sleep 1
+ pm2 flush > /dev/null 2>&1 && sleep 1
+ pm2 save > /dev/null 2>&1 && sleep 1
+ pm2 kill > /dev/null 2>&1 && sleep 1
+ npm remove pm2 -g > /dev/null 2>&1 && sleep 1
+ echo -e "${ARROW} ${CYAN}Removing others files and scripts...${NC}"
+ sudo rm -rf watchgod > /dev/null 2>&1 && sleep 1
+ sudo rm -rf $BENCH_DIR_LOG && sleep 1
+ sudo rm -rf /etc/logrotate.d/bench_debug_log > /dev/null 2>&1
+ sudo rm -rf /etc/logrotate.d/daemon_debug_log > /dev/null 2>&1
+ sudo rm -rf /etc/logrotate.d/docker_debug_log > /dev/null 2>&1
+ rm update.sh > /dev/null 2>&1
+ rm restart_zelflux.sh > /dev/null 2>&1
+ rm zelnodeupdate.sh > /dev/null 2>&1
+ rm start.sh > /dev/null 2>&1
+ rm update-zelflux.sh > /dev/null 2>&1
+ sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
+ zelcash-cli stop > /dev/null 2>&1 && sleep 2
+ sudo killall -s SIGKILL zelcashd > /dev/null 2>&1
+ zelbench-cli stop > /dev/null 2>&1
+ sudo killall -s SIGKILL zelbenchd > /dev/null 2>&1
+ sudo rm /usr/local/bin/zel* > /dev/null 2>&1 && sleep 1
+ sudo apt-get purge zelcash zelbench -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1
+ sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1
+ sudo rm -rf zelflux > /dev/null 2>&1 && sleep 1
+ sudo rm -rf .zelbenchmark > /dev/null 2>&1 && sleep 1
+ sudo rm -rf .fluxbenchmark > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /home/$USER/stop_zelcash_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/start_zelcash_service.sh > /dev/null 2>&1
+ if [[ -d /home/$USER/.zelcash ]]; then
+ echo -e "${ARROW} ${CYAN}Moving ~/.zelcash to ~/.flux${NC}"
+ sudo mv /home/$USER/.zelcash /home/$USER/.flux > /dev/null 2>&1 && sleep 1
+ sudo mv /home/$USER/.flux/zelcash.conf /home/$USER/.flux/flux.conf > /dev/null 2>&1 && sleep 1
+ fi
+ if [[ -d /home/$USER/$CONFIG_DIR ]]; then
+ config_veryfity
+ if [[ -z "$use_old_chain" ]]; then
+ if [[ "$SKIP_OLD_CHAIN" == "0" ]]; then
+ if ! whiptail --yesno "Would you like to use old chain from Flux daemon config directory?" 8 60; then
+ echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
+ sudo rm -rf /home/$USERNAME/$CONFIG_DIR/determ_zelnodes ~/$CONFIG_DIR/sporks ~/$CONFIG_DIR/database ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate > /dev/null 2>&1
+ sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ BOOTSTRAP_SKIP="1"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/db.log
+ sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log
+ sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf
+ sudo rm -rf /home/$USER/$CONFIG_DIR/database
+ sudo rm -rf /home/$USER/$CONFIG_DIR/sporks
+ fi
+ else
+ echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/determ_zelnodes /home/$USER/$CONFIG_DIR/sporks /home/$USER/$CONFIG_DIR/database /home/$USER/$CONFIG_DIR/blocks /home/$USER/$CONFIG_DIR/chainstate > /dev/null 2>&1
+ sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ fi
+ else
+ if [[ "$use_old_chain" == "1" ]]; then
+ BOOTSTRAP_SKIP="1"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/db.log
+ sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log
+ sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf
+ sudo rm -rf /home/$USER/$CONFIG_DIR/database
+ sudo rm -rf /home/$USER/$CONFIG_DIR/sporks
+ else
+ echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/determ_zelnodes /home/$USER/$CONFIG_DIR/sporks /home/$USER/$CONFIG_DIR/database /home/$USER/$CONFIG_DIR/blocks /home/$USER/$CONFIG_DIR/chainstate > /dev/null 2>&1
+ sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ fi
+ fi
+ fi
+ sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
+ sudo rm -rf /home/$USER/stop_daemon_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/start_daemon_service.sh > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Checking firewall status...${NC}" && sleep 1
+ if [[ $(sudo ufw status | grep "Status: active") ]]; then
+ sudo ufw disable > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
else
- echo -e "${ARROW} ${CYAN}SSH port must be integer................[${X_MARK}${CYAN}]${NC}}"
- echo
- exit
- fi
- fi
-}
-
-function ip_confirm() {
- echo -e "${ARROW} ${YELLOW}Detecting IP address...${NC}"
-
- WANIP=$(curl --silent -m 15 https://api4.my-ip.io/ip | tr -dc '[:alnum:].')
-
- if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl --silent -m 15 https://checkip.amazonaws.com | tr -dc '[:alnum:].')
- fi
-
- if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl --silent -m 15 https://api.ipify.org | tr -dc '[:alnum:].')
- fi
-
-
- if [[ "$WANIP" == "" ]]; then
- echo -e "${ARROW} ${CYAN}IP address could not be found, installation stopped .........[${X_MARK}${CYAN}]${NC}"
- echo
- exit
- fi
-
-
- string_limit_check_mark "Detected IP: $WANIP ................................." "Detected IP: ${GREEN}$WANIP${CYAN} ................................."
-
-}
-
-function create_swap() {
-
- if [[ -z "$swapon" ]]; then
- #echo -e "${YELLOW}Creating swap if none detected...${NC}" && sleep 1
- MEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
- gb=$(awk "BEGIN {print $MEM/1048576}")
- GB=$(echo "$gb" | awk '{printf("%d\n",$1 + 0.5)}')
- if [ "$GB" -lt 2 ]; then
- (( swapsize=GB*2 ))
- swap="$swapsize"G
- elif [[ $GB -ge 2 ]] && [[ $GB -le 16 ]]; then
- swap=4G
- elif [[ $GB -gt 16 ]] && [[ $GB -lt 32 ]]; then
- swap=2G
- fi
- if ! grep -q "swapfile" /etc/fstab; then
- if whiptail --yesno "No swapfile detected would you like to create one?" 8 54; then
- sudo fallocate -l "$swap" /swapfile > /dev/null 2>&1
- sudo chmod 600 /swapfile > /dev/null 2>&1
- sudo mkswap /swapfile > /dev/null 2>&1
- sudo swapon /swapfile > /dev/null 2>&1
- echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab > /dev/null 2>&1
- echo -e "${ARROW} ${YELLOW}Created ${SEA}${swap}${YELLOW} swapfile${NC}"
- else
- echo -e "${ARROW} ${YELLOW}Creating a swapfile skipped...${NC}"
- fi
- fi
-
- else
-
- if [[ "$swapon" == "1" ]]; then
-
- MEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
- gb=$(awk "BEGIN {print $MEM/1048576}")
- GB=$(echo "$gb" | awk '{printf("%d\n",$1 + 0.5)}')
- if [ "$GB" -lt 2 ]; then
- (( swapsize=GB*2 ))
- swap="$swapsize"G
- elif [[ $GB -ge 2 ]] && [[ $GB -le 16 ]]; then
- swap=4G
- elif [[ $GB -gt 16 ]] && [[ $GB -lt 32 ]]; then
- swap=2G
- fi
- if ! grep -q "swapfile" /etc/fstab; then
- sudo fallocate -l "$swap" /swapfile > /dev/null 2>&1
- sudo chmod 600 /swapfile > /dev/null 2>&1
- sudo mkswap /swapfile > /dev/null 2>&1
- sudo swapon /swapfile > /dev/null 2>&1
- echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab > /dev/null 2>&1
- echo -e "${ARROW} ${YELLOW}Created ${SEA}${swap}${YELLOW} swapfile${NC}"
- else
- echo -e "${ARROW} ${YELLOW}Creating a swapfile skipped...${NC}"
- fi
- #fi
-
- fi
-
-
- fi
- sleep 2
+ echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
+ fi
}
-
-function install_packages() {
- echo
- echo -e "${ARROW} ${YELLOW}Installing Packages...${NC}"
- if [[ $(lsb_release -d) = *Debian* ]] && [[ $(lsb_release -d) = *9* ]]; then
- sudo apt-get install dirmngr apt-transport-https -y > /dev/null 2>&1
- fi
- sudo apt-get install software-properties-common -y > /dev/null 2>&1
- sudo apt-get update -y > /dev/null 2>&1
- sudo apt-get upgrade -y > /dev/null 2>&1
- sudo apt-get install nano htop pwgen ufw figlet tmux jq zip gzip pv unzip git -y > /dev/null 2>&1
- sudo apt-get install build-essential libtool pkg-config -y > /dev/null 2>&1
- sudo apt-get install libc6-dev m4 g++-multilib -y > /dev/null 2>&1
- sudo apt-get install autoconf ncurses-dev python python-zmq -y > /dev/null 2>&1
- sudo apt-get install wget curl bsdmainutils automake fail2ban -y > /dev/null 2>&1
- sudo apt-get remove sysbench -y > /dev/null 2>&1
- echo -e "${ARROW} ${YELLOW}Packages complete...${NC}"
+function ssh_port() {
+ if [[ -z "$ssh_port" ]]; then
+ SSHPORT=$(grep -w Port /etc/ssh/sshd_config | sed -e 's/.*Port //')
+ echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
+ else
+ pettern='^[0-9]+$'
+ if [[ $ssh_port =~ $pettern ]] ; then
+ SSHPORT="$ssh_port"
+ echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
+ else
+ echo -e "${ARROW} ${CYAN}SSH port must be integer................[${X_MARK}${CYAN}]${NC}}"
+ echo
+ exit
+ fi
+ fi
}
-
function create_conf() {
-
- echo -e "${ARROW} ${YELLOW}Creating Flux daemon config file...${NC}"
- if [ -f ~/$CONFIG_DIR/$CONFIG_FILE ]; then
- echo -e "${ARROW} ${CYAN}Existing conf file found backing up to $COIN_NAME.old ...${NC}"
- mv ~/$CONFIG_DIR/$CONFIG_FILE ~/$CONFIG_DIR/$COIN_NAME.old;
- fi
-
- RPCUSER=$(pwgen -1 8 -n)
- PASSWORD=$(pwgen -1 20 -n)
-
- if [[ "$IMPORT_ZELCONF" == "0" ]]
- then
- zelnodeprivkey=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Privkey generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)
- zelnodeoutpoint=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode collateral txid" 8 72 3>&1 1>&2 2>&3)
- zelnodeindex=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode collateral output index usually a 0/1" 8 60 3>&1 1>&2 2>&3)
- fi
-
-
- if [ "x$PASSWORD" = "x" ]; then
- PASSWORD=${WANIP}-$(date +%s)
- fi
- mkdir ~/$CONFIG_DIR > /dev/null 2>&1
- touch ~/$CONFIG_DIR/$CONFIG_FILE
- cat << EOF > ~/$CONFIG_DIR/$CONFIG_FILE
-rpcuser=$RPCUSER
-rpcpassword=$PASSWORD
-rpcallowip=127.0.0.1
-rpcallowip=172.18.0.1
-rpcport=$RPCPORT
-port=$PORT
-zelnode=1
-zelnodeprivkey=$zelnodeprivkey
-zelnodeoutpoint=$zelnodeoutpoint
-zelnodeindex=$zelnodeindex
-server=1
-daemon=1
-txindex=1
-listen=1
-externalip=$WANIP
-bind=0.0.0.0
-addnode=explorer.flux.zelcore.io
-addnode=explorer.runonflux.io
-addnode=explorer.zelcash.online
-maxconnections=256
-EOF
- sleep 2
-}
-
-function flux_package() {
- sudo apt-get update -y > /dev/null 2>&1 && sleep 2
- echo -e "${ARROW} ${YELLOW}Flux Daemon && Benchmark installing...${NC}"
- sudo apt install $COIN_NAME $BENCH_NAME zelbench zelcash -y > /dev/null 2>&1 && sleep 2
- sudo chmod 755 $COIN_PATH/* > /dev/null 2>&1 && sleep 2
- integration_check
+ echo -e "${ARROW} ${YELLOW}Creating Flux daemon config file...${NC}"
+ if [ -f ~/$CONFIG_DIR/$CONFIG_FILE ]; then
+ echo -e "${ARROW} ${CYAN}Existing conf file found backing up to $COIN_NAME.old ...${NC}"
+ mv ~/$CONFIG_DIR/$CONFIG_FILE ~/$CONFIG_DIR/$COIN_NAME.old;
+ fi
+ if [[ "$IMPORT_ZELCONF" == "0" ]]; then
+ zelnodeprivkey=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)
+ zelnodeoutpoint=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3)
+ zelnodeindex=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Output Index usually a 0/1" 8 60 3>&1 1>&2 2>&3)
+ fi
+ mkdir /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ flux_daemon_conf_create
+ if [[ "$IMPORT_ZELID" == "0" ]]; then
+ while true
+ do
+ ZELID=$(whiptail --title "Flux Configuration" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)
+ if [ $(printf "%s" "$ZELID" | wc -c) -eq "34" ] || [ $(printf "%s" "$ZELID" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$ZELID") ]; then
+ echo -e "${ARROW} ${CYAN}Zel ID is valid${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ else
+ echo -e "${ARROW} ${CYAN}Zel ID is not valid try again...........[${X_MARK}${CYAN}]${NC}"
+ sleep 4
+ fi
+ done
+ fi
}
-
function install_daemon() {
-
sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1
sudo rm /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
-
echo -e "${ARROW} ${YELLOW}Configuring daemon repository and importing public GPG Key${NC}"
sudo chown -R $USER:$USER /usr/share/keyrings > /dev/null 2>&1
-
-if [[ "$(lsb_release -cs)" == "xenial" ]]; then
-
- echo 'deb https://apt.runonflux.io/ '$(lsb_release -cs)' main' | sudo tee --append /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
- gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B69CA27A986265D > /dev/null 2>&1
- gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
-
- if ! gpg --list-keys Zel > /dev/null; then
- gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
- gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
- fi
-
- flux_package && sleep 2
-else
-
- gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B69CA27A986265D > /dev/null 2>&1
- gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
-
- if ! gpg --list-keys Zel > /dev/null; then
- gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
- gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
- fi
-
- # cleaning
- sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
-
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/flux-archive-keyring.gpg] https://apt.runonflux.io/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
-
- # downloading key && save it as keyring
- gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
-
- if ! gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
- echo -e "${YELLOW}First attempt to retrieve keys failed will try a different keyserver.${NC}"
- sudo rm /usr/share/keyrings/zelcash-archive-keyring.gpg > /dev/null 2>&1
- gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://na.pool.sks-keyservers.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
- fi
-
-
- if ! gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
- echo -e "${YELLOW}Last keyserver also failed will try one last keyserver.${NC}"
- sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
- gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
- fi
-
-
- if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
-
- flux_package && sleep 2
-
- else
-
- echo
- echo -e "${WORNING} ${RED}Importing public GPG Key failed...${NC}"
- echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
- echo
- exit
-
- fi
-
-fi
-
-}
-
-
-
-function zk_params() {
- echo -e "${ARROW} ${YELLOW}Installing zkSNARK params...${NC}"
- bash flux-fetch-params.sh > /dev/null 2>&1 && sleep 2
- sudo chown -R $USER:$USER /home/$USER > /dev/null 2>&1
-}
-
-function bootstrap() {
-
- BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
-
- echo -e ""
- echo -e "${ARROW} ${YELLOW}Restore daemon chain from bootstrap${NC}"
- if [[ -z "$bootstrap_url" ]]; then
-
- if [[ -e ~/$CONFIG_DIR/blocks ]] && [[ -e ~/$CONFIG_DIR/chainstate ]]; then
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- rm -rf ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate ~/$CONFIG_DIR/determ_zelnodes
-
- fi
-
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
-
- echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}"
- echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}"
- if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1
- then
- echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}"
- else
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
-
- else
- check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
- fi
-
- fi
-
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- fi
-
- else
-
-
- CHOICE=$(
- whiptail --title "FLUXNODE INSTALLATION" --menu "Choose a method how to get bootstrap file" 10 47 2 \
- "1)" "Download from source build in script" \
- "2)" "Download from own source" 3>&2 2>&1 1>&3
- )
-
-
- case $CHOICE in
- "1)")
-
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
- if [[ "$DB_HIGHT" == "" ]]; then
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
- fi
-
- echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- #unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
-
-
- ;;
- "2)")
- BOOTSTRAP_ZIP="$(whiptail --title "Flux daemon bootstrap setup" --inputbox "Enter your URL (zip, tar.gz)" 8 72 3>&1 1>&2 2>&3)"
- echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
- wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- fi
- #echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- #unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- ;;
- esac
-
- fi
-
+ sudo chown -R $USER:$USER /home/$USER/.gnupg > /dev/null 2>&1
+ if [[ "$(lsb_release -cs)" == "xenial" ]]; then
+ echo 'deb https://apt.runonflux.io/ '$(lsb_release -cs)' main' | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
+ gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B69CA27A986265D > /dev/null 2>&1
+ gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
+ if ! gpg --list-keys Zel > /dev/null; then
+ gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
+ fi
+ flux_package && sleep 2
+ else
+ sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
+ server_check=$(curl -s -m 20 https://apt.runonflux.io/pool/main/f/flux/ | grep -o '[0-9].[0-9].[0-9]' | head -n1)
+ if [[ $server_check == "" ]]; then
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/flux-archive-keyring.gpg] https://apt.fluxos.network/ focal main" | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
else
-
- if [[ -e ~/$CONFIG_DIR/blocks ]] && [[ -e ~/$CONFIG_DIR/chainstate ]]; then
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- rm -rf ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate ~/$CONFIG_DIR/determ_zelnodes
- fi
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
-
- echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}"
- echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}"
- if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1
- then
- echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}"
- else
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
-
- else
- check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
- fi
-
- fi
-
-
- if [[ "$bootstrap_url" == "" ]]; then
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- fi
-
- else
-
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
- if [[ "$DB_HIGHT" == "" ]]; then
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/flux-archive-keyring.gpg] https://apt.runonflux.io/ focal main" | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
+ fi
+ # downloading key && save it as keyring
+ gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ key_counter=0
+ until [ $key_counter -gt 5 ]
+ do
+ if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
+ break
+ fi
+ echo -e "${CYAN}Retrieve keys failed will try again...${NC}"
+ sleep 5
+ sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
+ gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ ((key_counter++))
+ done
+ #if ! gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
+ #echo -e "${YELLOW}First attempt to retrieve keys failed will try a different keyserver.${NC}"
+ #sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
+ #gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://na.pool.sks-keyservers.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ #fi
+ #if ! gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
+ #echo -e "${YELLOW}Last keyserver also failed will try one last keyserver.${NC}"
+ #sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
+ #gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ #fi
+ if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
+ flux_package && sleep 2
+ else
+ echo -e ""
+ echo -e "${WORNING} ${RED}Importing public GPG Key failed...${NC}"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo -e ""
+ exit
fi
-
- echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
-
- fi
-
- else
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- else
- BOOTSTRAP_ZIP="$bootstrap_url"
- echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
- wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- fi
-
- fi
- fi
- fi
-
- if [[ -z "$bootstrap_zip_del" ]]; then
- if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
- else
-
- if [[ "$bootstrap_zip_del" == "1" ]]; then
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
-
- fi
-
-}
-
-
-function create_service_scripts() {
-
-#echo -e "${ARROW} ${YELLOW}Creating Flux daemon service scripts...${NC}" && sleep 1
-sudo touch /home/$USER/start_daemon_service.sh
-sudo chown $USER:$USER /home/$USER/start_daemon_service.sh
- cat <<'EOF' > /home/$USER/start_daemon_service.sh
-#!/bin/bash
-
-#color codes
-RED='\033[1;31m'
-CYAN='\033[1;36m'
-NC='\033[0m'
-#emoji codes
-BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
-WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
-
-sleep 2
-echo -e "${BOOK} ${CYAN}Pre-start process starting...${NC}"
-echo -e "${BOOK} ${CYAN}Checking if benchmark or daemon is running${NC}"
-bench_status_pind=$(pgrep fluxbenchd)
-daemon_status_pind=$(pgrep fluxd)
-if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then
-echo -e "${BOOK} ${CYAN}No running instance detected...${NC}"
-else
-if [[ "$bench_status_pind" != "" ]]; then
-echo -e "${WORNING} Running benchmark process detected${NC}"
-echo -e "${WORNING} Killing benchmark...${NC}"
-sudo killall -9 fluxbenchd > /dev/null 2>&1 && sleep 2
-fi
-if [[ "$daemon_status_pind" != "" ]]; then
-echo -e "${WORNING} Running daemon process detected${NC}"
-echo -e "${WORNING} Killing daemon...${NC}"
-sudo killall -9 fluxd > /dev/null 2>&1 && sleep 2
-fi
-sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
-fi
-
-bench_status_pind=$(pgrep zelbenchd)
-daemon_status_pind=$(pgrep zelcashd)
-if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then
-echo -e "${BOOK} ${CYAN}No running instance detected...${NC}"
-else
-if [[ "$bench_status_pind" != "" ]]; then
-echo -e "${WORNING} Running benchmark process detected${NC}"
-echo -e "${WORNING} Killing benchmark...${NC}"
-sudo killall -9 zelbenchd > /dev/null 2>&1 && sleep 2
-fi
-if [[ "$daemon_status_pind" != "" ]]; then
-echo -e "${WORNING} Running daemon process detected${NC}"
-echo -e "${WORNING} Killing daemon...${NC}"
-sudo killall -9 zelcashd > /dev/null 2>&1 && sleep 2
-fi
-sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
-fi
-
-if [[ -f /usr/local/bin/fluxd ]]; then
-bash -c "fluxd"
-exit
-else
-bash -c "zelcashd"
-exit
-fi
-EOF
-
-
-sudo touch /home/$USER/stop_daemon_service.sh
-sudo chown $USER:$USER /home/$USER/stop_daemon_service.sh
- cat <<'EOF' > /home/$USER/stop_daemon_service.sh
-#!/bin/bash
-bash -c "flux-cli stop"
-exit
-EOF
-
-sudo chmod +x /home/$USER/stop_daemon_service.sh
-sudo chmod +x /home/$USER/start_daemon_service.sh
-
-}
-
-function create_service() {
- echo -e "${ARROW} ${YELLOW}Creating Flux daemon service...${NC}" && sleep 1
- sudo touch /etc/systemd/system/zelcash.service
- sudo chown $USER:$USER /etc/systemd/system/zelcash.service
- cat << EOF > /etc/systemd/system/zelcash.service
-[Unit]
-Description=Flux daemon service
-After=network.target
-[Service]
-Type=forking
-User=$USER
-Group=$USER
-ExecStart=/home/$USER/start_daemon_service.sh
-ExecStop=-/home/$USER/stop_daemon_service.sh
-Restart=always
-RestartSec=10
-PrivateTmp=true
-TimeoutStopSec=60s
-TimeoutStartSec=15s
-StartLimitInterval=120s
-StartLimitBurst=5
-[Install]
-WantedBy=multi-user.target
-EOF
- sudo chown root:root /etc/systemd/system/zelcash.service
- sudo systemctl daemon-reload
+ fi
}
-
function basic_security() {
- echo -e "${ARROW} ${YELLOW}Configuring firewall and enabling fail2ban...${NC}"
- sudo ufw allow 16124/tcp > /dev/null 2>&1
- sudo ufw allow "$SSHPORT"/tcp > /dev/null 2>&1
- sudo ufw allow "$PORT"/tcp > /dev/null 2>&1
- sudo ufw logging on > /dev/null 2>&1
- sudo ufw default deny incoming > /dev/null 2>&1
-
- sudo ufw allow out from any to any port 123 > /dev/null 2>&1
- sudo ufw allow out to any port 80 > /dev/null 2>&1
- sudo ufw allow out to any port 443 > /dev/null 2>&1
- sudo ufw allow out to any port 53 > /dev/null 2>&1
- sudo ufw allow out to any port 16124 > /dev/null 2>&1
- sudo ufw allow out to any port 16125 > /dev/null 2>&1
- sudo ufw allow out to any port 16127 > /dev/null 2>&1
- sudo ufw allow from any to any port 16127 > /dev/null 2>&1
-
- sudo ufw default deny outgoing > /dev/null 2>&1
- sudo ufw limit OpenSSH > /dev/null 2>&1
- echo "y" | sudo ufw enable > /dev/null 2>&1
- sudo ufw reload > /dev/null 2>&1
- sudo systemctl enable fail2ban > /dev/null 2>&1
- sudo systemctl start fail2ban > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Configuring firewall and enabling fail2ban...${NC}"
+ sudo ufw allow "$SSHPORT"/tcp > /dev/null 2>&1
+ sudo ufw logging on > /dev/null 2>&1
+ sudo ufw default deny incoming > /dev/null 2>&1
+ sudo ufw allow out from any to any port 123 > /dev/null 2>&1
+ sudo ufw allow out to any port 80 > /dev/null 2>&1
+ sudo ufw allow out to any port 443 > /dev/null 2>&1
+ sudo ufw allow out to any port 53 > /dev/null 2>&1
+ #FluxOS communication
+ sudo ufw allow 16100:16199/tcp > /dev/null 2>&1
+ #sudo ufw default deny outgoing > /dev/null 2>&1
+ sudo ufw limit OpenSSH > /dev/null 2>&1
+ echo "y" | sudo ufw enable > /dev/null 2>&1
+ sudo ufw reload > /dev/null 2>&1
+ sudo systemctl enable fail2ban > /dev/null 2>&1
+ sudo systemctl start fail2ban > /dev/null 2>&1
}
-
-function pm2_install(){
-
- echo -e "${ARROW} ${YELLOW}PM2 installing...${NC}"
- npm install pm2@latest -g > /dev/null 2>&1
-
- if pm2 -v > /dev/null 2>&1
- then
- echo -e "${ARROW} ${YELLOW}Configuring PM2...${NC}"
- pm2 startup systemd -u $USER > /dev/null 2>&1
- sudo env PATH=$PATH:/home/$USER/.nvm/versions/node/$(node -v)/bin pm2 startup systemd -u $USER --hp /home/$USER > /dev/null 2>&1
-
-
- #pm2 start ~/zelflux/start.sh --name zelflux > /dev/null 2>&1
- #pm2 save > /dev/null 2>&1
-
-
- pm2 install pm2-logrotate > /dev/null 2>&1
- pm2 set pm2-logrotate:max_size 6M > /dev/null 2>&1
- pm2 set pm2-logrotate:retain 6 > /dev/null 2>&1
- pm2 set pm2-logrotate:compress true > /dev/null 2>&1
- pm2 set pm2-logrotate:workerInterval 3600 > /dev/null 2>&1
- pm2 set pm2-logrotate:rotateInterval '0 12 * * 0' > /dev/null 2>&1
-
- source ~/.bashrc
- #echo -e "${ARROW} ${CYAN}PM2 version: ${GREEN}v$(pm2 -v)${CYAN} installed${NC}"
- string_limit_check_mark "PM2 v$(pm2 -v) installed................................." "PM2 ${GREEN}v$(pm2 -v)${CYAN} installed................................."
- echo
- else
- string_limit_x_mark "PM2 was not installed................................."
- echo
- fi
-
-}
-
function start_daemon() {
-
- sudo systemctl enable zelcash.service > /dev/null 2>&1
- sudo systemctl start zelcash > /dev/null 2>&1
-
- NUM='180'
- MSG1='Starting daemon & syncing with chain please be patient this will take about 3 min...'
- MSG2=''
- spinning_timer
-
- if [[ "$($COIN_CLI getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
- # if $COIN_DAEMON > /dev/null 2>&1; then
-
- NUM='2'
- MSG1='Getting info...'
- MSG2="${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo && echo
-
-
- daemon_version=$($COIN_CLI getinfo | jq -r '.version')
- string_limit_check_mark "Flux daemon v$daemon_version installed................................." "Flux daemon ${GREEN}v$daemon_version${CYAN} installed................................."
- #echo -e "Zelcash version: ${GREEN}v$zelcash_version${CYAN} installed................................."
- bench_version=$($BENCH_CLI getinfo | jq -r '.version')
- string_limit_check_mark "Flux benchmark v$bench_version installed................................." "Flux benchmark ${GREEN}v$bench_version${CYAN} installed................................."
- #echo -e "${ARROW} ${CYAN}Zelbench version: ${GREEN}v$zelbench_version${CYAN} installed${NC}"
- echo
- pm2_install
- #zelbench-cli stop > /dev/null 2>&1 && sleep 2
- else
- echo
- echo -e "${WORNING} ${RED}Something is not right the daemon did not start. Will exit out so try and run the script again.${NC}"
-
- if [[ -f /home/$USER/$CONFIG_DIR/debug.log ]]; then
- error_line=$(egrep -a --color 'Error:' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
- if [[ "$error_line" != "" ]]; then
- echo -e "${WORNING} ${CYAN}Last error from ~/$CONFIG_DIR/debug.log: ${NC}"
- echo -e "${WORNING} ${CYAN}$error_line${NC}"
- echo
- exit
- fi
- fi
-
- echo -e "${WORNING} ${RED}Veryfity date in ~/.flux/flux.conf .${NC}"
- echo
- exit
- fi
-}
-
-function log_rotate() {
- echo -e "${ARROW} ${YELLOW}Configuring log rotate function for $1 logs...${NC}"
- sleep 1
- if [ -f /etc/logrotate.d/$2 ]; then
- sudo rm -rf /etc/logrotate.d/$2
- sleep 2
- fi
-
- sudo touch /etc/logrotate.d/$2
- sudo chown $USER:$USER /etc/logrotate.d/$2
- cat << EOF > /etc/logrotate.d/$2
-$3 {
- compress
- copytruncate
- missingok
- $4
- rotate $5
-}
-EOF
- sudo chown root:root /etc/logrotate.d/$2
+ sudo systemctl enable zelcash.service > /dev/null 2>&1
+ sudo systemctl start zelcash > /dev/null 2>&1
+ x=1
+ while [ $x -le 6 ]
+ do
+ NUM='300'
+ MSG1='Starting daemon & syncing with chain please be patient this will take about 5 min...'
+ MSG2=''
+ spinning_timer
+ chain_check=$($COIN_CLI $1 getinfo 2>&1 >/dev/null | grep "Activating" | wc -l)
+ if [[ "$chain_check" == "1" ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${CYAN}Activating best chain detected....Awaiting increased for next 5min${NC}"
+ fi
+ if [[ "$($COIN_CLI $1 getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
+ break
+ fi
+ if [[ "$x" -gt 6 ]]; then
+ echo -e "${ARROW} ${CYAN}Maximum timeout exceeded...${NC}"
+ break
+ fi
+ x=$(( $x + 1 ))
+ done
+ if [[ "$($COIN_CLI $1 getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
+ NUM='2'
+ MSG1='Getting info...'
+ MSG2="${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo && echo
+ daemon_version=$($COIN_CLI $1 getinfo | jq -r '.version')
+ string_limit_check_mark "Flux daemon v$daemon_version installed................................." "Flux daemon ${GREEN}v$daemon_version${CYAN} installed................................."
+ bench_version=$($BENCH_CLI $1 getinfo | jq -r '.version')
+ string_limit_check_mark "Flux benchmark v$bench_version installed................................." "Flux benchmark ${GREEN}v$bench_version${CYAN} installed................................."
+ echo
+ pm2_install
+ else
+ echo -e ""
+ echo -e "${WORNING} ${RED}Something is not right the daemon did not start or still loading...${NC}"
+ if [[ -f /home/$USER/$CONFIG_DIR/debug.log ]]; then
+ error_line=$(egrep -a --color 'Error:' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ if [[ "$error_line" != "" ]]; then
+ echo -e "${WORNING} ${CYAN}Last error from ~/$CONFIG_DIR/debug.log: ${NC}"
+ echo -e "${WORNING} ${CYAN}$error_line${NC}"
+ echo -e ""
+ exit
+ fi
+ fi
+ if whiptail --yesno "Something is not right the daemon did not start or still loading....\nWould you like continue the installation (make sure that flux daemon working) Y/N?" 8 90; then
+ echo -e "${ARROW} ${CYAN}Problem with daemon noticed but user want continue installation... ${NC}"
+ echo -n ""
+ else
+ echo -e "${WORNING} ${RED}Installation stopped by user...${NC}"
+ echo -n ""
+ exit
+ fi
+ fi
}
-
function install_process() {
-
- echo -e "${ARROW} ${YELLOW}Configuring firewall...${NC}"
- sudo ufw allow $ZELFRONTPORT/tcp > /dev/null 2>&1
- sudo ufw allow $LOCPORT/tcp > /dev/null 2>&1
- sudo ufw allow $ZELNODEPORT/tcp > /dev/null 2>&1
- sudo ufw allow $MDBPORT/tcp > /dev/null 2>&1
-
- echo -e "${ARROW} ${YELLOW}Configuring service repositories...${NC}"
-
- sudo rm /etc/apt/sources.list.d/mongodb*.list > /dev/null 2>&1
- sudo rm /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
-
- curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
-
- if [[ $(lsb_release -d) = *Debian* ]]; then
-
-
- if [[ $(lsb_release -cs) = *stretch* || $(lsb_release -cs) = *buster* ]]; then
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/4.4 main" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- else
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- fi
-
-
- elif [[ $(lsb_release -d) = *Ubuntu* ]]; then
-
-
- if [[ $(lsb_release -cs) = *focal* || $(lsb_release -cs) = *bionic* || $(lsb_release -cs) = *xenial* ]]; then
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.4 multiverse" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- else
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
- fi
-
- else
-
- echo -e "${WORNING} ${RED}OS type not supported..${NC}"
- echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
- echo
- exit
-
- fi
-
-
- if ! sysbench --version > /dev/null 2>&1; then
-
- echo
- echo -e "${ARROW} ${YELLOW}Sysbench installing...${NC}"
- curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh 2> /dev/null | sudo bash > /dev/null 2>&1
- sudo apt -y install sysbench > /dev/null 2>&1
-
+ echo -e "${ARROW} ${YELLOW}Configuring firewall...${NC}"
+ sudo ufw allow $ZELFRONTPORT/tcp > /dev/null 2>&1
+ sudo ufw allow $LOCPORT/tcp > /dev/null 2>&1
+ sudo ufw allow $ZELNODEPORT/tcp > /dev/null 2>&1
+ if ! sysbench --version > /dev/null 2>&1; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Sysbench installing...${NC}"
+ #curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh 2> /dev/null | sudo bash > /dev/null 2>&1
+ curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sed 's/dist=${dist}/dist=focal/g' | sudo bash > /dev/null 2>&1
+ sudo apt -y install sysbench > /dev/null 2>&1
if sysbench --version > /dev/null 2>&1; then
-
- string_limit_check_mark "Sysbench $(sysbench --version | awk '{print $2}') installed................................." "Sysbench ${GREEN}$(sysbench --version | awk '{print $2}')${CYAN} installed................................."
-
+ string_limit_check_mark "Sysbench $(sysbench --version | awk '{print $2}') installed................................." "Sysbench ${GREEN}$(sysbench --version | awk '{print $2}')${CYAN} installed................................."
fi
- fi
-
- install_mongod
- install_nodejs
- install_flux
- sleep 2
-}
-
-function install_mongod() {
-echo
-echo -e "${ARROW} ${YELLOW}Removing any instances of Mongodb...${NC}"
-sudo systemctl stop mongod > /dev/null 2>&1 && sleep 1
-sudo apt remove mongod* -y > /dev/null 2>&1 && sleep 1
-sudo apt purge mongod* -y > /dev/null 2>&1 && sleep 1
-sudo apt autoremove -y > /dev/null 2>&1 && sleep 1
-echo -e "${ARROW} ${YELLOW}Mongodb installing...${NC}"
-sudo apt-get update -y > /dev/null 2>&1
-sudo apt-get install mongodb-org -y > /dev/null 2>&1 && sleep 2
-sudo systemctl enable mongod > /dev/null 2>&1
-sudo systemctl start mongod > /dev/null 2>&1
-if mongod --version > /dev/null 2>&1
-then
- #echo -e "${ARROW} ${CYAN}MongoDB version: ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed${NC}"
- string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
- echo
-else
- #echo -e "${ARROW} ${CYAN}MongoDB was not installed${NC}"
- string_limit_x_mark "MongoDB was not installed................................."
- echo
-fi
-}
-
-function install_nodejs() {
-echo -e "${ARROW} ${YELLOW}Removing any instances of Nodejs...${NC}"
-n-uninstall -y > /dev/null 2>&1 && sleep 1
-rm -rf ~/n
-sudo apt-get remove nodejs npm nvm -y > /dev/null 2>&1 && sleep 1
-sudo apt-get purge nodejs nvm -y > /dev/null 2>&1 && sleep 1
-sudo rm -rf /usr/local/bin/npm
-sudo rm -rf /usr/local/share/man/man1/node*
-sudo rm -rf /usr/local/lib/dtrace/node.d
-sudo rm -rf ~/.npm
-sudo rm -rf ~/.nvm
-sudo rm -rf ~/.pm2
-sudo rm -rf ~/.node-gyp
-sudo rm -rf /opt/local/bin/node
-sudo rm -rf opt/local/include/node
-sudo rm -rf /opt/local/lib/node_modules
-sudo rm -rf /usr/local/lib/node*
-sudo rm -rf /usr/local/include/node*
-sudo rm -rf /usr/local/bin/node*
-echo -e "${ARROW} ${YELLOW}Nodejs installing...${NC}"
-#export NVM_DIR="$HOME/.nvm" && (
- # git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" > /dev/null 2>&1
- # cd "$NVM_DIR"
- # git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` > /dev/null 2>&1
-#) && \. "$NVM_DIR/nvm.sh"
-#cd
-curl --silent -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash > /dev/null 2>&1
-. ~/.profile
-. ~/.bashrc
-sleep 1
-#nvm install v12.16.1
-nvm install --lts > /dev/null 2>&1
-if node -v > /dev/null 2>&1
-then
-#echo -e "${ARROW} ${CYAN}Nodejs version: ${GREEN}$(node -v)${CYAN} installed${NC}"
-string_limit_check_mark "Nodejs $(node -v) installed................................." "Nodejs ${GREEN}$(node -v)${CYAN} installed................................."
-echo
-else
-#echo -e "${ARROW} ${CYAN}Nodejs was not installed${NC}"
-string_limit_x_mark "Nodejs was not installed................................."
-echo
-fi
-
+ fi
+ install_mongod
+ install_nodejs
+ install_flux
+ sleep 2
}
-
function install_flux() {
-
- docker_check=$(docker container ls -a | grep 'zelcash' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
- resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
- mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
-
-if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then
-
-echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1
-echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1
-echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
-
-fi
-
-if [[ $docker_check != 0 ]]; then
-echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1
-echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
-
-sudo service docker restart > /dev/null 2>&1 && sleep 5
-
-docker container ls -a | grep 'zelcash' | grep -Eo "^[0-9a-z]{8,}\b" |
-while read line; do
-sudo docker stop $line > /dev/null 2>&1 && sleep 2
-sudo docker rm $line > /dev/null 2>&1 && sleep 2
-done
-fi
-
-if [[ $resource_check != 0 ]]; then
-echo -e "${ARROW} ${YELLOW}Detected locked resource${NC}" && sleep 1
-echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}" && sleep 1
-df | egrep 'flux' | awk '{ print $1}' |
-while read line; do
-sudo umount -l $line && sleep 1
-done
-fi
-
- if [ -d "./$FLUX_DIR" ]; then
- echo -e "${ARROW} ${YELLOW}Removing any instances of Flux${NC}"
- sudo rm -rf $FLUX_DIR
- fi
-
-
- echo -e "${ARROW} ${YELLOW}Flux installing...${NC}"
- git clone https://github.com/zelcash/zelflux.git > /dev/null 2>&1
- echo -e "${ARROW} ${YELLOW}Creating Flux configuration file...${NC}"
-
-
-if [[ "$IMPORT_ZELID" == "0" ]]; then
-
- while true
- do
- ZELID=$(whiptail --title "Flux Configuration" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)
- if [ $(printf "%s" "$ZELID" | wc -c) -eq "34" ] || [ $(printf "%s" "$ZELID" | wc -c) -eq "33" ]; then
- echo -e "${ARROW} ${CYAN}Zel ID is valid${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
- break
- else
- echo -e "${ARROW} ${CYAN}Zel ID is not valid try again...........[${X_MARK}${CYAN}]${NC}}"
- sleep 4
- fi
- done
-
- if whiptail --yesno "Are you planning to run Kadena node? Please note that only Nimbus/Stratus nodes are allowed to run it. ( to get reward you still NEED INSTALL KadenaChainWebNode under Apps -> Local Apps section via FluxOS Web UI )" 10 90 3>&1 1>&2 2>&3; then
-
- while true
- do
-
- KDA_A=$(whiptail --inputbox "Please enter your Kadena address from Zelcore" 8 85 3>&1 1>&2 2>&3)
- if [[ "$KDA_A" != "" && "$KDA_A" != *kadena* ]]; then
-
- echo -e "${ARROW} ${CYAN}Kadena address is valid.................[${CHECK_MARK}${CYAN}]${NC}"
-
- while true
- do
- KDA_C=$(whiptail --inputbox "Please enter your kadena chainid (0-19)" 8 85 3>&1 1>&2 2>&3)
- if [[ "$KDA_C" -ge "0" && "$KDA_C" -le "19" ]]; then
- echo -e "${ARROW} ${CYAN}Kadena chainid is valid.................[${CHECK_MARK}${CYAN}]${NC}"
- KDA_A="kadena:$KDA_A?chainid=$KDA_C"
- break
- else
- echo -e "${ARROW} ${CYAN}Kadena chainid is not valid.............[${X_MARK}${CYAN}]${NC}"
- sleep 2
- fi
- done
-
- break
- else
- echo -e "${ARROW} ${CYAN}Kadena address is not valid.............[${X_MARK}${CYAN}]${NC}"
- sleep 2
- fi
- done
-
- fi
-
- fi
-
-
-if [[ "$KDA_A" != "" ]]; then
- touch ~/$FLUX_DIR/config/userconfig.js
- cat << EOF > ~/$FLUX_DIR/config/userconfig.js
-module.exports = {
- initial: {
- ipaddress: '${WANIP}',
- zelid: '${ZELID}',
- kadena: '${KDA_A}',
- testnet: false
- }
- }
-EOF
-else
- touch ~/$FLUX_DIR/config/userconfig.js
- cat << EOF > ~/$FLUX_DIR/config/userconfig.js
-module.exports = {
- initial: {
- ipaddress: '${WANIP}',
- zelid: '${ZELID}',
- testnet: false
- }
- }
-EOF
-fi
-
-if [ -d ~/$FLUX_DIR ]
-then
-current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
-
-string_limit_check_mark "Flux v$current_ver installed................................." "Flux ${GREEN}v$current_ver${CYAN} installed................................."
-#echo -e "${ARROW} ${CYAN}Zelflux version: ${GREEN}v$current_ver${CYAN} installed${NC}"
-
-echo
-else
-string_limit_x_mark "Flux was not installed................................."
-#echo -e "${ARROW} ${CYAN}Zelflux was not installed${NC}"
-echo
-fi
-
-}
-
-
-function status_loop() {
-
-network_height_01=$(curl -sk -m 5 https://explorer.runonflux.io/api/status?q=getInfo | jq '.info.blocks')
-network_height_02=$(curl -sk -m 5 https://explorer.flux.zelcore.io/api/status?q=getInfo | jq '.info.blocks')
-network_height_03=$(curl -sk -m 5 https://explorer.zelcash.online/api/status?q=getInfo | jq '.info.blocks')
-
-EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_02" "$network_height_03")
-
-
-if [[ "$EXPLORER_BLOCK_HIGHT" == $(${COIN_CLI} getinfo | jq '.blocks') ]]; then
-echo
-echo -e "${CLOCK}${GREEN} FLUX DAEMON SYNCING...${NC}"
-
-
-LOCAL_BLOCK_HIGHT=$(${COIN_CLI} getinfo 2> /dev/null | jq '.blocks')
-CONNECTIONS=$(${COIN_CLI} getinfo 2> /dev/null | jq '.connections')
-LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
-
-NUM='2'
-MSG1="Syncing progress >> Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN}"
-MSG2="${CYAN} ................[${CHECK_MARK}${CYAN}]${NC}"
-spinning_timer
-echo && echo
-
-else
-
- echo
- echo -e "${CLOCK}${GREEN}FLUX DAEMON SYNCING...${NC}"
-
- f=0
- start_sync=`date +%s`
-
-
- while true
- do
-
- network_height_01=$(curl -sk -m 5 https://explorer.runonflux.io/api/status?q=getInfo | jq '.info.blocks')
- network_height_02=$(curl -sk -m 5 https://explorer.flux.zelcore.io/api/status?q=getInfo | jq '.info.blocks')
- network_height_03=$(curl -sk -m 5 https://explorer.zelcash.online/api/status?q=getInfo | jq '.info.blocks')
-
- EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_02" "$network_height_03")
-
- LOCAL_BLOCK_HIGHT=$(${COIN_CLI} getinfo 2> /dev/null | jq '.blocks')
- CONNECTIONS=$(${COIN_CLI} getinfo 2> /dev/null | jq '.connections')
- LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
-
- if [[ "$LEFT" == "0" ]]; then
- time_break='5'
- else
- time_break='20'
+ echo -e "${ARROW} ${YELLOW}FluxOS installing...${NC}"
+ docker_check=$(docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
+ resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
+ mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
+
+ if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then
+ #echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1
+ echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1
+ echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
fi
-
- #if [[ "$CONNECTIONS" == "0" ]]; then
- # c=$((c+1))
- # if [[ "$c" > 3 ]]; then
- # c=0;
- #LOCAL_BLOCK_HIGHT=""
- # fi
-
- #fi
- #
- if [[ $LOCAL_BLOCK_HIGHT == "" ]]; then
-
- f=$((f+1))
- LOCAL_BLOCK_HIGHT="N/A"
- LEFT="N/A"
- CONNECTIONS="N/A"
- sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
- sudo systemctl start zelcash > /dev/null 2>&1
-
- NUM='60'
- MSG1="Syncing progress => Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN} Failed: ${RED}$f${NC}"
- MSG2=''
- spinning_timer
-
- network_height_01=$(curl -sk -m 5 https://explorer.runonflux.io/api/status?q=getInfo | jq '.info.blocks')
- network_height_02=$(curl -sk -m 5 https://explorer.flux.zelcore.io/api/status?q=getInfo | jq '.info.blocks')
- network_height_03=$(curl -sk -m 5 https://explorer.zelcash.online/api/status?q=getInfo | jq '.info.blocks')
-
- EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_02" "$network_height_03")
-
- LOCAL_BLOCK_HIGHT=$(${COIN_CLI} getinfo 2> /dev/null | jq '.blocks')
- CONNECTIONS=$(${COIN_CLI} getinfo 2> /dev/null | jq '.connections')
- LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+ if [[ $docker_check != 0 ]]; then
+ #echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1
+ echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
+ sudo service docker restart > /dev/null 2>&1 && sleep 2
+ docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" |
+ while read line; do
+ sudo docker stop $line > /dev/null 2>&1 && sleep 2
+ sudo docker rm $line > /dev/null 2>&1 && sleep 2
+ done
+ fi
+ if [[ $resource_check != 0 ]]; then
+ #echo -e "${ARROW} ${YELLOW}Detected locked resource${NC}" && sleep 1
+ echo -e "${ARROW} ${CYAN}Unmounting locked FluxOS resource${NC}" && sleep 1
+ df | egrep 'flux' | awk '{ print $1}' |
+ while read line; do
+ sudo umount -l $line && sleep 1
+ done
+ fi
+ if [ -d "./$FLUX_DIR" ]; then
+ echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS${NC}"
+ sudo rm -rf $FLUX_DIR
fi
- NUM="$time_break"
- MSG1="Syncing progress >> Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN} Failed: ${RED}$f${NC}"
- MSG2=''
- spinning_timer
-
- if [[ "$EXPLORER_BLOCK_HIGHT" == "$LOCAL_BLOCK_HIGHT" ]]; then
- echo -e "${GREEN} Duration: $((($(date +%s)-$start_sync)/60)) min. $((($(date +%s)-$start_sync) % 60)) sec. ${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
- break
- fi
- done
-
- fi
-
-
- #pm2 start ~/$FLUX_DIR/start.sh --name flux --time > /dev/null 2>&1
-
-
- if [[ -z "$mongo_bootstrap" ]]; then
-
- if whiptail --yesno "Would you like to restore Mongodb datatable from bootstrap?" 8 60; then
- mongodb_bootstrap
- else
- echo -e "${ARROW} ${YELLOW}Restore Mongodb datatable skipped...${NC}"
- fi
-
- else
-
- if [[ "$mongo_bootstrap" == "1" ]]; then
- mongodb_bootstrap
- else
- echo -e "${ARROW} ${YELLOW}Restore Mongodb datatable skipped...${NC}"
- fi
-
- fi
-
-
- if [[ -z "$watchdog" ]]; then
- if whiptail --yesno "Would you like to install watchdog for FluxNode?" 8 60; then
- install_watchdog
- else
- echo -e "${ARROW} ${YELLOW}Watchdog installation skipped...${NC}"
- fi
- else
-
- if [[ "$watchdog" == "1" ]]; then
- install_watchdog
- else
- echo -e "${ARROW} ${YELLOW}Watchdog installation skipped...${NC}"
- fi
-
- fi
-
- check
- display_banner
-}
-
-function check() {
-
-cd
-pm2 start /home/$USER/$FLUX_DIR/start.sh --restart-delay=30000 --max-restarts=40 --name flux --time > /dev/null 2>&1
-pm2 save > /dev/null 2>&1
-
-NUM='400'
-MSG1='Finalizing Flux installation please be patient this will take about ~5min...'
-MSG2="${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
-echo && spinning_timer
-echo
-
-$BENCH_CLI restartnodebenchmarks > /dev/null 2>&1
-
-NUM='250'
-MSG1='Restarting benchmark...'
-MSG2="${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
-spinning_timer
-echo && echo
-
-echo -e "${BOOK}${YELLOW} Flux benchmarks:${NC}"
-echo -e "${YELLOW}======================${NC}"
-bench_benchmarks=$($BENCH_CLI getbenchmarks)
-
-if [[ "bench_benchmarks" != "" ]]; then
-bench_status=$(jq -r '.status' <<< "$bench_benchmarks")
-if [[ "$bench_status" == "failed" ]]; then
-echo -e "${ARROW} ${CYAN}Flux benchmark failed...............[${X_MARK}${CYAN}]${NC}"
-check_benchmarks "eps" "89.99" " CPU speed" "< 90.00 events per second"
-check_benchmarks "ddwrite" "159.99" " Disk write speed" "< 160.00 events per second"
-else
-echo -e "${BOOK}${CYAN} STATUS: ${GREEN}$bench_status${NC}"
-bench_cores=$(jq -r '.cores' <<< "$bench_benchmarks")
-echo -e "${BOOK}${CYAN} CORES: ${GREEN}$bench_cores${NC}"
-bench_ram=$(jq -r '.ram' <<< "$bench_benchmarks")
-bench_ram=$(round "$bench_ram" 2)
-echo -e "${BOOK}${CYAN} RAM: ${GREEN}$bench_ram${NC}"
-bench_ssd=$(jq -r '.ssd' <<< "$bench_benchmarks")
-bench_ssd=$(round "$bench_ssd" 2)
-echo -e "${BOOK}${CYAN} SSD: ${GREEN}$bench_ssd${NC}"
-bench_hdd=$(jq -r '.hdd' <<< "$bench_benchmarks")
-bench_hdd=$(round "$bench_hdd" 2)
-echo -e "${BOOK}${CYAN} HDD: ${GREEN}$bench_hdd${NC}"
-bench_ddwrite=$(jq -r '.ddwrite' <<< "$bench_benchmarks")
-bench_ddwrite=$(round "$bench_ddwrite" 2)
-echo -e "${BOOK}${CYAN} DDWRITE: ${GREEN}$bench_ddwrite${NC}"
-bench_eps=$(jq -r '.eps' <<< "$bench_benchmarks")
-bench_eps=$(round "$bench_eps" 2)
-echo -e "${BOOK}${CYAN} EPS: ${GREEN}$bench_eps${NC}"
-fi
-
-else
-echo -e "${ARROW} ${CYAN}Flux benchmark not responding.................[${X_MARK}${CYAN}]${NC}"
-fi
-}
-
-function display_banner() {
- echo -e "${BLUE}"
- figlet -t -k "FLUXNODE"
- figlet -t -k "INSTALLATION COMPLETED"
- echo -e "${YELLOW}================================================================================================================================"
- #echo -e "FLUXNODE INSTALATION COMPLITED${NC}"
- #echo -e "${CYAN}COURTESY OF DK808/XK4MiLX${NC}"
- echo
- if pm2 -v > /dev/null 2>&1; then
- pm2_flux_status=$(pm2 info flux 2> /dev/null | grep 'status' | sed -r 's/│//gi' | sed 's/status.//g' | xargs)
- if [[ "$pm2_flux_status" == "online" ]]; then
- pm2_flux_uptime=$(pm2 info flux | grep 'uptime' | sed -r 's/│//gi' | sed 's/uptime//g' | xargs)
- pm2_flux_restarts=$(pm2 info flux | grep 'restarts' | sed -r 's/│//gi' | xargs)
- echo -e "${BOOK} ${CYAN}Pm2 Flux info => status: ${GREEN}$pm2_flux_status${CYAN}, uptime: ${GREEN}$pm2_flux_uptime${NC} ${SEA}$pm2_flux_restarts${NC}"
+ git clone https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Creating FluxOS configuration file...${NC}"
+ fluxos_conf_create
+ if [ -d ~/$FLUX_DIR ]; then
+ current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
+ string_limit_check_mark "FluxOS v$current_ver installed................................." "FluxOS ${GREEN}v$current_ver${CYAN} installed................................."
+ echo -e ""
else
- if [[ "$pm2_flux_status" != "" ]]; then
- pm2_flux_restarts=$(pm2 info flux | grep 'restarts' | sed -r 's/│//gi' | xargs)
- echo -e "${PIN} ${CYAN}PM2 Flux status: ${RED}$pm2_flux_status${NC}, restarts: ${RED}$pm2_flux_restarts${NC}"
- fi
+ string_limit_x_mark "FluxOS was not installed................................."
+ echo -e ""
fi
- echo
- fi
- echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE FLUX DAEMON.${NC}"
- echo -e "${PIN} ${CYAN}Start Flux daemon: ${SEA}sudo systemctl start zelcash${NC}"
- echo -e "${PIN} ${CYAN}Stop Flux daemon: ${SEA}sudo systemctl stop zelcash${NC}"
- echo -e "${PIN} ${CYAN}Help list: ${SEA}${COIN_CLI} help${NC}"
- echo
- echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE BENCHMARK.${NC}"
- echo -e "${PIN} ${CYAN}Get info: ${SEA}zelbench-cli getinfo${NC}"
- echo -e "${PIN} ${CYAN}Check benchmark: ${SEA}zelbench-cli getbenchmarks${NC}"
- echo -e "${PIN} ${CYAN}Restart benchmark: ${SEA}zelbench-cli restartnodebenchmarks${NC}"
- echo -e "${PIN} ${CYAN}Stop benchmark: ${SEA}zelbench-cli stop${NC}"
- echo -e "${PIN} ${CYAN}Start benchmark: ${SEA}sudo systemctl restart zelcash${NC}"
- echo
- echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE FLUX.${NC}"
- echo -e "${PIN} ${CYAN}Summary info: ${SEA}pm2 info flux${NC}"
- echo -e "${PIN} ${CYAN}Logs in real time: ${SEA}pm2 monit${NC}"
- echo -e "${PIN} ${CYAN}Stop Flux: ${SEA}pm2 stop flux${NC}"
- echo -e "${PIN} ${CYAN}Start Flux: ${SEA}pm2 start flux${NC}"
- echo
- if [[ "$WATCHDOG_INSTALL" == "1" ]]; then
- echo -e "${ARROW}${YELLOW} COMMANDS TO MANAGE WATCHDOG.${NC}"
- echo -e "${PIN} ${CYAN}Stop watchdog: ${SEA}pm2 stop watchdog${NC}"
- echo -e "${PIN} ${CYAN}Start watchdog: ${SEA}pm2 start watchdog --watch${NC}"
- echo -e "${PIN} ${CYAN}Restart watchdog: ${SEA}pm2 reload watchdog --watch${NC}"
- echo -e "${PIN} ${CYAN}Error logs: ${SEA}~/watchdog/watchdog_error.log${NC}"
- echo -e "${PIN} ${CYAN}Logs in real time: ${SEA}pm2 monit${NC}"
- echo
- echo -e "${PIN} ${RED}IMPORTANT: After installation check ${SEA}'pm2 list'${RED} if not work, type ${SEA}'source /home/$USER/.bashrc'${NC}"
- echo
- fi
- echo -e "${PIN} ${CYAN}To access your frontend to Flux enter this in as your url: ${SEA}${WANIP}:${ZELFRONTPORT}${NC}"
- echo -e "${YELLOW}===================================================================================================================[${GREEN}Duration: $((($(date +%s)-$start_install)/60)) min. $((($(date +%s)-$start_install) % 60)) sec.${YELLOW}]${NC}"
- sleep 1
- cd $HOME
- exec bash
}
-function start_install() {
-
-start_install=`date +%s`
-
-sudo echo -e "$USER ALL=(ALL) NOPASSWD:ALL" | sudo EDITOR='tee -a' visudo
-echo -e "${CYAN}February 2021, created by dk808 improved by XK4MiLX from Flux's team."
-echo -e "Special thanks to Goose-Tech, Skyslayer, & Packetflow."
-echo -e "FluxNode setup starting, press [CTRL+C] to cancel.${NC}"
-sleep 2
-
-if jq --version > /dev/null 2>&1; then
-echo -e ""
-else
-echo -e ""
-echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}"
-sudo apt install jq -y > /dev/null 2>&1
-
- if jq --version > /dev/null 2>&1
- then
- #echo -e "${ARROW} ${CYAN}Nodejs version: ${GREEN}$(node -v)${CYAN} installed${NC}"
- string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................."
- echo
- else
- #echo -e "${ARROW} ${CYAN}Nodejs was not installed${NC}"
- string_limit_x_mark "JQ was not installed................................."
- echo
- exit
- fi
-fi
-
-if [ "$USER" = "root" ]; then
- echo -e "${CYAN}You are currently logged in as ${GREEN}root${CYAN}, please switch to the username you just created.${NC}"
- sleep 4
- exit
-fi
-
-start_dir=$(pwd)
-correct_dir="/home/$USER"
-echo -e "${ARROW} ${YELLOW}Checking directory....${NC}"
-if [[ "$start_dir" == "$correct_dir" ]]
-then
-echo -e "${ARROW} ${CYAN}Correct directory ${GREEN}$(pwd)${CYAN} ................[${CHECK_MARK}${CYAN}]${NC}"
-else
-echo -e "${ARROW} ${CYAN}Bad directory switching...${NC}"
-cd
-echo -e "${ARROW} ${CYAN}Current directory ${GREEN}$(pwd)${CYAN}${NC}"
-fi
-sleep 1
-
-config_file
-
-if [[ -z "$index" || -z "$outpoint" || -z "$prvkey" ]]; then
-import_date
-else
-
-if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" && "$ZELID" != "" ]]; then
-echo
-IMPORT_ZELCONF="1"
-IMPORT_ZELID="1"
-echo -e "${ARROW} ${YELLOW}Install conf settings:${NC}"
-zelnodeprivkey="$prvkey"
-echo -e "${PIN}${CYAN}Private Key = ${GREEN}$zelnodeprivkey${NC}" && sleep 1
-zelnodeoutpoint="$outpoint"
-echo -e "${PIN}${CYAN}Output TX ID = ${GREEN}$zelnodeoutpoint${NC}" && sleep 1
-zelnodeindex="$index"
-echo -e "${PIN}${CYAN}Output Index = ${GREEN}$zelnodeindex${NC}" && sleep 1
-echo -e "${PIN}${CYAN}Zel ID = ${GREEN}$ZELID${NC}" && sleep 1
-echo
+#end of functions
+start_install
+wipe_clean
+ssh_port
+get_ip "install"
+create_swap
+install_packages
+create_conf
+install_daemon
+zk_params
+if [[ "$BOOTSTRAP_SKIP" == "0" ]]; then
+ bootstrap_new "install"
+fi
+create_service_scripts
+create_service "install"
+selfhosting "install"
+install_process
+start_daemon
+log_rotate "Flux benchmark" "bench_debug_log" "/home/$USER/$BENCH_DIR_LOG/debug.log" "monthly" "2"
+log_rotate "Flux daemon" "daemon_debug_log" "/home/$USER/$CONFIG_DIR/debug.log" "daily" "7"
+log_rotate "MongoDB" "mongod_debug_log" "/var/log/mongodb/*.log" "daily" "14"
+#log_rotate "Docker" "docker_debug_log" "/var/lib/docker/containers/*/*.log" "daily" "7"
+basic_security
+status_loop
+install_watchdog
+if [[ "$thunder" == "1" ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Thunder Mode configuration...${NC}"
+ thunder_mode "install"
fi
-
+if [[ "$gateway_ip" != "" && "$upnp_port" != "" ]] && [[ "$upnp_port" != "null" ]] && [[ "$upnp_enabled" == "true" ]] ; then
+ upnp_enable "install"
fi
-
-}
-
-#end of functions
- start_install
- wipe_clean
- ssh_port
- ip_confirm
- create_swap
- install_packages
- create_conf
- install_daemon
- zk_params
- if [[ "$BOOTSTRAP_SKIP" == "0" ]]; then
- bootstrap
- fi
- create_service_scripts
- create_service
- install_process
- start_daemon
- log_rotate "Flux benchmark" "bench_debug_log" "/home/$USER/$BENCH_DIR_LOG/debug.log" "monthly" "2"
- log_rotate "Flux daemon" "daemon_debug_log" "/home/$USER/$CONFIG_DIR/debug.log" "daily" "7"
- log_rotate "MongoDB" "mongod_debug_log" "/var/log/mongodb/*.log" "daily" "14"
- basic_security
- status_loop
+finalizing
+display_banner
diff --git a/install_pro_testnet.sh b/install_pro_testnet.sh
new file mode 100755
index 00000000..088621d3
--- /dev/null
+++ b/install_pro_testnet.sh
@@ -0,0 +1,1389 @@
+#!/bin/bash
+
+source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/flux_common.sh)"
+
+# Bootstrap settings
+BOOTSTRAP_ZIP='https://fluxnodeservice.com/daemon_bootstrap.tar.gz'
+BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz'
+BOOTSTRAP_URL_MONGOD='https://fluxnodeservice.com/mongod_bootstrap.tar.gz'
+BOOTSTRAP_ZIPFILE_MONGOD='mongod_bootstrap.tar.gz'
+
+#wallet information
+COIN_NAME='flux'
+CONFIG_DIR='.flux'
+CONFIG_FILE='flux.conf'
+
+BENCH_NAME='fluxbench'
+BENCH_CLI='fluxbench-cli'
+BENCH_DIR_LOG='.fluxbenchmark'
+
+COIN_DAEMON='fluxd'
+COIN_CLI='flux-cli'
+COIN_PATH='/usr/local/bin'
+
+USERNAME="$(whoami)"
+FLUX_DIR='zelflux'
+
+#Install variable
+IMPORT_ZELCONF="0"
+IMPORT_ZELID="0"
+CORRUPTED="0"
+BOOTSTRAP_SKIP="0"
+WATCHDOG_INSTALL="0"
+
+#Zelflux ports
+ZELFRONTPORT=16126
+LOCPORT=16127
+ZELNODEPORT=16128
+#MDBPORT=27017
+RPCPORT=16124
+PORT=16125
+
+
+function import_date() {
+
+if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE || -f /home/$USER/.zelcash/zelcash.conf ]]; then
+
+ if [[ -z "$import_settings" ]]; then
+
+ if whiptail --yesno "Would you like to import data from Flux config files Y/N?" 8 60; then
+
+ OLD_CONFIG=0
+
+ if [[ -d /home/$USER/.zelcash ]]; then
+ CONFIG_DIR='.zelcash'
+ CONFIG_FILE='zelcash.conf'
+ OLD_CONFIG=1
+ fi
+
+ IMPORT_ZELCONF="1"
+ echo
+ echo -e "${ARROW} ${YELLOW}Imported settings:${NC}"
+ zelnodeprivkey=$(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//')
+ echo -e "${PIN}${CYAN} Identity Key = ${GREEN}$zelnodeprivkey${NC}" && sleep 1
+ zelnodeoutpoint=$(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
+ echo -e "${PIN}${CYAN} Collateral TX ID = ${GREEN}$zelnodeoutpoint${NC}" && sleep 1
+ zelnodeindex=$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ echo -e "${PIN}${CYAN} Collateral Output Index = ${GREEN}$zelnodeindex${NC}" && sleep 1
+
+ if [[ "$OLD_CONFIG" == "1" ]]; then
+ CONFIG_DIR='.flux'
+ CONFIG_FILE='flux.conf'
+ fi
+
+ if [[ -f ~/$FLUX_DIR/config/userconfig.js ]]; then
+
+ ZELID=$(grep -w zelid ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
+
+ if [[ "$ZELID" != "" ]]; then
+ echo -e "${PIN}${CYAN} Zel ID = ${GREEN}$ZELID${NC}" && sleep 1
+ IMPORT_ZELID="1"
+ fi
+
+ # KDA_A=$(grep -w kadena ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
+ # if [[ "$KDA_A" != "" ]]; then
+ # echo -e "${PIN}${CYAN} KDA address = ${GREEN}$KDA_A${NC}" && sleep 1
+ # fi
+
+ fi
+ fi
+
+else
+
+ if [[ "$import_settings" == "1" ]]; then
+
+ OLD_CONFIG=0
+
+ if [[ -d /home/$USER/.zelcash ]]; then
+ CONFIG_DIR='.zelcash'
+ CONFIG_FILE='zelcash.conf'
+ OLD_CONFIG=1
+ fi
+
+ IMPORT_ZELCONF="1"
+ echo
+ echo -e "${ARROW} ${YELLOW}Imported settings:${NC}"
+ zelnodeprivkey=$(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//')
+ echo -e "${PIN}${CYAN} Identity Key = ${GREEN}$zelnodeprivkey${NC}" && sleep 1
+ zelnodeoutpoint=$(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
+ echo -e "${PIN}${CYAN} Collateral Output TX ID = ${GREEN}$zelnodeoutpoint${NC}" && sleep 1
+ zelnodeindex=$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ echo -e "${PIN}${CYAN} Output Index = ${GREEN}$zelnodeindex${NC}" && sleep 1
+
+ if [[ "$OLD_CONFIG" == "1" ]]; then
+ CONFIG_DIR='.flux'
+ CONFIG_FILE='flux.conf'
+ fi
+
+
+ if [[ -f ~/$FLUX_DIR/config/userconfig.js ]]; then
+
+ ZELID=$(grep -w zelid ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
+
+ if [[ "$ZELID" != "" ]]; then
+ echo -e "${PIN}${CYAN} Zel ID = ${GREEN}$ZELID${NC}" && sleep 1
+ IMPORT_ZELID="1"
+ fi
+
+ # KDA_A=$(grep -w kadena ~/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
+ # if [[ "$KDA_A" != "" ]]; then
+ # echo -e "${PIN}${CYAN} KDA address = ${GREEN}$KDA_A${NC}" && sleep 1
+ # fi
+ fi
+ fi
+
+ fi
+fi
+sleep 1
+echo
+}
+
+
+function install_watchdog() {
+echo -e "${ARROW} ${YELLOW}Install watchdog for FluxNode${NC}"
+if pm2 -v > /dev/null 2>&1
+then
+WATCHDOG_INSTALL="1"
+echo -e "${ARROW} ${YELLOW}Downloading...${NC}"
+cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1
+echo -e "${ARROW} ${YELLOW}Installing git hooks....${NC}"
+wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1
+mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
+sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
+echo -e "${ARROW} ${YELLOW}Installing watchdog module....${NC}"
+cd watchdog && npm install > /dev/null 2>&1
+echo -e "${ARROW} ${CYAN}Creating config file....${NC}"
+
+#if whiptail --yesno "Would you like enable FluxOS auto update?" 8 60; then
+flux_update='1'
+#sleep 1
+#else
+#lux_update='0'
+#sleep 1
+#fi
+
+#if whiptail --yesno "Would you like enable Flux daemon auto update?" 8 60; then
+daemon_update='1'
+#sleep 1
+#else
+#daemon_update='0'
+#sleep 1
+#fi
+
+#if whiptail --yesno "Would you like enable Flux benchmark auto update?" 8 60; then
+bench_update='1'
+#sleep 1
+#else
+#bench_update='0'
+#sleep 1
+#fi
+
+#if whiptail --yesno "Would you like enable fix action (restart daemon, benchmark, mongodb)?" 8 75; then
+fix_action='1'
+#sleep 1
+#else
+#fix_action='0'
+#sleep 1
+#fi
+
+telegram_alert=0;
+discord=0;
+
+if whiptail --yesno "Would you like enable alert notification?" 8 60; then
+
+sleep 1
+
+whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60
+
+sleep 1
+
+CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \
+ "1" "Discord notification " ON \
+ "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 )
+
+if [ -z "$CHOICES" ]; then
+
+ echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}"
+ sleep 1
+ discord=0;
+ ping=0;
+ telegram_alert=0;
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ node_label=0;
+
+else
+ for CHOICE in $CHOICES; do
+ case "$CHOICE" in
+ "1")
+
+ discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+
+ if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then
+
+ while true
+ do
+ ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3)
+ if [[ $ping == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "UserID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "UserID is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+ else
+ ping=0;
+ sleep 1
+ fi
+
+ ;;
+ "2")
+
+ telegram_alert=1;
+
+ while true
+ do
+ telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3)
+ if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then
+ string_limit_check_mark "Bot token is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Bot token is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+ while true
+ do
+ telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3)
+ if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "Chat ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Chat ID is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+ ;;
+ esac
+ done
+fi
+
+ while true
+ do
+ node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3)
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ string_limit_check_mark "Node name is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Node name is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+else
+
+ discord=0;
+ ping=0;
+ telegram_alert=0;
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ node_label=0;
+ sleep 1
+fi
+
+
+if [[ "$discord" == 0 ]]; then
+ ping=0;
+fi
+
+
+if [[ "$telegram_alert" == 0 ]]; then
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+fi
+
+if [[ -f /home/$USER/$CONFIG_DIR/testnet/$CONFIG_FILE ]]; then
+ index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/testnet/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ tx_from_file=$(grep -w zelnodeoutpoint /home/$USER/$CONFIG_DIR/testnet/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
+ stak_info=$(curl -s -m 5 https://testnet.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '10000|25000|100000')
+
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -s -m 5 https://testnet.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '10000|25000|100000')
+ fi
+fi
+
+if [[ $stak_info == ?(-)+([0-9]) ]]; then
+
+ case $stak_info in
+ "10000") eps_limit=90 ;;
+ "25000") eps_limit=180 ;;
+ "100000") eps_limit=300 ;;
+ esac
+
+else
+eps_limit=0;
+fi
+
+
+sudo touch /home/$USER/watchdog/config.js
+sudo chown $USER:$USER /home/$USER/watchdog/config.js
+ cat << EOF > /home/$USER/watchdog/config.js
+module.exports = {
+ label: '${node_label}',
+ tier_eps_min: '${eps_limit}',
+ zelflux_update: '${flux_update}',
+ zelcash_update: '${daemon_update}',
+ zelbench_update: '${bench_update}',
+ action: '${fix_action}',
+ ping: '${ping}',
+ web_hook_url: '${discord}',
+ telegram_alert: '${telegram_alert}',
+ telegram_bot_token: '${telegram_bot_token}',
+ telegram_chat_id: '${telegram_chat_id}'
+}
+EOF
+
+echo -e "${ARROW} ${YELLOW}Starting watchdog...${NC}"
+pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
+pm2 save > /dev/null 2>&1
+if [[ -f /home/$USER/watchdog/watchdog.js ]]
+then
+current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
+#echo -e "${ARROW} ${CYAN}Watchdog ${GREEN}v$current_ver${CYAN} installed successful.${NC}"
+string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................."
+else
+#echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}"
+string_limit_x_mark "Watchdog was not installed................................."
+fi
+else
+#echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}"
+string_limit_x_mark "Watchdog was not installed................................."
+fi
+}
+
+function mongodb_bootstrap(){
+
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Restore mongodb datatable from bootstrap${NC}"
+
+ DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
+ if [[ "$DB_HIGHT" == "" ]]; then
+ DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
+ fi
+
+ #BLOCKHIGHT=$(curl -s -m 6 http://"$WANIP":16127/explorer/scannedheight | jq '.data.generalScannedHeight')
+ echo -e "${ARROW} ${CYAN}Bootstrap block height: ${GREEN}$DB_HIGHT${NC}"
+ echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$BOOTSTRAP_URL_MONGOD${NC}"
+ wget --tries=5 $BOOTSTRAP_URL_MONGOD -q --show-progress
+
+ if [[ -f /home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD ]]; then
+
+ echo -e "${ARROW} ${CYAN}Unpacking...${NC}"
+ tar xvf $BOOTSTRAP_ZIPFILE_MONGOD -C /home/$USER > /dev/null 2>&1 && sleep 1
+ echo -e "${ARROW} ${CYAN}Importing mongodb datatable...${NC}"
+ mongorestore --port 27017 --db zelcashdata /home/$USER/dump/zelcashdata --drop > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
+ sudo rm -rf /home/$USER/dump > /dev/null 2>&1 && sleep 1
+ sudo rm -rf $BOOTSTRAP_ZIPFILE_MONGOD > /dev/null 2>&1 && sleep 1
+
+
+ BLOCKHIGHT_AFTER_BOOTSTRAP=$(mongoexport -d zelcashdata -c scannedheight --jsonArray --pretty --quiet | jq -r .[].generalScannedHeight)
+ echo -e ${ARROW} ${CYAN}Node block height after restored: ${GREEN}$BLOCKHIGHT_AFTER_BOOTSTRAP${NC}
+
+ else
+
+ echo -e "${ARROW} ${RED}MongoDB bootstrap server offline...try again later use option 5${NC}"
+ fi
+
+ echo -e ""
+
+ #if [[ "$BLOCKHIGHT_AFTER_BOOTSTRAP" -ge "$DB_HIGHT" ]]; then
+ #echo -e "${ARROW} ${CYAN}Mongo bootstrap installed successful.${NC}"
+ #echo -e ""
+ # else
+ # echo -e "${ARROW} ${CYAN}Mongo bootstrap installation failed.${NC}"
+ # echo -e ""
+ # fi
+
+}
+
+function wipe_clean() {
+ echo -e "${ARROW} ${YELLOW}Removing any instances of FluxNode${NC}"
+ apt_number=$(ps aux | grep 'apt' | wc -l)
+
+ if [[ "$apt_number" > 1 ]]; then
+
+ sudo killall apt > /dev/null 2>&1
+ sudo killall apt-get > /dev/null 2>&1
+ sudo dpkg --configure -a > /dev/null 2>&1
+
+ fi
+
+ echo -e "${ARROW} ${CYAN}Stopping all services and running processes...${NC}"
+
+ # NEW CLEAN_UP
+
+ sudo killall nano > /dev/null 2>&1
+ $COIN_CLI stop > /dev/null 2>&1 && sleep 2
+ sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
+ sudo killall -s SIGKILL $COIN_DAEMON > /dev/null 2>&1 && sleep 2
+ $BENCH_CLI stop > /dev/null 2>&1 && sleep 2
+ sudo killall -s SIGKILL $BENCH_NAME > /dev/null 2>&1 && sleep 1
+ sudo fuser -k 16127/tcp > /dev/null 2>&1 && sleep 1
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /usr/bin/flux* > /dev/null 2>&1 && sleep 1
+
+ echo -e "${ARROW} ${CYAN}Removing daemon && benchmark...${NC}"
+ sudo apt-get remove $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get purge $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1
+ tmux kill-server > /dev/null 2>&1 && sleep 1
+
+ echo -e "${ARROW} ${CYAN}Removing PM2...${NC}"
+ pm2 del zelflux > /dev/null 2>&1 && sleep 1
+ pm2 del flux > /dev/null 2>&1 && sleep 1
+ pm2 del watchdog > /dev/null 2>&1 && sleep 1
+ pm2 save > /dev/null 2>&1
+ pm2 unstartup > /dev/null 2>&1 && sleep 1
+ pm2 flush > /dev/null 2>&1 && sleep 1
+ pm2 save > /dev/null 2>&1 && sleep 1
+ pm2 kill > /dev/null 2>&1 && sleep 1
+ npm remove pm2 -g > /dev/null 2>&1 && sleep 1
+
+ echo -e "${ARROW} ${CYAN}Removing others files and scripts...${NC}"
+ sudo rm -rf watchgod > /dev/null 2>&1 && sleep 1
+ sudo rm -rf $BENCH_DIR_LOG && sleep 1
+
+ #FILE OF OLD ZEL NODE
+ sudo rm -rf /etc/logrotate.d/mongolog > /dev/null 2>&1
+ sudo rm -rf /etc/logrotate.d/zeldebuglog > /dev/null 2>&1
+ rm update.sh > /dev/null 2>&1
+ rm restart_zelflux.sh > /dev/null 2>&1
+ rm zelnodeupdate.sh > /dev/null 2>&1
+ rm start.sh > /dev/null 2>&1
+ rm update-zelflux.sh > /dev/null 2>&1
+ sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
+ zelcash-cli stop > /dev/null 2>&1 && sleep 2
+ sudo killall -s SIGKILL zelcashd > /dev/null 2>&1
+ zelbench-cli stop > /dev/null 2>&1
+ sudo killall -s SIGKILL zelbenchd > /dev/null 2>&1
+ sudo rm /usr/local/bin/zel* > /dev/null 2>&1 && sleep 1
+ sudo apt-get purge zelcash zelbench -y > /dev/null 2>&1 && sleep 1
+ sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1
+ sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1
+ sudo rm -rf zelflux > /dev/null 2>&1 && sleep 1
+ #sudo rm -rf ~/.zelcash/determ_zelnodes ~/.zelcash/sporks ~/$CONFIG_DIR/database ~/.zelcash/blocks ~/.zelcashchainstate > /dev/null 2>&1 && sleep 1
+ #sudo rm -rf ~/.zelcash > /dev/null 2>&1 && sleep 1
+ sudo rm -rf .zelbenchmark > /dev/null 2>&1 && sleep 1
+ sudo rm -rf /home/$USER/stop_zelcash_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/start_zelcash_service.sh > /dev/null 2>&1
+
+ if [[ -d /home/$USER/.zelcash ]]; then
+
+ echo -e "${ARROW} ${CYAN}Moving ~/.zelcash to ~/.flux${NC}"
+ #echo -e "${ARROW} ${CYAN}Renaming zelcash.conf to flux.conf${NC}"
+ sudo mv /home/$USER/.zelcash /home/$USER/.flux > /dev/null 2>&1 && sleep 1
+ sudo mv /home/$USER/.flux/zelcash.conf /home/$USER/.flux/flux.conf > /dev/null 2>&1 && sleep 1
+
+ fi
+
+
+ if [[ -d /home/$USER/$CONFIG_DIR ]]; then
+
+ if [[ -z "$use_old_chain" ]]; then
+
+ if ! whiptail --yesno "Would you like to use old chain from Flux daemon config directory?" 8 60; then
+ echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
+ sudo rm -rf ~/$CONFIG_DIR/determ_zelnodes ~/$CONFIG_DIR/sporks ~/$CONFIG_DIR/database ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate && sleep 2
+ sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 && sleep 2
+
+ else
+ BOOTSTRAP_SKIP="1"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/db.log
+ sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/database && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/sporks && sleep 1
+ fi
+
+ else
+
+ if [[ "$use_old_chain" == "1" ]]; then
+
+ BOOTSTRAP_SKIP="1"
+ sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat
+ sudo rm -rf /home/$USER/$CONFIG_DIR/db.log
+ sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/database && sleep 1
+ sudo rm -rf /home/$USER/$CONFIG_DIR/sporks && sleep 1
+
+ else
+
+ echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}"
+ sudo rm -rf ~/$CONFIG_DIR/determ_zelnodes ~/$CONFIG_DIR/sporks ~/$CONFIG_DIR/database ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate && sleep 2
+ sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 && sleep 2
+
+
+ fi
+
+ fi
+fi
+
+ sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
+ sudo rm -rf /home/$USER/stop_daemon_service.sh > /dev/null 2>&1
+ sudo rm -rf /home/$USER/start_daemon_service.sh > /dev/null 2>&1
+ echo -e ""
+
+ echo -e "${ARROW} ${YELLOW}Checking firewall status...${NC}" && sleep 1
+ if [[ $(sudo ufw status | grep "Status: active") ]]; then
+ # if [[ -z "$firewall_disable" ]]; then
+ # if whiptail --yesno "Firewall is active and enabled. Do you want disable it during install process?(Recommended)" 8 60; then
+ sudo ufw disable > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
+ # else
+ # echo -e "${ARROW} ${CYAN}Firewall status: ${GREEN}Enabled${NC}"
+ # fi
+ else
+
+ # if [[ "$firewall_disable" == "1" ]]; then
+ #sudo ufw disable > /dev/null 2>&1
+ # echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
+ # else
+ # echo -e "${ARROW} ${CYAN}Firewall status: ${GREEN}Enabled${NC}"
+ # fi
+ # fi
+
+ # else
+ echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}"
+ fi
+
+}
+
+
+function ssh_port() {
+
+ if [[ -z "$ssh_port" ]]; then
+
+ SSHPORT=$(grep -w Port /etc/ssh/sshd_config | sed -e 's/.*Port //')
+ if ! whiptail --yesno "Detected you are using $SSHPORT for SSH is this correct?" 8 56; then
+ SSHPORT=$(whiptail --inputbox "Please enter port you are using for SSH" 8 43 3>&1 1>&2 2>&3)
+ echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
+ else
+ echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
+ fi
+
+ else
+ pettern='^[0-9]+$'
+ if [[ $ssh_port =~ $pettern ]] ; then
+ SSHPORT="$ssh_port"
+ echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1
+ else
+ echo -e "${ARROW} ${CYAN}SSH port must be integer................[${X_MARK}${CYAN}]${NC}}"
+ echo
+ exit
+ fi
+ fi
+}
+
+function ip_confirm() {
+ echo -e "${ARROW} ${YELLOW}Detecting IP address...${NC}"
+
+ WANIP=$(curl --silent -m 15 https://api4.my-ip.io/ip | tr -dc '[:alnum:].')
+
+ if [[ "$WANIP" == "" ]]; then
+ WANIP=$(curl --silent -m 15 https://checkip.amazonaws.com | tr -dc '[:alnum:].')
+ fi
+
+ if [[ "$WANIP" == "" ]]; then
+ WANIP=$(curl --silent -m 15 https://api.ipify.org | tr -dc '[:alnum:].')
+ fi
+
+
+ if [[ "$WANIP" == "" ]]; then
+ echo -e "${ARROW} ${CYAN}IP address could not be found, installation stopped .........[${X_MARK}${CYAN}]${NC}"
+ echo
+ exit
+ fi
+
+
+ string_limit_check_mark "Detected IP: $WANIP ................................." "Detected IP: ${GREEN}$WANIP${CYAN} ................................."
+
+}
+
+
+function create_conf() {
+
+ echo -e "${ARROW} ${YELLOW}Creating Flux daemon config file...${NC}"
+ if [ -f ~/$CONFIG_DIR/$CONFIG_FILE ]; then
+ echo -e "${ARROW} ${CYAN}Existing conf file found backing up to $COIN_NAME.old ...${NC}"
+ mv ~/$CONFIG_DIR/$CONFIG_FILE ~/$CONFIG_DIR/$COIN_NAME.old;
+ fi
+
+ RPCUSER=$(pwgen -1 8 -n)
+ PASSWORD=$(pwgen -1 20 -n)
+
+ if [[ "$IMPORT_ZELCONF" == "0" ]]
+ then
+ zelnodeprivkey=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)
+ zelnodeoutpoint=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3)
+ zelnodeindex=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Output Index usually a 0/1" 8 60 3>&1 1>&2 2>&3)
+ fi
+
+
+ if [ "x$PASSWORD" = "x" ]; then
+ PASSWORD=${WANIP}-$(date +%s)
+ fi
+ mkdir -p ~/$CONFIG_DIR > /dev/null 2>&1
+ touch ~/$CONFIG_DIR/$CONFIG_FILE
+ cat << EOF > ~/$CONFIG_DIR/$CONFIG_FILE
+rpcuser=$RPCUSER
+rpcpassword=$PASSWORD
+rpcallowip=127.0.0.1
+rpcallowip=172.18.0.1
+rpcport=$RPCPORT
+port=$PORT
+zelnode=1
+zelnodeprivkey=$zelnodeprivkey
+zelnodeoutpoint=$zelnodeoutpoint
+zelnodeindex=$zelnodeindex
+server=1
+daemon=1
+txindex=1
+addressindex=1
+timestampindex=1
+spentindex=1
+insightexplorer=1
+experimentalfeatures=1
+testnet=1
+listen=1
+externalip=$WANIP
+bind=0.0.0.0
+addnode=testnet.runonflux.io
+maxconnections=256
+EOF
+ sleep 2
+
+}
+
+function install_daemon() {
+ sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1
+ sudo rm /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Configuring daemon repository and importing public GPG Key${NC}"
+ sudo chown -R $USER:$USER /usr/share/keyrings > /dev/null 2>&1
+ sudo chown -R $USER:$USER /home/$USER/.gnupg > /dev/null 2>&1
+ if [[ "$(lsb_release -cs)" == "xenial" ]]; then
+ echo 'deb https://apt.fluxos.network/ '$(lsb_release -cs)' main' | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
+ gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B69CA27A986265D > /dev/null 2>&1
+ gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
+ if ! gpg --list-keys Zel > /dev/null; then
+ gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1
+ fi
+ flux_package && sleep 2
+ else
+ sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/flux-archive-keyring.gpg] https://apt.fluxos.network/ focal main" | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/flux-archive-keyring.gpg] https://apt.runonflux.io/ focal main" | sudo tee --append /etc/apt/sources.list.d/flux.list > /dev/null 2>&1
+ # downloading key && save it as keyring
+ gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ key_counter=0
+ until [ $key_counter -gt 5 ]
+ do
+ if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
+ break
+ fi
+ echo -e "${CYAN}Retrieve keys failed will try again...${NC}"
+ sleep 5
+ sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1
+ gpg --no-default-keyring --keyring /usr/share/keyrings/flux-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1
+ ((key_counter++))
+ done
+
+ if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then
+ flux_package && sleep 2
+ else
+ echo -e ""
+ echo -e "${WORNING} ${RED}Importing public GPG Key failed...${NC}"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo -e ""
+ exit
+ fi
+ fi
+sudo rm -rf /tmp/*lux* 2>&1 && sleep 2
+if [[ $(dpkg --print-architecture) = *amd* ]]; then
+ echo -e "${ARROW} ${CYAN}Downloading testnet file...${NC}"
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Flux-amd64-v6.2.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Flux-amd64-v6.2.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Fluxbench-Linux-v3.9.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Fluxbench-Linux-v3.9.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1
+ sudo rm -rf /tmp/flux* 2>&1 && sleep 2
+ sudo rm -rf /tmp/Flux* 2>&1 && sleep 2
+else
+ echo -e "${ARROW} ${CYAN}Downloading testnet file...${NC}"
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Flux-arm-6.2.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Flux-arm-6.2.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Fluxbench-arm-v3.9.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Fluxbench-arm-v3.9.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1
+ sudo rm -rf /tmp/flux* 2>&1 && sleep 2
+ sudo rm -rf /tmp/Flux* 2>&1 && sleep 2
+fi
+sudo chmod 755 $COIN_PATH/* > /dev/null 2>&1 && sleep 2
+}
+
+
+function bootstrap() {
+
+ BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
+
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Restore daemon chain from bootstrap${NC}"
+ if [[ -z "$bootstrap_url" ]]; then
+
+ if [[ -e ~/$CONFIG_DIR/blocks ]] && [[ -e ~/$CONFIG_DIR/chainstate ]]; then
+ echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
+ rm -rf ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate ~/$CONFIG_DIR/determ_zelnodes
+
+ fi
+
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+
+ echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}"
+ echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}"
+ if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1
+ then
+ echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
+ rm -rf $BOOTSTRAP_ZIPFILE
+ fi
+
+ else
+ check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
+ fi
+
+ fi
+
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+ echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ fi
+
+ else
+
+
+ CHOICE=$(
+ whiptail --title "FLUXNODE INSTALLATION" --menu "Choose a method how to get bootstrap file" 10 47 2 \
+ "1)" "Download from source build in script" \
+ "2)" "Download from own source" 3>&2 2>&1 1>&3
+ )
+
+
+ case $CHOICE in
+ "1)")
+
+ DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
+ if [[ "$DB_HIGHT" == "" ]]; then
+ DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
+ fi
+
+ echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
+ echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
+ wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ #unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+
+
+ ;;
+ "2)")
+ BOOTSTRAP_ZIP="$(whiptail --title "Flux daemon bootstrap setup" --inputbox "Enter your URL (zip, tar.gz)" 8 72 3>&1 1>&2 2>&3)"
+ echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
+ BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
+ wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+ echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ fi
+ #echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ #unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ ;;
+ esac
+
+ fi
+
+ else
+
+ if [[ -e ~/$CONFIG_DIR/blocks ]] && [[ -e ~/$CONFIG_DIR/chainstate ]]; then
+ echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
+ rm -rf ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate ~/$CONFIG_DIR/determ_zelnodes
+ fi
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+
+ echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}"
+ echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}"
+ if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1
+ then
+ echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
+ rm -rf $BOOTSTRAP_ZIPFILE
+ fi
+
+ else
+ check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
+ fi
+
+ fi
+
+
+ if [[ "$bootstrap_url" == "" ]]; then
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+ echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ fi
+
+ else
+
+ DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
+ if [[ "$DB_HIGHT" == "" ]]; then
+ DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
+ fi
+
+ echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
+ echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
+ wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+
+ fi
+
+ else
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ else
+ BOOTSTRAP_ZIP="$bootstrap_url"
+ echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
+ BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
+ wget --tries 5 -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+ echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ fi
+
+ fi
+ fi
+ fi
+
+ if [[ -z "$bootstrap_zip_del" ]]; then
+ if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
+ rm -rf $BOOTSTRAP_ZIPFILE
+ fi
+ else
+
+ if [[ "$bootstrap_zip_del" == "1" ]]; then
+ rm -rf $BOOTSTRAP_ZIPFILE
+ fi
+
+ fi
+
+
+}
+
+
+function basic_security() {
+ echo -e "${ARROW} ${YELLOW}Configuring firewall and enabling fail2ban...${NC}"
+ sudo ufw allow 16124/tcp > /dev/null 2>&1
+ sudo ufw allow "$SSHPORT"/tcp > /dev/null 2>&1
+ sudo ufw allow "$PORT"/tcp > /dev/null 2>&1
+ sudo ufw logging on > /dev/null 2>&1
+ sudo ufw default deny incoming > /dev/null 2>&1
+
+ sudo ufw allow out from any to any port 123 > /dev/null 2>&1
+ sudo ufw allow out to any port 80 > /dev/null 2>&1
+ sudo ufw allow out to any port 443 > /dev/null 2>&1
+ sudo ufw allow out to any port 53 > /dev/null 2>&1
+ sudo ufw allow out to any port 16124 > /dev/null 2>&1
+ sudo ufw allow out to any port 16125 > /dev/null 2>&1
+ sudo ufw allow out to any port 26124 > /dev/null 2>&1
+ sudo ufw allow out to any port 26125 > /dev/null 2>&1
+ sudo ufw allow out to any port 16127 > /dev/null 2>&1
+ sudo ufw allow from any to any port 16127 > /dev/null 2>&1
+
+ sudo ufw default deny outgoing > /dev/null 2>&1
+ sudo ufw limit OpenSSH > /dev/null 2>&1
+ echo "y" | sudo ufw enable > /dev/null 2>&1
+ sudo ufw reload > /dev/null 2>&1
+ sudo systemctl enable fail2ban > /dev/null 2>&1
+ sudo systemctl start fail2ban > /dev/null 2>&1
+}
+
+
+function start_daemon() {
+
+ sudo systemctl enable zelcash.service > /dev/null 2>&1
+ sudo systemctl start zelcash > /dev/null 2>&1
+
+ NUM='250'
+ MSG1='Starting daemon & syncing with chain please be patient this will take about 3 min...'
+ MSG2=''
+ spinning_timer
+
+ if [[ "$($COIN_CLI getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
+ # if $COIN_DAEMON > /dev/null 2>&1; then
+
+ NUM='2'
+ MSG1='Getting info...'
+ MSG2="${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo && echo
+
+
+ daemon_version=$($COIN_CLI getinfo | jq -r '.version')
+ string_limit_check_mark "Flux daemon v$daemon_version installed................................." "Flux daemon ${GREEN}v$daemon_version${CYAN} installed................................."
+ #echo -e "Zelcash version: ${GREEN}v$zelcash_version${CYAN} installed................................."
+ bench_version=$($BENCH_CLI -testnet getinfo | jq -r '.version')
+ string_limit_check_mark "Flux benchmark v$bench_version installed................................." "Flux benchmark ${GREEN}v$bench_version${CYAN} installed................................."
+ #echo -e "${ARROW} ${CYAN}Zelbench version: ${GREEN}v$zelbench_version${CYAN} installed${NC}"
+ echo
+ pm2_install
+ #zelbench-cli stop > /dev/null 2>&1 && sleep 2
+ else
+ echo
+ echo -e "${WORNING} ${RED}Something is not right the daemon did not start or still loading...${NC}"
+
+ if [[ -f /home/$USER/$CONFIG_DIR/debug.log ]]; then
+ error_line=$(egrep -a --color 'Error:' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ if [[ "$error_line" != "" ]]; then
+ echo -e "${WORNING} ${CYAN}Last error from ~/$CONFIG_DIR/debug.log: ${NC}"
+ echo -e "${WORNING} ${CYAN}$error_line${NC}"
+ echo
+ exit
+ fi
+ fi
+
+
+ if whiptail --yesno "Something is not right the daemon did not start or still loading....\nWould you like continue the installation (make sure that flux daemon working) Y/N?" 8 90; then
+
+ echo -e "${ARROW} ${CYAN}Problem with daemon noticed but user want continue installation... ${NC}"
+ echo -n ""
+
+ else
+
+ echo -e "${WORNING} ${RED}Installation stopped by user...${NC}"
+ echo -n ""
+ exit
+
+ fi
+
+
+ fi
+}
+
+#TODO: RESEARCH, This defaults to mongodb 5.0 in install_pro, why not here?
+function install_process() {
+
+ echo -e "${ARROW} ${YELLOW}Configuring firewall...${NC}"
+ sudo ufw allow $ZELFRONTPORT/tcp > /dev/null 2>&1
+ sudo ufw allow $LOCPORT/tcp > /dev/null 2>&1
+ sudo ufw allow $ZELNODEPORT/tcp > /dev/null 2>&1
+ #sudo ufw allow $MDBPORT/tcp > /dev/null 2>&1
+
+ echo -e "${ARROW} ${YELLOW}Configuring service repositories...${NC}"
+
+ sudo rm /etc/apt/sources.list.d/mongodb*.list > /dev/null 2>&1
+ sudo rm /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+
+ curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-archive-keyring.gpg > /dev/null 2>&1
+
+ if [[ $(lsb_release -d) = *Debian* ]]; then
+
+
+ if [[ $(lsb_release -cs) = *stretch* || $(lsb_release -cs) = *buster* ]]; then
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/4.4 main" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
+ else
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
+ fi
+
+
+ elif [[ $(lsb_release -d) = *Ubuntu* ]]; then
+
+
+ if [[ $(lsb_release -cs) = *focal* || $(lsb_release -cs) = *bionic* || $(lsb_release -cs) = *xenial* ]]; then
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.4 multiverse" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
+ else
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" 2> /dev/null | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null 2>&1
+ fi
+
+ else
+
+ echo -e "${WORNING} ${RED}OS type $(lsb_release -si) - $(lsb_release -cs) not supported..${NC}"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+
+ fi
+
+
+ if ! sysbench --version > /dev/null 2>&1; then
+
+ echo
+ echo -e "${ARROW} ${YELLOW}Sysbench installing...${NC}"
+ curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh 2> /dev/null | sudo bash > /dev/null 2>&1
+ sudo apt -y install sysbench > /dev/null 2>&1
+
+ if sysbench --version > /dev/null 2>&1; then
+
+ string_limit_check_mark "Sysbench $(sysbench --version | awk '{print $2}') installed................................." "Sysbench ${GREEN}$(sysbench --version | awk '{print $2}')${CYAN} installed................................."
+
+ fi
+
+ fi
+
+ install_mongod
+ install_nodejs
+ install_flux
+ sleep 2
+}
+
+
+function install_flux() {
+
+ docker_check=$(docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
+ resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
+ mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
+
+if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then
+
+echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1
+echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1
+echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
+
+fi
+
+if [[ $docker_check != 0 ]]; then
+echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1
+echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
+
+sudo service docker restart > /dev/null 2>&1 && sleep 5
+
+docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" |
+while read line; do
+sudo docker stop $line > /dev/null 2>&1 && sleep 2
+sudo docker rm $line > /dev/null 2>&1 && sleep 2
+done
+fi
+
+if [[ $resource_check != 0 ]]; then
+echo -e "${ARROW} ${YELLOW}Detected locked resource${NC}" && sleep 1
+echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}" && sleep 1
+df | egrep 'flux' | awk '{ print $1}' |
+while read line; do
+sudo umount -l $line && sleep 1
+done
+fi
+
+ if [ -d "./$FLUX_DIR" ]; then
+ echo -e "${ARROW} ${YELLOW}Removing any instances of Flux${NC}"
+ sudo rm -rf $FLUX_DIR
+ fi
+
+
+ echo -e "${ARROW} ${YELLOW}Flux installing...${NC}"
+ git clone https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1
+ cd
+ echo -e "${ARROW} ${YELLOW}Creating Flux configuration file...${NC}"
+
+
+if [[ "$IMPORT_ZELID" == "0" ]]; then
+
+ while true
+ do
+ ZELID=$(whiptail --title "Flux Configuration" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)
+ if [ $(printf "%s" "$ZELID" | wc -c) -eq "34" ] || [ $(printf "%s" "$ZELID" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$ZELID") ]; then
+ echo -e "${ARROW} ${CYAN}Zel ID is valid${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ else
+ echo -e "${ARROW} ${CYAN}Zel ID is not valid try again...........[${X_MARK}${CYAN}]${NC}"
+ sleep 4
+ fi
+ done
+
+ fi
+
+
+
+ touch ~/$FLUX_DIR/config/userconfig.js
+ cat << EOF > ~/$FLUX_DIR/config/userconfig.js
+module.exports = {
+ initial: {
+ ipaddress: '${WANIP}',
+ zelid: '${ZELID}',
+ testnet: true
+ }
+ }
+EOF
+
+
+if [ -d ~/$FLUX_DIR ]
+then
+current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
+
+string_limit_check_mark "Flux v$current_ver installed................................." "Flux ${GREEN}v$current_ver${CYAN} installed................................."
+#echo -e "${ARROW} ${CYAN}Zelflux version: ${GREEN}v$current_ver${CYAN} installed${NC}"
+
+echo
+else
+string_limit_x_mark "Flux was not installed................................."
+#echo -e "${ARROW} ${CYAN}Zelflux was not installed${NC}"
+echo
+fi
+
+}
+
+
+function status_loop() {
+
+network_height_01=$(curl -sk -m 5 https://testnet.runonflux.io/api/status?q=getInfo | jq '.info.blocks')
+network_height_03=$(curl -sk -m 5 https://testnet.runonflux.io/api/status?q=getInfo | jq '.info.blocks')
+
+EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_03")
+
+
+if [[ "$EXPLORER_BLOCK_HIGHT" == $(${COIN_CLI} getinfo | jq '.blocks') ]]; then
+echo
+echo -e "${CLOCK}${GREEN} FLUX DAEMON SYNCING...${NC}"
+
+
+LOCAL_BLOCK_HIGHT=$(${COIN_CLI} getinfo 2> /dev/null | jq '.blocks')
+CONNECTIONS=$(${COIN_CLI} getinfo 2> /dev/null | jq '.connections')
+LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+
+NUM='2'
+MSG1="Syncing progress >> Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN}"
+MSG2="${CYAN} ................[${CHECK_MARK}${CYAN}]${NC}"
+spinning_timer
+echo && echo
+
+else
+
+ echo
+ echo -e "${CLOCK}${GREEN}FLUX DAEMON SYNCING...${NC}"
+
+ f=0
+ start_sync=`date +%s`
+
+
+ while true
+ do
+
+ network_height_01=$(curl -sk -m 5 https://testnet.runonflux.io/api/status?q=getInfo | jq '.info.blocks' 2> /dev/null)
+ network_height_03=$(curl -sk -m 5 https://testnet.runonflux.io/api/status?q=getInfo | jq '.info.blocks' 2> /dev/null)
+
+ EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_03")
+
+ LOCAL_BLOCK_HIGHT=$(${COIN_CLI} getinfo 2> /dev/null | jq '.blocks')
+ CONNECTIONS=$(${COIN_CLI} getinfo 2> /dev/null | jq '.connections')
+ LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+
+ if [[ "$LEFT" == "0" ]]; then
+ time_break='5'
+ else
+ time_break='20'
+ fi
+
+ #if [[ "$CONNECTIONS" == "0" ]]; then
+ # c=$((c+1))
+ # if [[ "$c" > 3 ]]; then
+ # c=0;
+ #LOCAL_BLOCK_HIGHT=""
+ # fi
+
+ #fi
+ #
+ if [[ $LOCAL_BLOCK_HIGHT == "" ]]; then
+
+ f=$((f+1))
+ LOCAL_BLOCK_HIGHT="N/A"
+ LEFT="N/A"
+ CONNECTIONS="N/A"
+ sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2
+ sudo systemctl start zelcash > /dev/null 2>&1
+
+ NUM='60'
+ MSG1="Syncing progress => Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN} Failed: ${RED}$f${NC}"
+ MSG2=''
+ spinning_timer
+
+ network_height_01=$(curl -sk -m 5 https://testnet.runonflux.io/api/status?q=getInfo | jq '.info.blocks' 2> /dev/null)
+ network_height_03=$(curl -sk -m 5 https://testnet.runonflux.io/api/status?q=getInfo | jq '.info.blocks' 2> /dev/null)
+
+ EXPLORER_BLOCK_HIGHT=$(max "$network_height_01" "$network_height_03")
+
+ LOCAL_BLOCK_HIGHT=$(${COIN_CLI} getinfo 2> /dev/null | jq '.blocks')
+ CONNECTIONS=$(${COIN_CLI} getinfo 2> /dev/null | jq '.connections')
+ LEFT=$((EXPLORER_BLOCK_HIGHT-LOCAL_BLOCK_HIGHT))
+
+ fi
+
+ NUM="$time_break"
+ MSG1="Syncing progress >> Local block height: ${GREEN}$LOCAL_BLOCK_HIGHT${CYAN} Explorer block height: ${RED}$EXPLORER_BLOCK_HIGHT${CYAN} Left: ${YELLOW}$LEFT${CYAN} blocks, Connections: ${YELLOW}$CONNECTIONS${CYAN} Failed: ${RED}$f${NC}"
+ MSG2=''
+ spinning_timer
+
+ if [[ "$EXPLORER_BLOCK_HIGHT" == "$LOCAL_BLOCK_HIGHT" ]]; then
+ echo -e "${GREEN} Duration: $((($(date +%s)-$start_sync)/60)) min. $((($(date +%s)-$start_sync) % 60)) sec. ${CYAN}.............[${CHECK_MARK}${CYAN}]${NC}"
+ break
+ fi
+ done
+
+ fi
+
+
+ #pm2 start ~/$FLUX_DIR/start.sh --name flux --time > /dev/null 2>&1
+
+
+ # if [[ -z "$mongo_bootstrap" ]]; then
+
+ # if whiptail --yesno "Would you like to restore Mongodb datatable from bootstrap?" 8 60; then
+ # mongodb_bootstrap
+ # else
+ # echo -e "${ARROW} ${YELLOW}Restore Mongodb datatable skipped...${NC}"
+ # fi
+ #
+ # else
+
+ # if [[ "$mongo_bootstrap" == "1" ]]; then
+ # mongodb_bootstrap
+ # else
+ # echo -e "${ARROW} ${YELLOW}Restore Mongodb datatable skipped...${NC}"
+ # fi
+
+ # fi
+
+
+ #if [[ -z "$watchdog" ]]; then
+ #if whiptail --yesno "Would you like to install watchdog for FluxNode?" 8 60; then
+ #install_watchdog
+ # else
+ # echo -e "${ARROW} ${YELLOW}Watchdog installation skipped...${NC}"
+ # fi
+ # else
+
+ # if [[ "$watchdog" == "1" ]]; then
+ # install_watchdog
+ # else
+ # echo -e "${ARROW} ${YELLOW}Watchdog installation skipped...${NC}"
+ # fi
+
+ # fi
+
+ check
+ display_banner "-testnet"
+}
+
+
+#end of functions
+ start_install
+ wipe_clean
+ ssh_port
+ ip_confirm
+ create_swap
+ install_packages
+ create_conf
+ install_daemon
+ zk_params
+ #if [[ "$BOOTSTRAP_SKIP" == "0" ]]; then
+ # bootstrap
+ # fi
+ create_service_scripts
+ create_service "install"
+
+ # if whiptail --yesno "Is the fluxnode being installed on a vps?" 8 60; then
+ # echo -e "${ARROW} ${YELLOW}Cron service for rotate ip skipped...${NC}"
+ # else
+ # if whiptail --yesno "Would you like to install cron service for rotate ip (required for dynamic ip)?" 8 60; then
+ selfhosting
+ # else
+ # echo -e "${ARROW} ${YELLOW}Cron service for rotate ip skipped...${NC}"
+ # fi
+ # fi
+
+ install_process
+ start_daemon
+ log_rotate "Flux benchmark" "bench_debug_log" "/home/$USER/$BENCH_DIR_LOG/debug.log" "monthly" "2"
+ log_rotate "Flux daemon" "daemon_debug_log" "/home/$USER/$CONFIG_DIR/debug.log" "daily" "7"
+ log_rotate "MongoDB" "mongod_debug_log" "/var/log/mongodb/*.log" "daily" "14"
+ log_rotate "Docker" "docker_debug_log" "/var/lib/docker/containers/*/*.log" "daily" "7"
+ basic_security
+ status_loop
diff --git a/log_viewer.sh b/log_viewer.sh
new file mode 100644
index 00000000..8c3e75a1
--- /dev/null
+++ b/log_viewer.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+set +o history
+
+export NEWT_COLORS='
+title=black,
+'
+
+TMUX=$(command -v tmux) || { echo "This script requires tmux. Please install it."; exit 1; }
+SESSION="FLUX-$$"
+LAYOUT="tiled"
+
+# Log files and their titles
+declare -A FILES
+FILES+=(
+ [Flux-Watchdog]="/dat/usr/lib/fluxwatchdog/watchdog_error.log"
+ [Flux-Daemon]="/dat/var/lib/fluxd/debug.log"
+ [Flux-Benchmark]="/dat/usr/lib/fluxbenchd/debug.log"
+ [FluxOS]="/dat/usr/lib/fluxos/debug.log"
+ [SAS]="/var/log/sas.log"
+ [MongoDB]="/dat/var/log/mongodb/mongod.log"
+ [Syncthing]="/dat/var/log/syncthing.log"
+)
+
+# Cleanup function to kill the tmux session and its panes
+function at_exit() {
+ $TMUX kill-session -t "$SESSION" >/dev/null 2>&1
+ set -o history
+}
+
+# Trap SIGINT (Ctrl+C) and SIGTERM to cleanup
+trap at_exit SIGINT SIGTERM EXIT
+
+# Verify if all files exist and prepare the whiptail menu options
+MENU_OPTIONS=()
+for title in "${!FILES[@]}"; do
+ LOG_FILE="${FILES[$title]}"
+ if [ -f "$LOG_FILE" ]; then
+ MENU_OPTIONS+=("$title" " " ON)
+ fi
+done
+
+# Exit if no valid log files are found
+if [ "${#MENU_OPTIONS[@]}" -eq 0 ]; then
+ echo -e "No valid log files found. Exiting."
+ echo -e ""
+ exit 1
+fi
+
+# Display whiptail menu
+SELECTED_FILES=$(whiptail --title "Select Log Files" --checklist \
+ "\nChoose which log files to monitor. Navigate using arrow keys, toggle selection with Spacebar, and confirm with Enter. To close the log monitor, press Ctrl+C.\n" 25 50 10 \
+ "${MENU_OPTIONS[@]}" 3>&1 1>&2 2>&3)
+
+# Handle user cancel or no selection
+if [ $? -ne 0 ] || [ -z "$SELECTED_FILES" ]; then
+ exit 1
+fi
+
+# Parse selected files into an array
+SELECTED_FILES=($(echo "$SELECTED_FILES" | tr -d '"'))
+
+# Start tmux session if it doesn't already exist
+if ! $TMUX has-session -t "$SESSION" 2>/dev/null; then
+ $TMUX new-session -d -s "$SESSION" -n Main "printf '\033]2;Main\033\\' ; bash"
+else
+ echo "Session $SESSION already exists. Attaching to it."
+ $TMUX attach -t "$SESSION"
+ exit 0
+fi
+
+# Enable mouse and adjust terminal overrides
+$TMUX set-option -t "$SESSION" -q mouse on
+$TMUX set-option -t "$SESSION" -ga terminal-overrides ',xterm*:smcup@:rmcup@'
+
+# Create panes for each selected file dynamically
+PANE_COUNT=0
+for title in "${SELECTED_FILES[@]}"; do
+ LOG_FILE="${FILES[$title]}"
+ echo "Opening pane for: $title ($LOG_FILE)"
+ if sudo jq empty "$LOG_FILE" > /dev/null 2>&1; then
+ $TMUX split-window -t "$SESSION" "printf '\033]2;%s\033\\' '${title}' ; sudo tail -F '${LOG_FILE}' | pino-pretty --colorize --translateTime 'dd-mm-yyyy HH:MM:ss'"
+ else
+ $TMUX split-window -t "$SESSION" "printf '\033]2;%s\033\\' '${title}' ; sudo tail -F '${LOG_FILE}'"
+ fi
+ PANE_COUNT=$((PANE_COUNT + 1))
+ $TMUX select-layout -t "$SESSION" "$LAYOUT"
+done
+
+# Remove the initial empty pane
+$TMUX kill-pane -t "${SESSION}.0"
+
+# Final tmux layout adjustments
+$TMUX select-layout -t "$SESSION" "$LAYOUT"
+
+# Customize tmux appearance
+$TMUX set-option -t "$SESSION" -g status-style bg=colour235,fg=yellow,dim
+$TMUX set-window-option -t "$SESSION" -g window-status-style fg=brightblue,bg=colour236,dim
+$TMUX set-window-option -t "$SESSION" -g window-status-current-style fg=brightred,bg=colour236,bright
+
+# Synchronize panes for uniform control
+$TMUX set-window-option -t "$SESSION" synchronize-panes on
+$TMUX set-option -t "$SESSION" pane-border-status top
+
+# Attach to the tmux session
+$TMUX attach -t "$SESSION" >/dev/null 2>&1
diff --git a/multinode.sh b/multinode.sh
new file mode 100755
index 00000000..6870e47b
--- /dev/null
+++ b/multinode.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+if [[ -f "/usr/lib/multitoolbox/flux_common.sh" ]]; then
+ source "/usr/lib/multitoolbox/flux_common.sh"
+else
+ source /dev/stdin <<< "$(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh")"
+fi
+
+function upnp_disable() {
+ if [[ ! -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ echo -e "${WORNING} ${CYAN}Missing FluxOS configuration file - install/re-install Flux Node...${NC}"
+ echo -e ""
+ exit
+ fi
+
+ if [[ -f $FLUX_BENCH_PATH/fluxbench.conf ]]; then
+ if [[ $(grep -e "fluxport" $FLUX_BENCH_PATH/fluxbench.conf) != "" ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Removing FluxOS UPnP configuration.....${NC}"
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD sed -i "/$(grep -e "fluxport" $FLUX_BENCH_PATH/fluxbench.conf)/d" $FLUX_BENCH_PATH/fluxbench.conf > /dev/null 2>&1
+ else
+ echo -e "${ARROW} ${CYAN}UPnP Mode is already disabled...${NC}"
+ echo -e ""
+ exit
+ fi
+ else
+ echo -e "${ARROW} ${CYAN}UPnP Mode is already disabled...${NC}"
+ echo -e ""
+ exit
+ fi
+ if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep 'apiport' | wc -l) == "1" ]]; then
+ RemoveLine "routerIP"
+ RemoveLine "apiport"
+ fi
+ echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark.....${NC}"
+ echo -e ""
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo systemctl restart zelcash > /dev/null 2>&1
+ pm2 restart flux > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxbenchd > /dev/null 2>&1
+ sudo systemctl restart fluxos > /dev/null 2>&1
+ fi
+ sleep 10
+}
+
+CHOICE=$(
+whiptail --title "UPnP Configuration" --menu "Make your choice" 16 30 9 \
+"1)" "Enable UPnP Mode" \
+"2)" "Disable UPnP Mode" 3>&2 2>&1 1>&3
+)
+case $CHOICE in
+ "1)")
+ upnp_enable
+ ;;
+ "2)")
+ upnp_disable
+ ;;
+esac
+
diff --git a/multitoolbox.sh b/multitoolbox.sh
old mode 100644
new mode 100755
index 4525a58f..d09fe1fa
--- a/multitoolbox.sh
+++ b/multitoolbox.sh
@@ -1,1550 +1,1131 @@
#!/bin/bash
-
-BOOTSTRAP_ZIP='https://fluxnodeservice.com/daemon_bootstrap.tar.gz'
-BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz'
-BOOTSTRAP_URL_MONGOD='https://fluxnodeservice.com/mongod_bootstrap.tar.gz'
-BOOTSTRAP_ZIPFILE_MONGOD='mongod_bootstrap.tar.gz'
-KDA_BOOTSTRAP_ZIPFILE='kda_bootstrap.tar.gz'
-KDA_BOOTSTRAP_ZIP='https://fluxnodeservice.com/kda_bootstrap.tar.gz'
-
-
-if [[ -d /home/$USER/.zelcash ]]; then
- CONFIG_DIR='.zelcash'
- CONFIG_FILE='zelcash.conf'
-
-else
- CONFIG_DIR='.flux'
- CONFIG_FILE='flux.conf'
-fi
-
-FLUX_DIR='zelflux'
-FLUX_APPS_DIR='ZelApps'
-COIN_NAME='zelcash'
-
-#color codes
-RED='\033[1;31m'
-YELLOW='\033[1;33m'
-BLUE="\\033[38;5;27m"
-SEA="\\033[38;5;49m"
-GREEN='\033[1;32m'
-CYAN='\033[1;36m'
-NC='\033[0m'
-
-#emoji codes
-CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}"
-X_MARK="${RED}\xE2\x9C\x96${NC}"
-PIN="${RED}\xF0\x9F\x93\x8C${NC}"
-CLOCK="${GREEN}\xE2\x8C\x9B${NC}"
-ARROW="${SEA}\xE2\x96\xB6${NC}"
-BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
-HOT="${ORANGE}\xF0\x9F\x94\xA5${NC}"
-WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
-dversion="v5.0"
-
-PM2_INSTALL="0"
-zelflux_setting_import="0"
-
-#dialog color
-export NEWT_COLORS='
-title=black,
-'
-
-function spinning_timer() {
- animation=( ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ )
- end=$((SECONDS+NUM))
- while [ $SECONDS -lt $end ];
- do
- for i in "${animation[@]}";
- do
- echo -e ""
- echo -ne "${RED}\r\033[1A\033[0K$i ${CYAN}${MSG1}${NC}"
- sleep 0.1
-
- done
- done
- echo -ne "${MSG2}"
-}
-
-function string_limit_check_mark_port() {
-if [[ -z "$2" ]]; then
-string="$1"
-string=${string::65}
-else
-string=$1
-string_color=$2
-string_leght=${#string}
-string_leght_color=${#string_color}
-string_diff=$((string_leght_color-string_leght))
-string=${string_color::65+string_diff}
-fi
-echo -e "${PIN}${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
-}
-
-function string_limit_check_mark() {
-if [[ -z "$2" ]]; then
-string="$1"
-string=${string::50}
-else
-string=$1
-string_color=$2
-string_leght=${#string}
-string_leght_color=${#string_color}
-string_diff=$((string_leght_color-string_leght))
-string=${string_color::50+string_diff}
-fi
-echo -e "${ARROW} ${CYAN}$string[${CHECK_MARK}${CYAN}]${NC}"
-}
-
-function string_limit_x_mark() {
-if [[ -z "$2" ]]; then
-string="$1"
-string=${string::50}
-else
-string=$1
-string_color=$2
-string_leght=${#string}
-string_leght_color=${#string_color}
-string_diff=$((string_leght_color-string_leght))
-string=${string_color::50+string_diff}
-fi
-echo -e "${ARROW} ${CYAN}$string[${X_MARK}${CYAN}]${NC}"
-}
-
-function tar_file_unpack()
-{
- echo -e "${ARROW} ${YELLOW}Unpacking bootstrap archive file...${NC}"
- pv $1 | tar -zx -C $2
-}
-
-function tar_file_pack()
-{
- echo -e "${ARROW} ${YELLOW}Creating bootstrap archive file...${NC}"
- tar -czf - $1 | (pv -p --timer --rate --bytes > $2) 2>&1
-}
-
-function check_tar()
-{
- echo -e "${ARROW} ${YELLOW}Checking bootstrap file integration...${NC}"
-
- if gzip -t "$1" &>/dev/null; then
-
- echo -e "${ARROW} ${CYAN}Bootstrap file is valid.................[${CHECK_MARK}${CYAN}]${NC}"
-
- else
-
- echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
- rm -rf $1
-
- fi
-}
-
-function pm2_install(){
-
- tmux kill-server > /dev/null 2>&1 && sleep 1
- echo -e "${ARROW} ${CYAN}PM2 installing...${NC}"
- npm install pm2@latest -g > /dev/null 2>&1
-
- if pm2 -v > /dev/null 2>&1
- then
- rm restart_zelflux.sh > /dev/null 2>&1
- echo -e "${ARROW} ${CYAN}Configuring PM2...${NC}"
- pm2 startup systemd -u $USER > /dev/null 2>&1
- sudo env PATH=$PATH:/home/$USER/.nvm/versions/node/$(node -v)/bin pm2 startup systemd -u $USER --hp /home/$USER > /dev/null 2>&1
- pm2 start ~/$FLUX_DIR/start.sh --name flux > /dev/null 2>&1
- pm2 save > /dev/null 2>&1
- pm2 install pm2-logrotate > /dev/null 2>&1
- pm2 set pm2-logrotate:max_size 6M > /dev/null 2>&1
- pm2 set pm2-logrotate:retain 6 > /dev/null 2>&1
- pm2 set pm2-logrotate:compress true > /dev/null 2>&1
- pm2 set pm2-logrotate:workerInterval 3600 > /dev/null 2>&1
- pm2 set pm2-logrotate:rotateInterval '0 12 * * 0' > /dev/null 2>&1
- source ~/.bashrc
- #echo -e "${ARROW} ${CYAN}PM2 version: ${GREEN}v$(pm2 -v)${CYAN} installed${NC}"
- string_limit_check_mark "PM2 v$(pm2 -v) installed....................................................." "PM2 ${GREEN}v$(pm2 -v)${CYAN} installed....................................................."
- PM2_INSTALL="1"
-
- else
-
- string_limit_x_mark "PM2 was not installed....................................................."
- echo
- fi
-
-}
-
-
-function config_file() {
-
-if [[ -f /home/$USER/install_conf.json ]]; then
-import_settings=$(cat /home/$USER/install_conf.json | jq -r '.import_settings')
-ssh_port=$(cat /home/$USER/install_conf.json | jq -r '.ssh_port')
-firewall_disable=$(cat /home/$USER/install_conf.json | jq -r '.firewall_disable')
-bootstrap_url=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_url')
-bootstrap_zip_del=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_zip_del')
-swapon=$(cat /home/$USER/install_conf.json | jq -r '.swapon')
-mongo_bootstrap=$(cat /home/$USER/install_conf.json | jq -r '.mongo_bootstrap')
-watchdog=$(cat /home/$USER/install_conf.json | jq -r '.watchdog')
-use_old_chain=$(cat /home/$USER/install_conf.json | jq -r '.use_old_chain')
-prvkey=$(cat /home/$USER/install_conf.json | jq -r '.prvkey')
-outpoint=$(cat /home/$USER/install_conf.json | jq -r '.outpoint')
-index=$(cat /home/$USER/install_conf.json | jq -r '.index')
-zel_id=$(cat /home/$USER/install_conf.json | jq -r '.zelid')
-kda_address=$(cat /home/$USER/install_conf.json | jq -r '.kda_address')
-
-echo -e "${ARROW} ${YELLOW}Install config summary:"
-
-if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then
-echo -e "${PIN}${CYAN}Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-
-if [[ "$import_settings" == "1" ]]; then
-echo -e "${PIN}${CYAN}Import settings from exist config files..........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-fi
-
-if [[ "$ssh_port" != "" ]]; then
-string_limit_check_mark_port "SSH port: $ssh_port ...................................................................." "SSH port: ${GREEN}$ssh_port ${CYAN}...................................................................."
-sleep 1
-fi
-
-if [[ "$firewall_disable" == "1" ]]; then
-echo -e "${PIN}${CYAN}Firewall disabled diuring installation...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-echo -e "${PIN}${CYAN}Firewall enabled diuring installation............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$use_old_chain" == "1" ]]; then
-echo -e "${PIN}${CYAN}Diuring re-installation old chain will be use....................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-
-else
-
-if [[ "$bootstrap_url" == "" ]]; then
-echo -e "${PIN}${CYAN}Use Flux Bootstrap from source build in scripts..................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-echo -e "${PIN}${CYAN}Use Flux Bootstrap from own source...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$bootstrap_zip_del" == "1" ]]; then
-echo -e "${PIN}${CYAN}Remove Flux Bootstrap archive file...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-else
-echo -e "${PIN}${CYAN}Leave Flux Bootstrap archive file................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-fi
-
-if [[ "$swapon" == "1" ]]; then
-echo -e "${PIN}${CYAN}Create a file that will be used for swap.........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$mongo_bootstrap" == "1" ]]; then
-echo -e "${PIN}${CYAN}Use Bootstrap for MongoDB........................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-
-if [[ "$watchdog" == "1" ]]; then
-echo -e "${PIN}${CYAN}Install watchdog.................................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
-fi
-fi
-}
-
-function ip_confirm() {
-
- WANIP=$(curl --silent -m 15 https://api4.my-ip.io/ip | tr -dc '[:alnum:].')
-
- if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl --silent -m 15 https://checkip.amazonaws.com | tr -dc '[:alnum:].')
- fi
-
- if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl --silent -m 15 https://api.ipify.org | tr -dc '[:alnum:].')
- fi
-
-
- if [[ "$WANIP" == "" ]]; then
- echo -e "${ARROW} ${CYAN}IP address could not be found, installation stopped .........[${X_MARK}${CYAN}]${NC}"
- echo
- exit
- fi
-
- string_limit_check_mark "IP: $WANIP ..........................................." "IP: ${GREEN}$WANIP${CYAN} ..........................................."
-}
-
-function install_flux() {
-
-echo -e "${GREEN}Module: Re-install Flux${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
- if pm2 -v > /dev/null 2>&1; then
- pm2 del zelflux > /dev/null 2>&1
- pm2 del flux > /dev/null 2>&1
- pm2 save > /dev/null 2>&1
- fi
-
-docker_check=$(docker container ls -a | grep 'zelcash' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
-resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
-mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
-
-if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then
-echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1
-echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1
-echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
-fi
-
-if [[ $docker_check != 0 ]]; then
-echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1
-echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
-sudo aa-remove-unknown && sudo service docker restart > /dev/null 2>&1 && sleep 2
-sleep 5
-#docker ps | grep -Eo "^[0-9a-z]{8,}\b" |
-docker container ls -a | grep 'zelcash' | grep -Eo "^[0-9a-z]{8,}\b" |
-while read line; do
-sudo docker stop $line > /dev/null 2>&1 && sleep 2
-sudo docker rm $line > /dev/null 2>&1 && sleep 2
-done
-fi
-
-if [[ $resource_check != 0 ]]; then
-echo -e "${ARROW} ${YELLOW}Detected locked resource...${NC}" && sleep 1
-echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}" && sleep 1
-df | egrep 'flux' | awk '{ print $1}' |
-while read line; do
-sudo umount -l $line && sleep 1
-done
-fi
-
-if [ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]; then
-
- echo -e "${ARROW} ${CYAN}Importing setting...${NC}"
- zel_id=$(grep -w zelid /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
- WANIP=$(grep -w ipaddress /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*ipaddress: .//' | sed -e 's/.\{2\}$//')
-
- echo -e "${PIN}${CYAN}Zel ID = ${GREEN}$zel_id${NC}" && sleep 1
-
- KDA_A=$(grep -w kadena /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
-
- if [[ "$KDA_A" != "" ]]; then
-
- echo -e "${PIN}${CYAN}Kadena address = ${GREEN}$KDA_A${NC}" && sleep 1
-
- fi
-
-
- echo -e "${PIN}${CYAN}IP = ${GREEN}$WANIP${NC}" && sleep 1
- echo
- echo -e "${ARROW} ${CYAN}Removing any instances of Flux....${NC}"
- sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 2
- #sudo rm -rf zelflux > /dev/null 2>&1 && sleep 2
- zelflux_setting_import="1"
-
-fi
-
-if [ -d /home/$USER/$FLUX_DIR ]; then
-
- echo -e "${ARROW} ${CYAN}Removing any instances of Flux....${NC}"
- #sudo rm -rf zelflux > /dev/null 2>&1 && sleep 2
- sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 2
-
-fi
-
-echo -e "${ARROW} ${CYAN}Flux downloading...${NC}"
-git clone https://github.com/zelcash/zelflux.git > /dev/null 2>&1 && sleep 2
-
-if [ -d /home/$USER/$FLUX_DIR ]
-then
-
-if [[ -f /home/$USER/$FLUX_DIR/package.json ]]; then
- current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
-else
- string_limit_x_mark "Flux was not downloaded, run script again..........................................."
- echo
- exit
-fi
-
-string_limit_check_mark "Flux v$current_ver downloaded..........................................." "Flux ${GREEN}v$current_ver${CYAN} downloaded..........................................."
-else
-string_limit_x_mark "Flux was not downloaded, run script again..........................................."
-echo
-exit
-fi
-
-
-if [[ "$zelflux_setting_import" == "0" ]]; then
-
-ip_confirm
-
-while true
- do
- zel_id="$(whiptail --title "MULTITOOLBOX" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)"
- if [ $(printf "%s" "$zel_id" | wc -c) -eq "34" ] || [ $(printf "%s" "$zel_id" | wc -c) -eq "33" ]; then
- string_limit_check_mark "Zel ID is valid..........................................."
- break
- else
- string_limit_x_mark "Zel ID is not valid try again..........................................."
- sleep 2
- fi
-
- done
-
-
- touch ~/$FLUX_DIR/config/userconfig.js
- cat << EOF > ~/$FLUX_DIR/config/userconfig.js
-module.exports = {
- initial: {
- ipaddress: '${WANIP}',
- zelid: '${zel_id}',
- testnet: false
- }
- }
-EOF
-
-else
-
-if [[ "$KDA_A" != "" ]]; then
-
- touch ~/$FLUX_DIR/config/userconfig.js
- cat << EOF > ~/$FLUX_DIR/config/userconfig.js
-module.exports = {
- initial: {
- ipaddress: '${WANIP}',
- zelid: '${zel_id}',
- kadena: '${KDA_A}',
- testnet: false
- }
- }
-EOF
-
-else
-
- touch ~/$FLUX_DIR/config/userconfig.js
- cat << EOF > ~/$FLUX_DIR/config/userconfig.js
-module.exports = {
- initial: {
- ipaddress: '${WANIP}',
- zelid: '${zel_id}',
- testnet: false
- }
- }
-EOF
-
-fi
-
-fi
-
-if [[ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]]; then
-string_limit_check_mark "Flux configuration successfull..........................................."
-else
-string_limit_x_mark "Flux installation failed, missing config file..........................................."
-echo
-exit
-fi
-
- if pm2 -v > /dev/null 2>&1; then
-
- rm restart_zelflux.sh > /dev/null 2>&1
- pm2 del flux > /dev/null 2>&1
- pm2 del zelflux > /dev/null 2>&1
- pm2 save > /dev/null 2>&1
- echo -e "${ARROW} ${CYAN}Starting Flux....${NC}"
- echo -e "${ARROW} ${CYAN}Flux loading will take 2-3min....${NC}"
- echo
- pm2 start /home/$USER/$FLUX_DIR/start.sh --restart-delay=60000 --max-restarts=40 --name flux --time > /dev/null 2>&1
- pm2 save > /dev/null 2>&1
- pm2 list
-
- else
-
- pm2_install()
- if [[ "$PM2_INSTALL" == "1" ]]; then
- echo -e "${ARROW} ${CYAN}Starting Flux....${NC}"
- echo -e "${ARROW} ${CYAN}Flux loading will take 2-3min....${NC}"
- echo
- pm2 list
- fi
- fi
-
-}
-
-function create_config() {
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-echo -e "${GREEN}Module: Create FluxNode installation config file${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-
-if jq --version > /dev/null 2>&1; then
-sleep 0.2
-else
-echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}"
-sudo apt install jq -y > /dev/null 2>&1
-
- if jq --version > /dev/null 2>&1
- then
- #echo -e "${ARROW} ${CYAN}Nodejs version: ${GREEN}$(node -v)${CYAN} installed${NC}"
- string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................."
- echo
- else
- #echo -e "${ARROW} ${CYAN}Nodejs was not installed${NC}"
- string_limit_x_mark "JQ was not installed................................."
- echo
- exit
- fi
-fi
-
-skip_zelcash_config='0'
-skip_bootstrap='0'
-
-if [[ -d /home/$USER/$CONFIG_DIR ]]; then
-
- if whiptail --yesno "Would you like import old settings from daemon and Flux?" 8 65; then
- import_settings='1'
- skip_zelcash_config='1'
- sleep 1
- else
- import_settings='0'
- sleep 1
- fi
-
- if whiptail --yesno "Would you like use exist Flux chain?" 8 65; then
- use_old_chain='1'
- skip_bootstrap='1'
- sleep 1
- else
- use_old_chain='0'
- sleep 1
- fi
-
-
-fi
-
-if [[ "$skip_zelcash_config" == "1" ]]; then
-prvkey=""
-outpoint=""
-index=""
-zelid=""
-kda_address=""
-else
-
-prvkey=$(whiptail --inputbox "Enter your FluxNode Private Key from Zelcore" 8 65 3>&1 1>&2 2>&3)
-sleep 1
-outpoint=$(whiptail --inputbox "Enter your FluxNode Output TX ID from Zelcore" 8 72 3>&1 1>&2 2>&3)
-sleep 1
-index=$(whiptail --inputbox "Enter your FluxNode Output Index from Zelcore" 8 65 3>&1 1>&2 2>&3)
-sleep 1
-zel_id=$(whiptail --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)
-sleep 1
-KDA_A=$(whiptail --inputbox "Please enter your Kadena address from Zelcore" 8 85 3>&1 1>&2 2>&3)
-sleep 1
-KDA_C=$(whiptail --inputbox "Please enter your kadena chainid (0-19)" 8 85 3>&1 1>&2 2>&3)
-
- if [[ "$KDA_A" == "" ]]; then
- kda_address=""
- else
- kda_address="kadena:$KDA_A?chainid=$KDA_C"
- fi
-
-fi
-
-ssh_port=$(whiptail --inputbox "Enter port you are using for SSH (default 22)" 8 65 3>&1 1>&2 2>&3)
-sleep 1
-
-
-pettern='^[0-9]+$'
-if [[ $ssh_port =~ $pettern ]] ; then
-sleep 1
-else
-echo -e "${ARROW} ${CYAN}SSH port must be integer.................................[${X_MARK}${CYAN}]${NC}"
-echo
-exit
-fi
-
-
-if whiptail --yesno "Would you like disable firewall diuring installation?" 8 65; then
-firewall_disable='1'
-sleep 1
-else
-firewall_disable='0'
-sleep 1
-fi
-
-
-if [[ "$skip_bootstrap" == "0" ]]; then
-
-if whiptail --yesno "Would you like use Flux bootstrap from script source?" 8 65; then
-bootstrap_url="$BOOTSTRAP_ZIP"
-sleep 1
-else
-bootstrap_url=$(whiptail --inputbox "Enter your Flux bootstrap URL" 8 65 3>&1 1>&2 2>&3)
-sleep 1
-fi
-
-if whiptail --yesno "Would you like keep bootstrap archive file localy?" 8 65; then
-bootstrap_zip_del='0'
-sleep 1
-else
-bootstrap_zip_del='1'
-sleep 1
-fi
-fi
-
-if whiptail --yesno "Would you like create swapfile?" 8 65; then
-swapon='1'
-sleep 1
-else
-swapon='0'
-sleep 1
-fi
-
-
-if whiptail --yesno "Would you like use mongod bootstrap file?" 8 65; then
-mongo_bootstrap='1'
-sleep 1
-else
-mongo_bootstrap='0'
-sleep 1
-fi
-
-
-if whiptail --yesno "Would you like install FluxNode watchdog?" 8 65; then
-watchdog='1'
-sleep 1
-else
-watchdog='0'
-sleep 1
-fi
-
-rm /home/$USER/install_conf.json > /dev/null 2>&1
-sudo touch /home/$USER/install_conf.json
-sudo chown $USER:$USER /home/$USER/install_conf.json
- cat << EOF > /home/$USER/install_conf.json
-{
- "import_settings": "${import_settings}",
- "prvkey": "${prvkey}",
- "outpoint": "${outpoint}",
- "index": "${index}",
- "zelid": "${zel_id}",
- "kda_address": "${kda_address}",
- "ssh_port": "${ssh_port}",
- "firewall_disable": "${firewall_disable}",
- "bootstrap_url": "${bootstrap_url}",
- "bootstrap_zip_del": "${bootstrap_zip_del}",
- "swapon": "${swapon}",
- "mongo_bootstrap": "${mongo_bootstrap}",
- "use_old_chain": "${use_old_chain}",
- "watchdog": "${watchdog}"
-}
-EOF
-config_file
-echo
-
-
-
-}
-
-
-function install_watchdog() {
-
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-echo -e "${GREEN}Module: Install watchdog for FluxNode${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if ! pm2 -v > /dev/null 2>&1
-then
-pm2_install
- if [[ "$PM2_INSTALL" == "0" ]]; then
- exit
- fi
-echo -e ""
-fi
-
-echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
-pm2 del watchdog > /dev/null 2>&1
-pm2 save > /dev/null 2>&1
-sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
-
-echo -e "${ARROW} ${CYAN}Downloading...${NC}"
-cd && git clone https://github.com/XK4MiLX/watchdog.git > /dev/null 2>&1
-echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}"
-wget https://raw.githubusercontent.com/XK4MiLX/zelnode/master/post-merge > /dev/null 2>&1
-mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
-sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
-echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}"
-cd watchdog && npm install > /dev/null 2>&1
-echo -e "${ARROW} ${CYAN}Starting watchdog...${NC}"
-pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 10 > /dev/null 2>&1
-pm2 save > /dev/null 2>&1
-if [[ -f /home/$USER/watchdog/watchdog.js ]]
-then
-current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
-#echo -e "${ARROW} ${CYAN}Watchdog ${GREEN}v$current_ver${CYAN} installed successful.${NC}"
-string_limit_check_mark "Watchdog v$current_ver installed..........................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed..........................................."
-else
-#echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}"
-string_limit_x_mark "Watchdog was not installed..........................................."
-fi
-echo
-}
-
-
-function kda_bootstrap() {
-
- echo -e "${GREEN}Module: Restore Kadena node blockchain from bootstrap${NC}"
- echo -e "${YELLOW}================================================================${NC}"
-
- if [[ "$USER" == "root" ]]; then
-
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
- fi
-
- echo -e "${NC}"
- sudo chown -R $USER:$USER /home/$USER/$FLUX_DIR
- echo -e "${ARROW} ${CYAN}Stopping Kadena Node...${NC}"
-
- docker stop zelKadenaChainWebNode > /dev/null 2>&1 && sleep 10
-
- if [[ -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db ]]; then
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- sudo rm -rf /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db
- fi
-
- mkdir -p /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0
-
-
- if [ -f "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" ]; then
-
- echo -e "${ARROW} ${CYAN}Local bootstrap file detected...${NC}"
- if whiptail --yesno "Do u want check vailidation of archive file before unpack?" 8 60 3>&1 1>&2 2>&3; then
- check_tar "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE"
- else
- echo -e "${ARROW} ${CYAN}Vailidation of archive file skipped..${NC}"
- fi
-
- fi
-
-
- if [ -f "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" ]; then
-
- tar_file_unpack "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" "/home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0"
- sleep 2
- #unzip -o $KDA_BOOTSTRAP_ZIPFILE -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode > /dev/null 2>&1
-
- else
-
- echo -e "${ARROW} ${CYAN}Bootstrap file downloading...${NC}" && sleep 2
-
- CHOICE=$(
- whiptail --title "Bootstrap installation" --menu "Choose a method how to get bootstrap file" 10 47 2 \
- "1)" "Download from source build in script" \
- "2)" "Download from own source" 3>&2 2>&1 1>&3
- )
-
-
- case $CHOICE in
- "1)")
- DB_HIGHT=$(curl -s -m 15 https://fluxnodeservice.com/kda_bootstrap.json | jq -r '.block_height')
- if [[ "$DB_HIGHT" == "" ]]; then
- DB_HIGHT=$(curl -s -m 15 https://fluxnodeservice.com/kda_bootstrap.json | jq -r '.block_height')
- fi
- echo -e "${ARROW} ${CYAN}KDA Bootstrap height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$KDA_BOOTSTRAP_ZIP ${NC}"
- wget -O $KDA_BOOTSTRAP_ZIPFILE $KDA_BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" "/home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0"
- sleep 2
-
- ;;
- "2)")
- KDA_BOOTSTRAP_ZIP="$(whiptail --title "Kadena node bootstrap source (*.tar.gz, *.zip file supported)" --inputbox "Enter your URL" 8 72 3>&1 1>&2 2>&3)"
- KDA_BOOTSTRAP_ZIPFILE="${KDA_BOOTSTRAP_ZIP##*/}"
- echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$KDA_BOOTSTRAP_ZIP ${NC}"
- wget -O $KDA_BOOTSTRAP_ZIPFILE $KDA_BOOTSTRAP_ZIP -q --show-progress
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $KDA_BOOTSTRAP_ZIPFILE -d /home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0 > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$KDA_BOOTSTRAP_ZIPFILE" "/home/$USER/$FLUX_DIR/$FLUX_APPS_DIR/zelKadenaChainWebNode/chainweb-db/0"
-
- fi
- sleep 2
- ;;
- esac
-
- fi
-
- if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
- rm -rf $KDA_BOOTSTRAP_ZIPFILE
- fi
-
- docker start zelKadenaChainWebNode > /dev/null 2>&1
- NUM='15'
- MSG1='Starting Kadena Node...'
- MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo -e ""
- echo -e "${ARROW} ${CYAN}Kadena Node initial process can take about ~15min. ${NC}"
- echo -e ""
-
-}
-
-
-function flux_daemon_bootstrap() {
-
- echo -e "${GREEN}Module: Restore Flux blockchain from bootstrap${NC}"
- echo -e "${YELLOW}================================================================${NC}"
-
- if [[ "$USER" == "root" ]]; then
-
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
- fi
-
- echo -e "${NC}"
- echo -e "${ARROW} ${CYAN}Stopping Flux daemon service${NC}"
- sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
- sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
-
- if [[ -e ~/$CONFIG_DIR/blocks ]] && [[ -e ~/$CONFIG_DIR/chainstate ]]; then
- echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
- rm -rf ~/$CONFIG_DIR/blocks ~/$CONFIG_DIR/chainstate ~/$CONFIG_DIR/determ_zelnodes
- fi
-
- BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
- echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}"
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
-
- echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}"
-
- if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1
- then
- echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}"
- else
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- printf '\e[A\e[K'
- echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
-
- else
- check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
- fi
-
- fi
-
-
- if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
-
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- fi
-
- else
-
- CHOICE=$(
- whiptail --title "FLUXNODE INSTALLATION" --menu "Choose a method how to get bootstrap file" 10 47 2 \
- "1)" "Download from source build in script" \
- "2)" "Download from own source" 3>&2 2>&1 1>&3
- )
-
-
- case $CHOICE in
- "1)")
-
- DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
- echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
- echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
-
-
-
- ;;
- "2)")
- BOOTSTRAP_ZIP="$(whiptail --title "Flux daemon bootstrap setup" --inputbox "Enter your URL (zip, tar.gz)" 8 72 3>&1 1>&2 2>&3)"
- echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
- BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
- wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
-
- if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
- echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
- unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
- else
- tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
- sleep 2
- fi
- ;;
- esac
-
- fi
-
-
- if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
- rm -rf $BOOTSTRAP_ZIPFILE
- fi
-
- sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2
- NUM='35'
- MSG1='Starting Flux daemon service...'
- MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
- spinning_timer
- echo -e "" && echo -e ""
-}
-
-function mongodb_bootstrap(){
-
-echo -e "${GREEN}Module: Restore Flux MongoDB datatable from bootstrap (explorer only)${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if [[ "$USER" == "root" ]]; then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-sudo rm /home/$USER/fluxdb_dump.tar.gz > /dev/null 2>&1
-sudo rm /home/$USER/$BOOTSTRAP_ZIPFILE_MONGOD > /dev/null 2>&1
-
-if ! pm2 -v > /dev/null 2>&1; then
-
- pm2_install
-
- if [[ "$PM2_INSTALL" == "0" ]]; then
- exit
- fi
-
-fi
-
-WANIP=$(wget http://ipecho.net/plain -O - -q)
-
-DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
-if [[ "$DB_HIGHT" == "" ]]; then
- DB_HIGHT=$(curl -s -m 10 https://fluxnodeservice.com/mongodb_bootstrap.json | jq -r '.block_height')
-fi
-
-BLOCKHIGHT=$(curl -s -m 5 http://"$WANIP":16127/explorer/scannedheight | jq '.data.generalScannedHeight')
-FORCE_BOOTSTRAP=0
-
-if [[ "$DB_HIGHT" == "" ]]; then
- echo -e "${ARROW} ${CYAN}MongoDB bootstrap server offline...${NC}"
- string_limit_x_mark "Operation aborted....................."
- exit
-fi
-
-
-if [[ "$BLOCKHIGHT" == "" || "$BLOCKHIGHT" == "null" ]]; then
-
- if whiptail --yesno "Local Explorer not respondin...Would you like force bootstrap installation?" 8 60; then
- FORCE_BOOTSTRAP=1
- else
- string_limit_x_mark "Local Explorer not responding........."
- string_limit_x_mark "Operation aborted....................."
- echo -e ""
- exit
- fi
-
-fi
-
- if [[ "$FORCE_BOOTSTRAP" != "1" ]]; then
-
- if [[ "$BLOCKHIGHT" == "null" ]]; then
-
- message=$(curl -s -m 5 http://"$WANIP":16127/explorer/scannedheight | jq -r .data.message)
-
- if whiptail --yesno "Flux explorer error noticed...Would you like force bootstrap installation?" 8 60; then
- FORCE_BOOTSTRAP=1
- else
- echo -e "${ARROW} ${CYAN}Flux explorer error: ${RED}$message${NC}"
- string_limit_x_mark "Operation aborted....................."
- echo -e ""
- exit
- fi
- fi
- fi
-
-
-if [[ "$BLOCKHIGHT" != "" && "$BLOCKHIGHT" != "null" ]]; then
-
- if [[ "$BLOCKHIGHT" -gt "$DB_HIGHT" ]]; then
-
- if whiptail --yesno "Datatable is out of date....Would you like force bootstrap installation?" 8 60; then
- FORCE_BOOTSTRAP=1
- else
- echo -e "${ARROW} ${CYAN}Current Node block hight ${RED}$BLOCKHIGHT${CYAN} > Bootstrap block hight ${RED}$DB_HIGHT${CYAN}. Datatable is out of date.${NC}"
- string_limit_x_mark "Operation aborted....................."
- echo -e ""
- exit
- fi
-
- fi
-fi
-
-
-echo -e "${ARROW} ${CYAN}IP: ${RED}$WANIP${NC}"
-
-if [[ "$FORCE_BOOTSTRAP" != "1" ]]; then
- echo -e "${ARROW} ${CYAN}Node block hight: ${GREEN}$BLOCKHIGHT${NC}"
-fi
-
-echo -e "${ARROW} ${CYAN}Bootstrap block hight: ${GREEN}$DB_HIGHT${NC}"
-echo -e ""
-
-
-echo -e "${ARROW} ${CYAN}Downloading File: ${GREEN}$BOOTSTRAP_URL_MONGOD${NC}"
-wget $BOOTSTRAP_URL_MONGOD -q --show-progress
-echo -e "${ARROW} ${CYAN}Unpacking...${NC}"
-tar xvf $BOOTSTRAP_ZIPFILE_MONGOD -C /home/$USER > /dev/null 2>&1 && sleep 1
-echo -e "${ARROW} ${CYAN}Stoping Flux...${NC}"
-pm2 stop flux > /dev/null 2>&1
-echo -e "${ARROW} ${CYAN}Importing mongodb datatable...${NC}"
-mongorestore --port 27017 --db zelcashdata /home/$USER/dump/zelcashdata --drop > /dev/null 2>&1
-echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
-sudo rm -rf /home/$USER/dump > /dev/null 2>&1 && sleep 1
-sudo rm -rf $BOOTSTRAP_ZIPFILE_MONGOD > /dev/null 2>&1 && sleep 1
-pm2 start flux > /dev/null 2>&1
-pm2 save > /dev/null 2>&1
-
-NUM='120'
-MSG1='Flux starting...'
-MSG2="${CYAN}.....................[${CHECK_MARK}${CYAN}]${NC}"
-spinning_timer
-echo
-
-#BLOCKHIGHT_AFTER_BOOTSTRAP=$(curl -s -m 3 http://"$WANIP":16127/explorer/scannedheight | jq '.data.generalScannedHeight')
-BLOCKHIGHT_AFTER_BOOTSTRAP=$(mongoexport -d zelcashdata -c scannedheight --jsonArray --pretty --quiet | jq -r .[].generalScannedHeight)
- if [[ "$BLOCKHIGHT_AFTER_BOOTSTRAP" != "" && "$BLOCKHIGHT_AFTER_BOOTSTRAP" != "null" ]]; then
-
- echo -e "${ARROW} ${CYAN}Node block hight after restored: ${GREEN}$BLOCKHIGHT_AFTER_BOOTSTRAP${NC}"
-
- if [[ "$BLOCKHIGHT_AFTER_BOOTSTRAP" -ge "$DB_HIGHT" ]]; then
-
- string_limit_check_mark "MongoDB bootstrap installed successful.................................."
- echo -e ""
- else
-
- if [[ "$FORCE_BOOTSTRAP" == "1" ]]; then
- string_limit_check_mark "MongoDB bootstrap installed successful.................................."
- echo -e ""
- else
- string_limit_x_mark "MongoDB bootstrap installation failed.................................."
- echo -e ""
- fi
-
- fi
- else
-
- string_limit_x_mark "MongoDB bootstrap installation failed.................................."
- echo -e ""
-
- fi
-
-
-}
-
-function install_kernel(){
-
-
-echo -e "${GREEN}Module: Install Linux Kernel 5.X for Ubuntu 18.04${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-echo -e "${NC}"
-echo -e "${YELLOW}Installing Linux Kernel 5.x${NC}"
-sudo apt-get install --install-recommends linux-generic-hwe-18.04 -y
-read -p "Would you like to reboot pc Y/N?" -n 1 -r
-echo -e "${NC}"
-if [[ $REPLY =~ ^[Yy]$ ]]
-then
-sudo reboot -n
-fi
-
-}
-
-function analyzer_and_fixer(){
-
-echo -e "${GREEN}Module: FluxNode analyzer and fixer${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-bash -i <(curl -s https://raw.githubusercontent.com/XK4MiLX/zelnode/master/nodeanalizerandfixer.sh)
-
-}
-
- function insertAfter
-{
- local file="$1" line="$2" newText="$3"
- sudo sed -i -e "/$line/a"$'\\\n'"$newText"$'\n' "$file"
-}
-
-function fix_lxc_config(){
-
-echo -e "${GREEN}Module: Fix your lxc.conf file on host${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-echo -e ""
-
-continer_name="$(whiptail --title "ZELNODE MULTITOOLBOX $dversion" --inputbox "Enter your LXC continer name" 8 72 3>&1 1>&2 2>&3)"
-echo -e "${YELLOW}================================================================${NC}"
-if [[ $(grep -w "features: mount=fuse,nesting=1" /etc/pve/lxc/$continer_name.conf) && $(grep -w "lxc.mount.entry: /dev/fuse dev/fuse none bind,create=file 0 0" /etc/pve/lxc/$continer_name.conf) ]]
-then
-echo -e "${CHECK_MARK} ${CYAN}LXC configurate file $continer_name.conf [OK]${NC}"
-fi
-
-insertAfter "/etc/pve/lxc/$continer_name.conf" "cores" "features: mount=fuse,nesting=1"
-sudo bash -c "echo 'lxc.mount.entry: /dev/fuse dev/fuse none bind,create=file 0 0' >>/etc/pve/lxc/$continer_name.conf"
-sudo bash -c "echo 'lxc.cap.drop:' >>/etc/pve/lxc/$continer_name.conf"
-sudo bash -c "echo 'lxc.cap.drop: mac_override sys_time sys_module sys_rawio' >>/etc/pve/lxc/$continer_name.conf"
-sudo bash -c "echo 'lxc.apparmor.profile: unconfined' >>/etc/pve/lxc/$continer_name.conf"
-sudo bash -c "echo 'lxc.cgroup.devices.allow: a' >>/etc/pve/lxc/$continer_name.conf"
-sudo bash -c "echo 'lxc.cap.drop:' >>/etc/pve/lxc/$continer_name.conf"
-
-if [[ $(grep -w "features: mount=fuse,nesting=1" /etc/pve/lxc/$continer_name.conf) && $(grep -w "lxc.mount.entry: /dev/fuse dev/fuse none bind,create=file 0 0" /etc/pve/lxc/$continer_name.conf) ]]
-then
-echo -e "${CHECK_MARK} ${CYAN}LXC configurate file $continer_name.conf [FiXED]${NC}"
-else
-echo -e "${X_MARK} ${CYAN}LXC configurate file $continer_name.conf fix [Failed]${NC}"
-fi
-
-}
-
-function install_node(){
-
-echo -e "${GREEN}Module: Install FluxNode${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
-
- echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version not supported${NC}"
- echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
- echo
- exit
-fi
-
-
-if docker run hello-world > /dev/null 2>&1
-then
-echo -e ""
-else
-echo -e "${WORNING}${CYAN}Docker is not working correct or is not installed.${NC}"
-exit
-fi
-
-bash -i <(curl -s https://raw.githubusercontent.com/XK4MiLX/zelnode/master/install_pro.sh)
-
-
-}
-
-function install_docker(){
-
-echo -e "${GREEN}Module: Install Docker${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-
-if [[ "$USER" != "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the root accont use command 'su -'.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
-fi
-
-if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
-
- echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version not supported${NC}"
- echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
- echo
- exit
-
-fi
-
-usernew="$(whiptail --title "MULTITOOLBOX $dversion" --inputbox "Enter your username" 8 72 3>&1 1>&2 2>&3)"
-
-echo -e "${ARROW} ${YELLOW}Creating new user...${NC}"
-adduser --gecos "" "$usernew"
-usermod -aG sudo "$usernew" > /dev/null 2>&1
-echo -e "${ARROW} ${YELLOW}Update and upgrade system...${NC}"
-apt update -y && apt upgrade -y
-echo -e "${ARROW} ${YELLOW}Installing docker...${NC}"
-echo -e "${ARROW} ${CYAN}Architecture: ${GREEN}$(dpkg --print-architecture)${NC}"
-
-if [[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then
- sudo rm /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
-fi
-
-if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
- sudo rm /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
-fi
-
-
-if [[ $(lsb_release -d) = *Debian* ]]
-then
-
-sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
-sudo apt-get update -y > /dev/null 2>&1
-sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
-sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
-#curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - > /dev/null 2>&1
-#sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /dev/null 2>&1
-curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
-echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
-sudo apt-get update -y > /dev/null 2>&1
-sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
-
+#disable bash history
+set +o history
+
+if ! [[ -z $1 ]]; then
+ if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then
+ export ROOT_BRANCH="$1"
+ export BRANCH_ALREADY_REFERENCED='1'
+ if [[ -f "/usr/lib/multitoolbox/multitoolbox.sh" ]]; then
+ bash -i "/usr/lib/multitoolbox/multitoolbox.sh"
+ else
+ bash -i <(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/multitoolbox.sh") $ROOT_BRANCH $2
+ fi
+ unset ROOT_BRANCH
+ unset BRANCH_ALREADY_REFERENCED
+ set -o history
+ exit
+ fi
else
-
-sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
-sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
-sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
-
-curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
-echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
-#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - > /dev/null 2>&1
-#sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /dev/null 2>&1
-sudo apt-get update -y > /dev/null 2>&1
-sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
-
+ export ROOT_BRANCH='master'
fi
-# echo -e "${YELLOW}Creating docker group..${NC}"
-# groupadd docker
-echo -e "${ARROW} ${YELLOW}Adding $usernew to docker group...${NC}"
-adduser "$usernew" docker
-echo -e "${NC}"
-echo -e "${YELLOW}=====================================================${NC}"
-echo -e "${YELLOW}Running through some checks...${NC}"
-echo -e "${YELLOW}=====================================================${NC}"
-
-if sudo docker run hello-world > /dev/null 2>&1
-then
- echo -e "${CHECK_MARK} ${CYAN}Docker is installed${NC}"
+if [[ -f "/usr/lib/multitoolbox/flux_common.sh" ]]; then
+ source "/usr/lib/multitoolbox/flux_common.sh"
else
- echo -e "${X_MARK} ${CYAN}Docker did not installed${NC}"
+ source /dev/stdin <<< "$(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh")"
fi
-if [[ $(getent group docker | grep "$usernew") ]]
-then
- echo -e "${CHECK_MARK} ${CYAN}User $usernew is member of 'docker'${NC}"
+if [[ -d /home/$USER/.zelcash ]]; then
+ CONFIG_DIR='.zelcash'
+ CONFIG_FILE='zelcash.conf'
else
- echo -e "${X_MARK} ${CYAN}User $usernew is not member of 'docker'${NC}"
-fi
-
-echo -e "${YELLOW}=====================================================${NC}"
-echo -e "${NC}"
-read -p "Would you like switch to user account Y/N?" -n 1 -r
-echo -e "${NC}"
-if [[ $REPLY =~ ^[Yy]$ ]]
-then
-su - $usernew
+ CONFIG_DIR='.flux'
+ CONFIG_FILE='flux.conf'
fi
+FLUX_DIR='zelflux'
+FLUX_APPS_DIR='ZelApps'
+COIN_NAME='zelcash'
+dversion="v8.0"
+PM2_INSTALL="0"
+zelflux_setting_import="0"
+OS_FLAGE="$2"
+
+function config_veryfity(){
+ if [[ -f $FLUX_DAEMON_PATH/flux.conf ]]; then
+ echo -e "${ARROW} ${YELLOW}Checking config file...${NC}"
+ insightexplorer=$(cat $FLUX_DAEMON_PATH/flux.conf | grep 'insightexplorer=1' | wc -l)
+ if [[ "$insightexplorer" == "1" ]]; then
+ echo -e "${ARROW} ${CYAN}Insightexplorer enabled..............[${CHECK_MARK}${CYAN}]${NC}"
+ echo ""
+ else
+ echo -e "${WORNING} ${CYAN}Insightexplorer disabled.............[${X_MARK}${CYAN}]${NC}"
+ echo -e "${WORNING} ${CYAN}Use option 2 for node re-install${NC}"
+ echo -e ""
+ exit
+ fi
+ fi
}
-function daemon_reconfiguration()
-{
-
-echo -e "${GREEN}Module: Flux Daemon Reconfiguration${NC}"
-echo -e "${YELLOW}================================================================${NC}"
+function config_file() {
+ if [[ -f $DATA_PATH/install_conf.json ]]; then
+ import_settings=$(cat $DATA_PATH/install_conf.json | jq -r '.import_settings')
+ bootstrap_url=$(cat $DATA_PATH/install_conf.json | jq -r '.bootstrap_url')
+ bootstrap_zip_del=$(cat $DATA_PATH/install_conf.json | jq -r '.bootstrap_zip_del')
+ use_old_chain=$(cat $DATA_PATH/install_conf.json | jq -r '.use_old_chain')
+ prvkey=$(cat $DATA_PATH/install_conf.json | jq -r '.prvkey')
+ outpoint=$(cat $DATA_PATH/install_conf.json | jq -r '.outpoint')
+ index=$(cat $DATA_PATH/install_conf.json | jq -r '.index')
+ zel_id=$(cat $DATA_PATH/install_conf.json | jq -r '.zelid')
+ upnp_port=$(cat $DATA_PATH/install_conf.json | jq -r '.upnp_port')
+ gateway_ip=$(cat $DATA_PATH/install_conf.json | jq -r '.gateway_ip')
+ upnp_enabled=$(cat $DATA_PATH/install_conf.json | jq -r '.upnp_enabled')
+ thunder=$(cat $DATA_PATH/install_conf.json | jq -r '.thunder')
+ echo -e "${ARROW} ${YELLOW}Install config summary:"
+ if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then
+ echo -e "${PIN}${CYAN}Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ if [[ "$import_settings" == "1" ]]; then
+ echo -e "${PIN}${CYAN}Import settings from exist config files..........................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ if [[ "$use_old_chain" == "1" ]]; then
+ echo -e "${PIN}${CYAN}During re-installation old chain will be used....................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ if [[ "$bootstrap_url" == "" || "$bootstrap_url" == "0" ]]; then
+ echo -e "${PIN}${CYAN}Use Flux Bootstrap from source build in scripts..................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${PIN}${CYAN}Use Flux Bootstrap from own source...............................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ if [[ "$bootstrap_zip_del" == "1" ]]; then
+ echo -e "${PIN}${CYAN}Remove Flux Bootstrap archive file...............................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${PIN}${CYAN}Leave Flux Bootstrap archive file................................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ if [[ ( "$discord" != "" && "$discord" != "0" ) || "$telegram_alert" == '1' ]]; then
+ echo -e "${PIN}${CYAN}Enable watchdog notification.....................................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ echo -e "${PIN}${CYAN}Disable watchdog notification....................................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
+ if [[ ! -z $gateway_ip && ! -z $upnp_port ]] && [[ "$upnp_enabled" == "true" ]] ; then
+ echo -e "${PIN}${CYAN}Enable UPnP configuration........................................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+}
+function install_flux() {
+ echo -e "${GREEN}Module: Re-install FluxOS${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if pm2 -v > /dev/null 2>&1; then
+ pm2 del zelflux > /dev/null 2>&1
+ pm2 del flux > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ fi
+ else
+ echo -e "${ARROW} ${CYAN}Stopping FluxOS....${NC}"
+ sudo systemctl stop flux-watchdog > /dev/null 2>&1
+ sudo systemctl stop fluxos > /dev/null 2>&1
+ sudo systemctl stop syncthing > /dev/null 2>&1
+ fi
+ fluxos_clean
+ if [[ -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ echo -e "${ARROW} ${CYAN}Import settings...${NC}"
+ ZELID=$(grep -w zelid $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
+ WANIP=$(grep -w ipaddress $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*ipaddress: .//' | sed -e 's/.\{2\}$//')
+ echo -e "${PIN}${CYAN}Flux/SSP ID = ${GREEN}$ZELID${NC}"
+ #KDA_A=$(grep -w kadena $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
+ #if [[ "$KDA_A" != "" ]]; then
+ #echo -e "${PIN}${CYAN}Kadena address = ${GREEN}$KDA_A${NC}"
+ #fi
+ echo -e "${PIN}${CYAN}IP = ${GREEN}$WANIP${NC}"
+ upnp_port=$(grep -w apiport $FLUXOS_PATH/config/userconfig.js | egrep -o '[0-9]+')
+ if [[ "$upnp_port" != "" ]]; then
+ echo -e "${PIN}${CYAN}API port = ${GREEN}$upnp_port${NC}"
+ fi
+ router_ip=$(grep -w routerIP $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*routerIP: .//' | sed -e 's/.\{2\}$//')
+ if [[ "$router_ip" != "" ]]; then
+ echo -e "${PIN}${CYAN}Router IP = ${GREEN}$router_ip${NC}"
+ fi
+ ImportBlockedPorts
+ if [[ "$blockedPortsList" != "" ]]; then
+ echo -e "${PIN}${CYAN}BlockedPorts: [$display]${NC}"
+ fi
+ ImportBlockedRepository
+ if [[ "$blockedRepositoryList" != "" ]]; then
+ echo -e "${PIN}${CYAN}BlockedRepositories: [$display]${NC}"
+ fi
+ echo -e ""
+ echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS....${NC}"
+ sudo rm -rf $FLUXOS_PATH > /dev/null 2>&1 && sleep 1
+ if [[ "$ZELID" != "" && "$WANIP" != "" ]]; then
+ zelflux_setting_import="1"
+ fi
+ fi
+ if [ -d $FLUXOS_PATH ]; then
+ echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS....${NC}"
+ sudo rm -rf $FLUXOS_PATH > /dev/null 2>&1 && sleep 1
+ fi
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ cd $DATA_PATH/usr/lib
+ FLUXOS_HOME_DIR="fluxos"
+ fi
+ if [[ -z $FLUXOS_VERSION ]]; then
+ FLUXOS_HOME_DIR="zelflux"
+ fi
+ echo -e "${ARROW} ${CYAN}FluxOS downloading...${NC}"
+ if [[ -n $FLUXOS_VERSION ]]; then
+ SUDO_CMD="sudo"
+ fi
+ $SUDO_CMD git clone https://github.com/RunOnFlux/flux.git $FLUXOS_HOME_DIR > /dev/null 2>&1 && sleep 1
+ if [[ -d $FLUXOS_PATH ]]; then
+ if [[ -f $FLUXOS_PATH/package.json ]]; then
+ current_ver=$(jq -r '.version' $FLUXOS_PATH/package.json)
+ else
+ string_limit_x_mark "FluxOS was not downloaded, run script again..........................................."
+ echo
+ exit
+ fi
+ string_limit_check_mark "FluxOS v$current_ver downloaded..........................................." "FluxOS ${GREEN}v$current_ver${CYAN} downloaded..........................................."
+ else
+ string_limit_x_mark "FluxOS was not downloaded, run script again..........................................."
+ echo
exit
-fi
-
-echo
-echo -e "${ARROW} ${YELLOW}Fill in all the fields that you want to replace${NC}"
-sleep 4
-skip_change='4'
-zelnodeprivkey="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Private Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)"
-sleep 1
-zelnodeoutpoint="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Output TX ID" 8 72 3>&1 1>&2 2>&3)"
-sleep 1
-zelnodeindex="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Output Index" 8 60 3>&1 1>&2 2>&3)"
-sleep 1
-externalip="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode IP" 8 60 3>&1 1>&2 2>&3)"
-sleep 1
-
-if [[ "$zelnodeprivkey" == "" ]]; then
-skip_change=$((skip_change-1))
-echo -e "${ARROW} ${CYAN}Replace FluxNode privkey skipped....................[${CHECK_MARK}${CYAN}]${NC}"
-fi
-
-if [[ "$zelnodeoutpoint" == "" ]]; then
-skip_change=$((skip_change-1))
-echo -e "${ARROW} ${CYAN}Replace FluxNode outpoint skipped ..................[${CHECK_MARK}${CYAN}]${NC}"
-fi
-
-if [[ "$zelnodeindex" == "" ]]; then
-skip_change=$((skip_change-1))
-echo -e "${ARROW} ${CYAN}Replace FluxNode index skipped......................[${CHECK_MARK}${CYAN}]${NC}"
-fi
-
-if [[ "$externalip" == "" ]]; then
-skip_change=$((skip_change-1))
-echo -e "${ARROW} ${CYAN}Replace FluxNode IP skipped.........................[${CHECK_MARK}${CYAN}]${NC}"
-fi
-
-
-if [[ "$skip_change" == "0" ]]; then
-echo -e "${ARROW} ${YELLOW}All fields are empty changes skipped...${NC}"
-echo
-exit
-fi
-
-echo -e "${ARROW} ${CYAN}Stopping Flux daemon serivce...${NC}"
-sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
-sudo fuser -k 16125/tcp > /dev/null 2>&1
-
-
-if [[ "$zelnodeprivkey" != "" ]]; then
+ fi
+ if [[ "$zelflux_setting_import" == "0" ]]; then
+ get_ip "install"
+ while true
+ do
+ ZELID="$(whiptail --title "MULTITOOLBOX" --inputbox "Enter your Flux/SSP ID from ZelCore (Apps -> Flux ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)"
+ if [ $(printf "%s" "$ZELID" | wc -c) -eq "34" ] || [ $(printf "%s" "$ZELID" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$ZELID") ]; then
+ string_limit_check_mark "Flux/SSP ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Flux/SSP ID is not valid try again..........................................."
+ sleep 2
+ fi
+ done
+ #if [[ -z $FLUXOS_VERSION ]]; then
+ #while true
+ #do
+ #KDA_A=$(whiptail --inputbox "Node tier eligible to receive KDA rewards, what's your KDA address? Nothing else will be required on FluxOS regarding KDA." 8 85 3>&1 1>&2 2>&3)
+ #if [[ "$KDA_A" != "" && "$KDA_A" != *kadena* && "$KDA_A" = *k:* ]]; then
+ #echo -e "${ARROW} ${CYAN}Kadena address is valid.................[${CHECK_MARK}${CYAN}]${NC}"
+ #KDA_A="kadena:$KDA_A?chainid=0"
+ #sleep 2
+ #break
+ #else
+ #echo -e "${ARROW} ${CYAN}Kadena address is not valid.............[${X_MARK}${CYAN}]${NC}"
+ #sleep 2
+ #fi
+ #done
+ #fi
+ fi
+ fluxos_conf_create
+ if [[ -f $FLUXOS_PATH/config/userconfig.js ]]; then
+ if [[ "$upnp_port" != "" ]]; then
+ config_builder "apiport" "$upnp_port" "API Port" "fluxos"
+ fi
+ if [[ "$router_ip" != "" ]]; then
+ config_builder "routerIP" "$router_ip" "Router IP" "fluxos"
+ fi
+ if [[ "$blockedPortsList" != "" ]]; then
+ RemoveLine "blockedPorts"
+ buildBlockedPortsList " blockedPorts" "$blockedPortsList" "Blocked ports list created successfully!" "fluxos"
+ fi
+ if [[ "$blockedRepositoryList" != "" ]]; then
+ RemoveLine "blockedRepositories"
+ buildBlockedRepositoryList " blockedRepositories" "$blockedRepositoryList" "Blocked repositories list created successfully!" "fluxos"
+ fi
+ string_limit_check_mark "FluxOS configuration successfull..........................................."
+ else
+ string_limit_x_mark "FluxOS installation failed, missing config file..........................................."
+ echo
+ exit
+ fi
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if pm2 -v > /dev/null 2>&1; then
+ rm restart_zelflux.sh > /dev/null 2>&1
+ pm2 del flux > /dev/null 2>&1
+ pm2 del zelflux > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}"
+ echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}"
+ echo -e ""
+ pm2 start /home/$USER/$FLUX_DIR/start.sh --max-memory-restart 1500M --restart-delay 30000 --max-restarts 40 --name flux --time > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ pm2 list
+ else
+ pm2_install
+ if [[ "$PM2_INSTALL" == "1" ]]; then
+ echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}"
+ echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}"
+ echo
+ pm2 list
+ fi
+ fi
+ else
+ echo -e "${ARROW} ${CYAN}Installing FluxOS dependencies will take 5min....${NC}"
+ cd $FLUXOS_PATH
+ sudo npm install --omit=dev --cache /dat/usr/lib/npm > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}"
+ echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}"
+ echo
+ sudo systemctl start syncthing > /dev/null 2>&1
+ sudo systemctl start flux-watchdog > /dev/null 2>&1
+ sudo systemctl restart fluxbenchd > /dev/null 2>&1
+ sudo systemctl start fluxos > /dev/null 2>&1
+ fi
+}
+function create_config() {
+ echo -e "${GREEN}Module: Create FluxNode installation config file...${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ if jq --version > /dev/null 2>&1; then
+ sleep 0.2
+ else
+ echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}"
+ sudo apt install jq -y > /dev/null 2>&1
+ if jq --version > /dev/null 2>&1; then
+ string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................."
+ echo
+ else
+ string_limit_x_mark "JQ was not installed................................."
+ echo
+ exit
+ fi
+ fi
-if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "${ARROW} ${CYAN}Replace FluxNode privkey skipped....................[${CHECK_MARK}${CYAN}]${NC}"
+ CHOICE=$(whiptail --title "Create FluxNode installation config" --menu "Make your choice" 15 65 8 \
+ "1)" "Manualy - fill questions list" \
+ "2)" "Auto - import exists settings" 3>&2 2>&1 1>&3 )
+ case $CHOICE in
+ "1)")
+ manual_build
+ ;;
+ "2)")
+ config_smart_create
+ ;;
+ esac
+}
+function install_watchdog() {
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ echo -e "${GREEN}Module: Install watchdog for FluxNode${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if ! pm2 -v > /dev/null 2>&1; then
+ pm2_install
+ if [[ "$PM2_INSTALL" == "0" ]]; then
+ exit
+ fi
+ echo -e ""
+ fi
+ pm2 del watchdog > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Downloading...${NC}"
+ cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}"
+ wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1
+ mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
+ sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
+ echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}"
+ cd watchdog && npm install > /dev/null 2>&1
+ else
+ sudo systemctl stop flux-watchdog
+ cd $FLUX_WATCHDOG_PATH
+ cd ..
+ sudo rm -rf $FLUX_WATCHDOG_PATH > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Downloading...${NC}"
+ git clone https://github.com/RunOnFlux/fluxnode-watchdog.git flux-watchdog > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}"
+ wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1
+ mv post-merge $FLUX_WATCHDOG_PATH/.git/hooks/post-merge
+ sudo chmod +x $FLUX_WATCHDOG_PATH/.git/hooks/post-merge
+ echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}"
+ cd flux-watchdog && npm install > /dev/null 2>&1
+ fi
+ echo -e "${ARROW} ${CYAN}Creating config file....${NC}"
+ if whiptail --yesno "Would you like enable FluxOS auto update?" 8 60; then
+ flux_update='1'
+ sleep 1
+ else
+ flux_update='0'
+ sleep 1
+ fi
+ if whiptail --yesno "Would you like enable Flux daemon auto update?" 8 60; then
+ daemon_update='1'
+ sleep 1
+ else
+ daemon_update='0'
+ sleep 1
+ fi
+ if whiptail --yesno "Would you like enable Flux benchmark auto update?" 8 60; then
+ bench_update='1'
+ sleep 1
+ else
+ bench_update='0'
+ sleep 1
+ fi
+ fix_action='1'
+ telegram_alert=0;
+ discord=0;
+ if whiptail --yesno "Would you like enable alert notification?" 8 60; then
+ sleep 1
+ whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60
+ sleep 1
+ CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \
+ "1" "Discord notification " ON \
+ "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 )
+ if [[ -z "$CHOICES" ]]; then
+ echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}"
+ sleep 1
+ discord=0;
+ ping=0;
+ telegram_alert=0;
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ node_label=0;
+ else
+ for CHOICE in $CHOICES; do
+ case "$CHOICE" in
+ "1")
+ discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+ if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then
+ while true
+ do
+ ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3)
+ if [[ $ping == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "UserID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "UserID is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ else
+ ping=0;
+ sleep 1
+ fi
+ ;;
+ "2")
+ telegram_alert=1;
+ while true
+ do
+ telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3)
+ if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then
+ string_limit_check_mark "Bot token is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Bot token is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ while true
+ do
+ telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3)
+ if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "Chat ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Chat ID is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ ;;
+ esac
+ done
+ fi
+ while true
+ do
+ node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3)
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ string_limit_check_mark "Node name is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Node name is not valid try again............................."
+ sleep 1
+ fi
+ done
+ sleep 1
+ else
+ node_label=0;
+ discord=0;
+ ping=0;
+ telegram_alert=0;
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ sleep 1
+ fi
+ if [[ $discord == 0 ]]; then
+ ping=0;
+ fi
+ if [[ $telegram_alert == 0 ]]; then
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ fi
+ if [[ -f $FLUX_BENCH_PATH/$CONFIG_FILE ]]; then
+ index_from_file=$(grep -w zelnodeindex $FLUX_BENCH_PATH/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ tx_from_file=$(grep -w zelnodeoutpoint $FLUX_BENCH_PATH/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
+ stak_info=$(curl -s -m 5 https://explorer.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -s -m 5 https://explorer.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ fi
+ fi
+ if [[ $stak_info == ?(-)+([0-9]) ]]; then
+ case $stak_info in
+ "1000") eps_limit=240 ;;
+ "12500") eps_limit=640 ;;
+ "40000") eps_limit=1520 ;;
+ esac
+ else
+ eps_limit=0;
+ fi
+ watchdog_conf_create
+ echo -e "${ARROW} ${CYAN}Starting watchdog...${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ else
+ sudo systemctl start flux-watchdog > /dev/null 2>&1
+ fi
+ if [[ -f $FLUX_WATCHDOG_PATH/watchdog.js ]]; then
+ current_ver=$(jq -r '.version' $FLUX_WATCHDOG_PATH/package.json)
+ string_limit_check_mark "Watchdog v$current_ver installed..........................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed..........................................."
+ else
+ string_limit_x_mark "Watchdog was not installed..........................................."
+ fi
+ echo -e ""
+}
+function flux_daemon_bootstrap() {
+ echo -e "${GREEN}Module: Restore Flux blockchain from bootstrap${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ cd
+ echo -e "${NC}"
+ #config_veryfity
+ bootstrap_new
+}
+function install_node(){
+ echo -e "${GREEN}Module: Install FluxNode${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+
+ if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
+ echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}"
+ echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+ fi
+
+ if [[ "$OS_FLAGE" == "" ]]; then
+ os_check
+ fi
+
+ if sudo docker run hello-world > /dev/null 2>&1; then
+ echo -e ""
+ else
+ echo -e "${WORNING}${CYAN}Docker is not working correct or is not installed.${NC}"
+ exit
+ fi
+ bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro.sh)
+}
+function install_docker(){
+ echo -e "${GREEN}Module: Install Docker${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ "$USER" != "root" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the root account use command 'sudo su -'.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
+ echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}"
+ echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+ fi
+
+ if [[ "$OS_FLAGE" == "" ]]; then
+ os_check
+ fi
+
+ if [[ -z "$usernew" ]]; then
+ usernew="$(whiptail --title "MULTITOOLBOX $dversion" --inputbox "Enter your username" 8 72 3>&1 1>&2 2>&3)"
+ usernew=$(awk '{print tolower($0)}' <<< "$usernew")
+ else
+ echo -e "${PIN}${CYAN} Import docker user '$usernew' from environment variable............[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ echo -e "${ARROW} ${CYAN}New User: ${GREEN}${usernew}${NC}"
+ adduser --gecos "" "$usernew"
+ usermod -aG sudo "$usernew" > /dev/null 2>&1
+ echo -e "${ARROW} ${YELLOW}Update and upgrade system...${NC}"
+ apt update -y && apt upgrade -y
+ if ! ufw version > /dev/null 2>&1; then
+ echo -e "${ARROW} ${YELLOW}Installing ufw firewall..${NC}"
+ sudo apt-get install -y ufw > /dev/null 2>&1
+ fi
+ cron_check=$(systemctl status cron 2> /dev/null | grep 'active' | wc -l)
+ if [[ "$cron_check" == "0" ]]; then
+ echo -e "${ARROW} ${YELLOW}Installing crontab...${NC}"
+ sudo apt-get install -y cron > /dev/null 2>&1
+ fi
+ echo -e "${ARROW} ${YELLOW}Installing docker...${NC}"
+ echo -e "${ARROW} ${CYAN}Architecture: ${GREEN}$(dpkg --print-architecture)${NC}"
+ if [[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then
+ sudo rm /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
+ fi
+ if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
+ sudo rm /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
+ fi
+ if [[ $(lsb_release -d) = *Debian* ]]; then
+ sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
+ sudo apt-get update -y > /dev/null 2>&1
+ sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
+ sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
+ #curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - > /dev/null 2>&1
+ #sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /dev/null 2>&1
+ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
+ sudo apt-get update -y > /dev/null 2>&1
+ sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
+ else
+ sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
+ sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
+ sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
+ #curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - > /dev/null 2>&1
+ #sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /dev/null 2>&1
+ sudo apt-get update -y > /dev/null 2>&1
+ sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
+ fi
+ echo -e "${ARROW} ${YELLOW}Adding $usernew to docker group...${NC}"
+ adduser "$usernew" docker
+ echo -e "${NC}"
+ echo -e "${YELLOW}=====================================================${NC}"
+ echo -e "${YELLOW}Running through some checks...${NC}"
+ echo -e "${YELLOW}=====================================================${NC}"
+ if sudo docker run hello-world > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN}Docker is installed${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN}Docker did not installed${NC}"
+ fi
+ if [[ $(getent group docker | grep "$usernew") ]]; then
+ echo -e "${CHECK_MARK} ${CYAN}User $usernew is member of 'docker'${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN}User $usernew is not member of 'docker'${NC}"
+ fi
+ echo -e "${YELLOW}=====================================================${NC}"
+ echo -e "${NC}"
+ read -p "Would you like switch to user account Y/N?" -n 1 -r
+ echo -e "${NC}"
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ su - $usernew
+ fi
+}
+function mongod_db_fix() {
+ echo -e "${GREEN}Module: MongoDB Repair Assistant${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ fi
+ if [[ -z $FLUXOS_VERSION ]]; then
+ CHOICE=$(
+ whiptail --title "MongoDB Repair Assistant" --menu "Make your choice" 15 65 8 \
+ "1)" "Soft repair - MongoDB database repair" \
+ "2)" "Hard repair - MongoDB re-install" 3>&2 2>&1 1>&3
+ )
+ else
+ CHOICE=$(
+ whiptail --title "MongoDB FiX action" --menu "Make your choice" 15 65 8 \
+ "1)" "Soft repair - MongoDB database repair" \
+ "2)" "Hard repair - MongoDB database wipe" 3>&2 2>&1 1>&3
+ )
+ fi
+ case $CHOICE in
+ "1)")
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Soft repair starting... ${NC}"
+ echo -e "${ARROW} ${CYAN}Stopping MongoDB service ${NC}"
+ sudo systemctl stop mongod
+ echo -e "${ARROW} ${CYAN}Fixing corrupted DB ${NC}"
+ sudo rm $MONGODB_DATA_PATH/journal/* > /dev/null 2>&1
+ sudo rm $MONGODB_DATA_PATH/mongod.lock > /dev/null 2>&1
+ sudo -u mongodb mongod --dbpath $MONGODB_DATA_PATH --repair > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Setting privilege ${NC}"
+ sudo chown -R mongodb:mongodb $MONGODB_DATA_PATH > /dev/null 2>&1
+ sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting MongoDB service ${NC}"
+ sudo systemctl start mongod
+ if mongod --version > /dev/null 2>&1; then
+ string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
+ echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}"
+ fi
+ echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}"
+ if [[ -z $FLUXOS_VERSION ]]; then
+ sudo systemctl restart zelcash > /dev/null 2>&1
+ pm2 restart flux > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxd > /dev/null 2>&1
+ sudo systemctl restart fluxbenchd > /dev/null 2>&1
+ sudo systemctl restart fluxos > /dev/null 2>&1
+ fi
+ sleep 5
+ echo -e ""
+ ;;
+ "2)")
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Hard repair starting... ${NC}"
+ echo -e "${ARROW} ${CYAN}Stopping MongoDB service...${NC}"
+ sudo systemctl stop mongod
+ if [[ -z $FLUXOS_VERSION ]]; then
+ echo -e "${ARROW} ${CYAN}Removing MongoDB... ${NC}"
+ sudo apt-get remove -f mongodb-org* -y > /dev/null 2>&1
+ sudo apt-get purge --allow-change-held-packages mongodb-org* -y > /dev/null 2>&1
+ sudo apt autoremove -y > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Removing Database... ${NC}"
+ sudo rm -r /var/log/mongodb > /dev/null 2>&1
+ sudo rm -r /var/lib/mongodb > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Installing MongoDB... ${NC}"
+ avx_check=$(cat /proc/cpuinfo | grep -o avx | head -n1)
+ os_version=$(lsb_release -rs | tr -d '.')
+ architecture=$(dpkg --print-architecture)
+ if [[ $(lsb_release -d) = *Debian* ]]; then
+ os_name="Debian"
+ fi
+ if [[ $(lsb_release -d) = *Ubuntu* ]]; then
+ os_name="Ubuntu"
+ fi
+ #Ubuntu MongoDB 4.4
+ if [[ "$avx_check" == "" && "$os_name" == "Ubuntu" && "$architecture" == "amd64" && "$os_version" -le "2010" ]] || [[ "$os_name" == "Ubuntu" && "$architecture" == "arm64" && "$os_version" -le "2010" ]]; then
+ install_mongod="4.4"
+ fi
+ #Debian MongoDB 4.4
+ if [[ "$avx_check" == "" && "$os_name" == "Debian" && "$architecture" == "amd64" && "$os_version" -le "9" ]] || [[ "$os_name" == "Debian" && "$architecture" == "arm64" && "$os_version" -le "9" ]]; then
+ install_mongod="4.4"
+ fi
+ if [[ "$install_mongod" == "4.4" ]]; then
+ sudo apt update -y > /dev/null 2>&1
+ sudo apt install -y mongodb-org=4.4.18 mongodb-org-server=4.4.18 mongodb-org-shell=4.4.18 mongodb-org-mongos=4.4.18 mongodb-org-tools=4.4.18 > /dev/null 2>&1 && sleep 2
+ echo "mongodb-org hold" | sudo dpkg --set-selections > /dev/null 2>&1 && sleep 2
+ echo "mongodb-org-server hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-shell hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-mongos hold" | sudo dpkg --set-selections > /dev/null 2>&1
+ echo "mongodb-org-tools hold" | sudo dpkg --set-selections > /dev/null 2>&1
else
- sed -i "s/$(grep -e zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeprivkey=$zelnodeprivkey/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e "${ARROW} ${CYAN}FluxNode privkey replaced successful................[${CHECK_MARK}${CYAN}]${NC}"
- fi
-fi
-
-fi
-
-if [[ "$zelnodeoutpoint" != "" ]]; then
-
-if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "${ARROW} ${CYAN}Replace FluxNode outpoint skipped ..................[${CHECK_MARK}${CYAN}]${NC}"
+ sudo apt update -y > /dev/null 2>&1
+ DEBIAN_FRONTEND=noninteractive sudo apt-get --yes install mongodb-org > /dev/null 2>&1
+ fi
+ sudo mkdir -p /var/log/mongodb > /dev/null 2>&1
+ sudo mkdir -p /var/lib/mongodb > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Settings privilege... ${NC}"
+ sudo chown -R mongodb:mongodb /var/log/mongodb > /dev/null 2>&1
+ sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1
+ sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
+ fluxos_clean
+ #echo -e "${ARROW} ${CYAN}Restoring Database... ${NC}"
+ #mongorestore --drop --archive=/home/$USER/mongoDB_backup.gz > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting mongod service... ${NC}"
+ sudo systemctl enable mongod
+ sudo systemctl start mongod
+ if mongod --version > /dev/null 2>&1; then
+ string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
+ echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}"
else
- sed -i "s/$(grep -e zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeoutpoint=$zelnodeoutpoint/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e "${ARROW} ${CYAN}FluxNode outpoint replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
- fi
-fi
-
-fi
-
-if [[ "$zelnodeindex" != "" ]]; then
-
-if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "${ARROW} ${CYAN}Replace FluxNode index skipped......................[${CHECK_MARK}${CYAN}]${NC}"
+ string_limit_x_mark "MongoDB was not installed................................."
+ fi
+ echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}"
+ sudo systemctl restart zelcash > /dev/null 2>&1
+ pm2 restart flux > /dev/null 2>&1
+ sleep 5
+ echo -e ""
+ else
+ echo -e "${ARROW} ${CYAN}Stopping Flux Watchdog service... ${NC}"
+ sudo systemctl stop flux-watchdog > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Stopping Fluxd service... ${NC}"
+ sudo systemctl stop fluxd > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Stopping Fluxbench service... ${NC}"
+ sudo systemctl stop fluxbenchd > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Stopping FluxOS service... ${NC}"
+ sudo systemctl stop fluxos > /dev/null 2>&1
+ sudo rm -rf /var/lib/mongodb/*
+ fluxos_clean
+ echo -e "${ARROW} ${CYAN}Starting MongoDB service... ${NC}"
+ sudo systemctl start mongod > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting Syncthing service... ${NC}"
+ sudo systemctl start syncthing > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting FluxOS service... ${NC}"
+ sudo systemctl start fluxos > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting Fluxd service... ${NC}"
+ sudo systemctl start fluxd > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting Fluxbench service... ${NC}"
+ sudo systemctl start fluxbenchd > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting Flux Watchdog service... ${NC}"
+ sudo systemctl start flux-watchdog > /dev/null 2>&1
+ if mongod --version > /dev/null 2>&1; then
+ string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
+ echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}"
else
- sed -i "s/$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeindex=$zelnodeindex/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e "${ARROW} ${CYAN}FluxNode index replaced successful..................[${CHECK_MARK}${CYAN}]${NC}"
-
- fi
-fi
+ string_limit_x_mark "MongoDB was not installed................................."
+ fi
+ echo -e ""
+ fi
+ ;;
+ esac
+}
+function node_reconfiguration() {
+ reset=""
+ if [[ -f $DATA_PATH/install_conf.json ]]; then
+ import_config_file "silent"
+ get_ip
+ if [[ -d $FLUXOS_PATH ]]; then
+ if [[ "$ZELID" != "" ]]; then
+ echo -e "${ARROW} ${CYAN}Creating FluxOS config file...${NC}"
+ sudo rm -rf $FLUXOS_PATH/config/userconfig.js > /dev/null 2>&1
+ fluxos_conf_create
+ reset=0
+ fi
+ fi
+ if [[ -d $FLUX_DAEMON_PATH ]]; then
+ if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]]; then
+ zelnodeprivkey="$prvkey"
+ zelnodeoutpoint="$outpoint"
+ zelnodeindex="$index"
+ echo -e "${ARROW} ${CYAN}Creating Daemon config file...${NC}"
+ sudo rm -rf $FLUX_DAEMON_PATH/flux.conf > /dev/null 2>&1
+ flux_daemon_conf_create
+ reset=0
+ fi
+ fi
+ if [[ -d $FLUX_WATCHDOG_PATH ]]; then
+ echo -e "${ARROW} ${CYAN}Creating Watchdog config file...${NC}"
+ sudo rm -rf $FLUX_WATCHDOG_PATH/config.js > /dev/null 2>&1
+ fix_action='1'
+ watchdog_conf_create
+ reset=0
+ fi
+ if [[ -d $FLUX_DAEMON_PATH ]]; then
+ if [[ ! -z "$upnp_port" && ! -z "$gateway_ip" ]]; then
+ reset=1
+ upnp_enable
+ fi
+ fi
+ if [[ "$reset" == "0" ]]; then
+ if [[ -z $FLUXOS_VERSION ]]; then
+ echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}"
+ sudo systemctl restart zelcash > /dev/null 2>&1
+ pm2 restart flux > /dev/null 2>&1
+ else
+ sudo systemctl restart fluxd > /dev/null 2>&1
+ sudo systemctl restart fluxbenchd > /dev/null 2>&1
+ sudo systemctl restart fluxos > /dev/null 2>&1
+ sudo systemctl restart flux-watchdog > /dev/null 2>&1
+ fi
+ sleep 10
+ fi
+ else
+ echo -e "${ARROW} ${CYAN}Install config file not exist, operation aborted...${NC}"
+ echo -e ""
+ fi
+}
+if ! figlet -v > /dev/null 2>&1; then
+ sudo apt-get update -y > /dev/null 2>&1
+ sudo apt-get install -y figlet > /dev/null 2>&1
fi
-if [[ "$externalip" != "" ]]; then
-
-if [[ "externalip=$externalip" == $(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "${ARROW} ${CYAN}Replace FluxNode IP skipped.........................[${CHECK_MARK}${CYAN}]${NC}"
- else
- sed -i "s/$(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE)/externalip=$externalip/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "externalip=$externalip" == $(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e "${ARROW} ${CYAN}FluxNode IP replaced successful.....................[${CHECK_MARK}${CYAN}]${NC}"
-
- fi
+if ! pv -V > /dev/null 2>&1; then
+ sudo apt-get install -y pv > /dev/null 2>&1
fi
-fi
-
-sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2
-NUM='35'
-MSG1='Restarting daemon serivce...'
-MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
-spinning_timer
-echo -e "" && echo -e ""
-}
-
-
-
-
-if ! figlet -v > /dev/null 2>&1
-then
-sudo apt-get update -y > /dev/null 2>&1
-sudo apt-get install -y figlet > /dev/null 2>&1
+if ! gzip -V > /dev/null 2>&1; then
+ sudo apt-get install -y gzip > /dev/null 2>&1
fi
-if ! pv -V > /dev/null 2>&1
-then
-sudo apt-get install -y pv > /dev/null 2>&1
+if ! whiptail -v > /dev/null 2>&1; then
+ sudo apt-get install -y whiptail > /dev/null 2>&1
fi
-if ! gzip -V > /dev/null 2>&1
-then
-sudo apt-get install -y gzip > /dev/null 2>&1
+if ! upnpc -h > /dev/null 2>&1 ; then
+ sudo apt install -y miniupnpc > /dev/null 2>&1 && sleep 2
fi
-if ! zip -v > /dev/null 2>&1
-then
-sudo apt-get install -y zip > /dev/null 2>&1
+if [[ $(cat /etc/bash.bashrc | grep 'multitoolbox' | wc -l) == "0" && $FLUXOS_VERSION == "" ]]; then
+ echo "alias multitoolbox='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)'" | sudo tee -a /etc/bash.bashrc
+ echo "alias multitoolbox_testnet='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox_testnet.sh)'" | sudo tee -a /etc/bash.bashrc
+ alias multitoolbox='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)'
+ alias multitoolbox_testnet='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox_testnet.sh)'
+ source /etc/bash.bashrc
fi
-if ! whiptail -v > /dev/null 2>&1
-then
-sudo apt-get install -y whiptail > /dev/null 2>&1
+if [[ -d /usr/lib/multitoolbox ]]; then
+ cd /usr/lib/multitoolbox
+ commit_hash=$(sudo git rev-parse --short HEAD)
+ commit_date=$(sudo git log -1 --date=format:'%Y-%m-%d %H:%M:%S' --format=%cd)
+ ROOT_BRANCH=$(sudo git rev-parse --abbrev-ref HEAD)
+ cd
fi
-
-
+if ! wget --version > /dev/null 2>&1 ; then
+ sudo apt install -y wget > /dev/null 2>&1 && sleep 2
+fi
clear
sleep 1
echo -e "${BLUE}"
figlet -f slant "Multitoolbox"
echo -e "${YELLOW}================================================================${NC}"
-echo -e "${GREEN}Version: $dversion${NC}"
-echo -e "${GREEN}OS: Ubuntu 16/18/19/20, Debian 9/10 ${NC}"
-echo -e "${GREEN}Created by: XK4MiLX from Flux's team${NC}"
-echo -e "${GREEN}Special thanks to dk808, CryptoWrench && jriggs28${NC}"
-echo -e "${YELLOW}================================================================${NC}"
-echo -e "${CYAN}1 - Install Docker${NC}"
-echo -e "${CYAN}2 - Install FluxNode${NC}"
-echo -e "${CYAN}3 - FluxNode analyzer and fixer${NC}"
-echo -e "${CYAN}4 - Install watchdog for FluxNode${NC}"
-echo -e "${CYAN}5 - Restore Flux MongoDB datatable from bootstrap${NC}"
-echo -e "${CYAN}6 - Restore Flux blockchain from bootstrap${NC}"
-echo -e "${CYAN}7 - Create FluxNode installation config file${NC}"
-echo -e "${CYAN}8 - Re-install Flux${NC}"
-echo -e "${CYAN}9 - Flux Daemon Reconfiguration${NC}"
-echo -e "${CYAN}10 - Restore Kadena node blockchain from bootstrap${NC}"
-#echo -e "${CYAN}8 - Install Linux Kernel 5.X for Ubuntu 18.04${NC}"
+if [[ -n $FLUXOS_VERSION ]]; then
+ echo -e "${GREEN}Version: $dversion${NC}"
+ echo -e "${GREEN}Commit: $commit_hash${NC}"
+ echo -e "${GREEN}Data: $commit_date${NC}"
+fi
+echo -e "${GREEN}Branch: $ROOT_BRANCH${NC}"
+if [[ ! -z $FLUXOS_VERSION ]]; then
+ echo -e "${GREEN}FluxOS version: $FLUXOS_VERSION${NC}"
+else
+ echo -e "${GREEN}OS: Ubuntu 20/22/23, Debian 10/11/12 (if hardware requirements are met)${NC}"
+fi
echo -e "${YELLOW}================================================================${NC}"
-
+if [[ -z $FLUXOS_VERSION ]]; then
+ echo -e "${CYAN}1 - Install Docker${NC}"
+ echo -e "${CYAN}2 - Install FluxNode${NC}"
+ echo -e "${CYAN}3 - FluxNode analyzer and fixer${NC}"
+ echo -e "${CYAN}4 - Install watchdog for FluxNode${NC}"
+ echo -e "${CYAN}5 - Restore Flux blockchain from bootstrap${NC}"
+ echo -e "${CYAN}6 - Create FluxNode installation config file${NC}"
+ echo -e "${CYAN}7 - Re-install FluxOS${NC}"
+ echo -e "${CYAN}8 - Flux Daemon Reconfiguration${NC}"
+ echo -e "${CYAN}9 - Create Flux daemon service${NC}"
+ echo -e "${CYAN}10 - Create Self-hosting cron ip service ${NC}"
+ echo -e "${CYAN}11 - FluxOS config management ${NC}"
+ echo -e "${CYAN}12 - MongoDB Repair Assistant${NC}"
+ echo -e "${CYAN}13 - Multinode configuration with UPNP communication (Needs Router with UPNP support)${NC}"
+ echo -e "${CYAN}14 - Node reconfiguration from install config${NC}"
+ echo -e "${CYAN}15 - Hardware benchmark${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+else
+ echo -e "${CYAN}1 - Re-install FluxOS${NC}"
+ echo -e "${CYAN}2 - Flux Daemon Reconfiguration${NC}"
+ echo -e "${CYAN}3 - FluxOS Config Management${NC}"
+ echo -e "${CYAN}4 - Restore Flux blockchain from bootstrap${NC}"
+ echo -e "${CYAN}5 - MongoDB Repair Assistant${NC}"
+ echo -e "${CYAN}6 - FluxNode Diagnostics${NC}"
+ echo -e "${CYAN}7 - Log Viewer${NC}"
+ echo -e "${CYAN}8 - Hardware benchmark${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+fi
read -rp "Pick an option and hit ENTER: "
-
- case "$REPLY" in
-
+case "$REPLY" in
1)
- clear
- sleep 1
- install_docker
+ clear
+ sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ install_docker
+ else
+ install_flux
+ fi
;;
2)
- clear
- sleep 1
- install_node
+ clear
+ sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ install_node
+ else
+ daemon_reconfiguration
+ fi
;;
3)
+ clear
+ sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ analyzer_and_fixer
+ else
+ fluxos_reconfiguration
+ fi
+ ;;
+ 4)
+ clear
+ sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ install_watchdog
+ else
+ flux_daemon_bootstrap
+ fi
+ ;;
+ 5)
+ clear
+ sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ flux_daemon_bootstrap
+ else
+ mongod_db_fix
+ fi
+ ;;
+ 6)
+ clear
+ sleep 1
+ if [[ -z $FLUXOS_VERSION ]]; then
+ create_config
+ else
+ analyzer_and_fixer
+ fi
+ ;;
+ 7)
clear
sleep 1
- analyzer_and_fixer
+ if [[ -z $FLUXOS_VERSION ]]; then
+ install_flux
+ else
+ bash -i "/usr/lib/multitoolbox/log_viewer.sh"
+ fi
;;
- 4)
+ 8)
clear
sleep 1
- install_watchdog
+ if [[ -z $FLUXOS_VERSION ]]; then
+ daemon_reconfiguration
+ else
+ echo -e "${GREEN}Module: Hardware benchmark${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ bash -i "/usr/lib/multitoolbox/hardwarebench.sh"
+ fi
;;
-
- 5)
+ 9)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
+ clear
+ sleep 1
+ echo -e "${GREEN}Module: Flux Daemon service creator${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ create_service_scripts
+ create_service "install"
+ echo -e ""
+ ;;
+ 10)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
clear
sleep 1
- mongodb_bootstrap
+ selfhosting_creator
;;
- 6)
+ 11)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
clear
sleep 1
- flux_daemon_bootstrap
- ;;
- 7)
+ fluxos_reconfiguration
+ echo -e ""
+ ;;
+ 12)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
clear
sleep 1
- create_config
+ mongod_db_fix
+ echo -e ""
;;
- 8)
+ 13)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
clear
sleep 1
- install_flux
+ multinode
+ echo -e ""
;;
- 9)
- clear
- sleep 1
- daemon_reconfiguration
-
+ 14)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
+ clear
+ sleep 1
+ echo -e "${GREEN}Module: Node reconfiguration from install config${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ node_reconfiguration
+ echo -e ""
;;
-
- 10)
- clear
- sleep 1
- kda_bootstrap
-
+ 15)
+ if [[ ! -z $FLUXOS_VERSION ]]; then
+ exit
+ fi
+ clear
+ sleep 1
+ echo -e "${GREEN}Module: Hardware benchmark${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+ bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/hardwarebench.sh)
;;
-
-# 8)
- #clear
- # sleep 1
- #install_kernel
-# ;;
-
- esac
+esac
+# USED FOR CLEANUP AT END OF SCRIPT
+unset ROOT_BRANCH
+unset BRANCH_ALREADY_REFERENCED
diff --git a/multitoolbox_testnet.sh b/multitoolbox_testnet.sh
new file mode 100755
index 00000000..768d75ed
--- /dev/null
+++ b/multitoolbox_testnet.sh
@@ -0,0 +1,1331 @@
+#!/bin/bash
+
+if ! [[ -z $1 ]]; then
+ if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then
+ export ROOT_BRANCH="$1"
+ export BRANCH_ALREADY_REFERENCED='1'
+ bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/multitoolbox_testnet.sh) $ROOT_BRANCH
+ unset ROOT_BRANCH
+ unset BRANCH_ALREADY_REFERENCED
+ exit
+ fi
+else
+ export ROOT_BRANCH='master'
+fi
+
+source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh)"
+
+
+BOOTSTRAP_ZIP='https://fluxnodeservice.com/daemon_bootstrap.tar.gz'
+BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz'
+BOOTSTRAP_URL_MONGOD='https://fluxnodeservice.com/mongod_bootstrap.tar.gz'
+BOOTSTRAP_ZIPFILE_MONGOD='mongod_bootstrap.tar.gz'
+KDA_BOOTSTRAP_ZIPFILE='kda_bootstrap.tar.gz'
+KDA_BOOTSTRAP_ZIP='http://202.61.207.10:16127/apps/fluxshare/getfile/kda_bootstrap.tar.gz?token=a705701758411b28ea20325ef9654e31e3d8f5f03a24b4e4e662e601a1250859'
+
+if [[ -d /home/$USER/.zelcash ]]; then
+ CONFIG_DIR='.zelcash'
+ CONFIG_FILE='zelcash.conf'
+
+else
+ CONFIG_DIR='.flux'
+ CONFIG_FILE='flux.conf'
+fi
+
+FLUX_DIR='zelflux'
+FLUX_APPS_DIR='ZelApps'
+COIN_NAME='zelcash'
+
+dversion="v6.1"
+
+PM2_INSTALL="0"
+zelflux_setting_import="0"
+
+
+
+function config_file() {
+
+if [[ -f /home/$USER/install_conf.json ]]; then
+import_settings=$(cat /home/$USER/install_conf.json | jq -r '.import_settings')
+ssh_port=$(cat /home/$USER/install_conf.json | jq -r '.ssh_port')
+firewall_disable=$(cat /home/$USER/install_conf.json | jq -r '.firewall_disable')
+bootstrap_url=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_url')
+bootstrap_zip_del=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_zip_del')
+swapon=$(cat /home/$USER/install_conf.json | jq -r '.swapon')
+mongo_bootstrap=$(cat /home/$USER/install_conf.json | jq -r '.mongo_bootstrap')
+watchdog=$(cat /home/$USER/install_conf.json | jq -r '.watchdog')
+use_old_chain=$(cat /home/$USER/install_conf.json | jq -r '.use_old_chain')
+prvkey=$(cat /home/$USER/install_conf.json | jq -r '.prvkey')
+outpoint=$(cat /home/$USER/install_conf.json | jq -r '.outpoint')
+index=$(cat /home/$USER/install_conf.json | jq -r '.index')
+zel_id=$(cat /home/$USER/install_conf.json | jq -r '.zelid')
+kda_address=$(cat /home/$USER/install_conf.json | jq -r '.kda_address')
+
+echo -e "${ARROW} ${YELLOW}Install config summary:"
+
+if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then
+echo -e "${PIN}${CYAN}Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+else
+
+if [[ "$import_settings" == "1" ]]; then
+echo -e "${PIN}${CYAN}Import settings from exist config files..........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+fi
+
+fi
+
+if [[ "$ssh_port" != "" ]]; then
+string_limit_check_mark_port "SSH port: $ssh_port ...................................................................." "SSH port: ${GREEN}$ssh_port ${CYAN}...................................................................."
+sleep 1
+fi
+
+if [[ "$firewall_disable" == "1" ]]; then
+echo -e "${PIN}${CYAN}Firewall disabled diuring installation...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+else
+echo -e "${PIN}${CYAN}Firewall enabled diuring installation............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+fi
+
+if [[ "$use_old_chain" == "1" ]]; then
+echo -e "${PIN}${CYAN}During re-installation old chain will be use....................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+
+else
+
+if [[ "$bootstrap_url" == "" ]]; then
+echo -e "${PIN}${CYAN}Use Flux Bootstrap from source build in scripts..................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+else
+echo -e "${PIN}${CYAN}Use Flux Bootstrap from own source...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+fi
+
+if [[ "$bootstrap_zip_del" == "1" ]]; then
+echo -e "${PIN}${CYAN}Remove Flux Bootstrap archive file...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+else
+echo -e "${PIN}${CYAN}Leave Flux Bootstrap archive file................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+fi
+
+fi
+
+if [[ "$swapon" == "1" ]]; then
+echo -e "${PIN}${CYAN}Create a file that will be used for swap.........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+fi
+
+#if [[ "$mongo_bootstrap" == "1" ]]; then
+#echo -e "${PIN}${CYAN}Use Bootstrap for MongoDB........................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+#fi
+
+if [[ "$watchdog" == "1" ]]; then
+echo -e "${PIN}${CYAN}Install watchdog.................................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1
+fi
+fi
+}
+
+
+function install_flux() {
+
+echo -e "${GREEN}Module: Re-install FluxOS${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+if [[ "$USER" == "root" || "$USER" == "ubuntu" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+fi
+
+ if pm2 -v > /dev/null 2>&1; then
+ pm2 del zelflux > /dev/null 2>&1
+ pm2 del flux > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ fi
+
+docker_check=$(docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
+resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
+mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
+
+if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then
+echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1
+echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1
+echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
+fi
+
+if [[ $docker_check != 0 ]]; then
+echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1
+echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
+sudo aa-remove-unknown && sudo service docker restart > /dev/null 2>&1 && sleep 2
+sleep 5
+#docker ps | grep -Eo "^[0-9a-z]{8,}\b" |
+docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" |
+while read line; do
+sudo docker stop $line > /dev/null 2>&1 && sleep 2
+sudo docker rm $line > /dev/null 2>&1 && sleep 2
+done
+fi
+
+if [[ $resource_check != 0 ]]; then
+echo -e "${ARROW} ${YELLOW}Detected locked resource...${NC}" && sleep 1
+echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}" && sleep 1
+df | egrep 'flux' | awk '{ print $1}' |
+while read line; do
+sudo umount -l $line && sleep 1
+done
+fi
+
+if [ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]; then
+
+ echo -e "${ARROW} ${CYAN}Importing setting...${NC}"
+ zel_id=$(grep -w zelid /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
+ WANIP=$(grep -w ipaddress /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*ipaddress: .//' | sed -e 's/.\{2\}$//')
+
+ echo -e "${PIN}${CYAN}Zel ID = ${GREEN}$zel_id${NC}" && sleep 1
+
+ KDA_A=$(grep -w kadena /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
+
+ if [[ "$KDA_A" != "" ]]; then
+
+ echo -e "${PIN}${CYAN}Kadena address = ${GREEN}$KDA_A${NC}" && sleep 1
+
+ fi
+
+
+ echo -e "${PIN}${CYAN}IP = ${GREEN}$WANIP${NC}" && sleep 1
+ echo
+ echo -e "${ARROW} ${CYAN}Removing any instances of Flux....${NC}"
+ sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 2
+ #sudo rm -rf zelflux > /dev/null 2>&1 && sleep 2
+ zelflux_setting_import="1"
+
+fi
+
+if [ -d /home/$USER/$FLUX_DIR ]; then
+
+ echo -e "${ARROW} ${CYAN}Removing any instances of Flux....${NC}"
+ #sudo rm -rf zelflux > /dev/null 2>&1 && sleep 2
+ sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 2
+
+fi
+
+echo -e "${ARROW} ${CYAN}Flux downloading...${NC}"
+git clone https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1 && sleep 2
+cd zelflux
+echo -e "${ARROW} ${YELLOW}Changing to test branch...${NC}"
+git checkout testnet > /dev/null 2>&1
+#git clone --single-branch --branch development https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1 && sleep 2
+
+if [ -d /home/$USER/$FLUX_DIR ]
+then
+
+if [[ -f /home/$USER/$FLUX_DIR/package.json ]]; then
+ current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
+else
+ string_limit_x_mark "Flux was not downloaded, run script again..........................................."
+ echo
+ exit
+fi
+
+string_limit_check_mark "Flux v$current_ver downloaded..........................................." "Flux ${GREEN}v$current_ver${CYAN} downloaded..........................................."
+else
+string_limit_x_mark "Flux was not downloaded, run script again..........................................."
+echo
+exit
+fi
+
+
+if [[ "$zelflux_setting_import" == "0" ]]; then
+
+ip_confirm
+
+while true
+ do
+ zel_id="$(whiptail --title "MULTITOOLBOX" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)"
+ if [ $(printf "%s" "$zel_id" | wc -c) -eq "34" ] || [ $(printf "%s" "$zel_id" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$zel_id") ]; then
+ string_limit_check_mark "Zel ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Zel ID is not valid try again..........................................."
+ sleep 2
+ fi
+
+ done
+
+
+ touch ~/$FLUX_DIR/config/userconfig.js
+ cat << EOF > ~/$FLUX_DIR/config/userconfig.js
+module.exports = {
+ initial: {
+ ipaddress: '${WANIP}',
+ zelid: '${zel_id}',
+ testnet: true
+ }
+ }
+EOF
+
+else
+
+if [[ "$KDA_A" != "" ]]; then
+
+ touch ~/$FLUX_DIR/config/userconfig.js
+ cat << EOF > ~/$FLUX_DIR/config/userconfig.js
+module.exports = {
+ initial: {
+ ipaddress: '${WANIP}',
+ zelid: '${zel_id}',
+ kadena: '${KDA_A}',
+ testnet: true,
+ }
+ }
+EOF
+
+else
+
+ touch ~/$FLUX_DIR/config/userconfig.js
+ cat << EOF > ~/$FLUX_DIR/config/userconfig.js
+module.exports = {
+ initial: {
+ ipaddress: '${WANIP}',
+ zelid: '${zel_id}',
+ testnet: true
+ }
+ }
+EOF
+
+fi
+
+fi
+
+if [[ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]]; then
+string_limit_check_mark "Flux configuration successfull..........................................."
+else
+string_limit_x_mark "Flux installation failed, missing config file..........................................."
+echo
+exit
+fi
+
+ if pm2 -v > /dev/null 2>&1; then
+
+ rm restart_zelflux.sh > /dev/null 2>&1
+ pm2 del flux > /dev/null 2>&1
+ pm2 del zelflux > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ echo -e "${ARROW} ${CYAN}Starting Flux....${NC}"
+ echo -e "${ARROW} ${CYAN}Flux loading will take 2-3min....${NC}"
+ echo
+ pm2 start /home/$USER/$FLUX_DIR/start.sh --restart-delay=60000 --max-restarts=40 --name flux --time > /dev/null 2>&1
+ pm2 save > /dev/null 2>&1
+ pm2 list
+
+ else
+
+ pm2_install()
+ if [[ "$PM2_INSTALL" == "1" ]]; then
+ echo -e "${ARROW} ${CYAN}Starting Flux....${NC}"
+ echo -e "${ARROW} ${CYAN}Flux loading will take 2-3min....${NC}"
+ echo
+ pm2 list
+ fi
+ fi
+
+}
+
+function create_config() {
+if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+fi
+
+echo -e "${GREEN}Module: Create FluxNode installation config file${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+
+if jq --version > /dev/null 2>&1; then
+sleep 0.2
+else
+echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}"
+sudo apt install jq -y > /dev/null 2>&1
+
+ if jq --version > /dev/null 2>&1
+ then
+ #echo -e "${ARROW} ${CYAN}Nodejs version: ${GREEN}$(node -v)${CYAN} installed${NC}"
+ string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................."
+ echo
+ else
+ #echo -e "${ARROW} ${CYAN}Nodejs was not installed${NC}"
+ string_limit_x_mark "JQ was not installed................................."
+ echo
+ exit
+ fi
+fi
+
+skip_zelcash_config='0'
+skip_bootstrap='0'
+
+if [[ -d /home/$USER/$CONFIG_DIR ]]; then
+
+ if whiptail --yesno "Would you like import old settings from daemon and Flux?" 8 65; then
+ import_settings='1'
+ skip_zelcash_config='1'
+ sleep 1
+ else
+ import_settings='0'
+ sleep 1
+ fi
+
+ if whiptail --yesno "Would you like use exist Flux chain?" 8 65; then
+ use_old_chain='1'
+ skip_bootstrap='1'
+ sleep 1
+ else
+ use_old_chain='0'
+ sleep 1
+ fi
+
+
+fi
+
+if [[ "$skip_zelcash_config" == "1" ]]; then
+prvkey=""
+outpoint=""
+index=""
+zelid=""
+kda_address=""
+else
+
+prvkey=$(whiptail --inputbox "Enter your FluxNode Identity Key from Zelcore" 8 65 3>&1 1>&2 2>&3)
+sleep 1
+outpoint=$(whiptail --inputbox "Enter your FluxNode Collateral Output TX ID from Zelcore" 8 72 3>&1 1>&2 2>&3)
+sleep 1
+index=$(whiptail --inputbox "Enter your FluxNode Output Index from Zelcore" 8 65 3>&1 1>&2 2>&3)
+sleep 1
+zel_id=$(whiptail --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)
+sleep 1
+KDA_A=$(whiptail --inputbox "Please enter your Kadena address from Zelcore" 8 85 3>&1 1>&2 2>&3)
+sleep 1
+KDA_C=$(whiptail --inputbox "Please enter your kadena chainid (0-19)" 8 85 3>&1 1>&2 2>&3)
+
+ if [[ "$KDA_A" == "" ]]; then
+ kda_address=""
+ else
+ kda_address="kadena:$KDA_A?chainid=$KDA_C"
+ fi
+
+fi
+
+ssh_port=$(whiptail --inputbox "Enter port you are using for SSH (default 22)" 8 65 3>&1 1>&2 2>&3)
+sleep 1
+
+
+pettern='^[0-9]+$'
+if [[ $ssh_port =~ $pettern ]] ; then
+sleep 1
+else
+echo -e "${ARROW} ${CYAN}SSH port must be integer.................................[${X_MARK}${CYAN}]${NC}"
+echo
+exit
+fi
+
+
+if whiptail --yesno "Would you like disable firewall diuring installation?" 8 65; then
+firewall_disable='1'
+sleep 1
+else
+firewall_disable='0'
+sleep 1
+fi
+
+
+if [[ "$skip_bootstrap" == "0" ]]; then
+
+if whiptail --yesno "Would you like use Flux bootstrap from script source?" 8 65; then
+bootstrap_url="$BOOTSTRAP_ZIP"
+sleep 1
+else
+bootstrap_url=$(whiptail --inputbox "Enter your Flux bootstrap URL" 8 65 3>&1 1>&2 2>&3)
+sleep 1
+fi
+
+if whiptail --yesno "Would you like keep bootstrap archive file localy?" 8 65; then
+bootstrap_zip_del='0'
+sleep 1
+else
+bootstrap_zip_del='1'
+sleep 1
+fi
+fi
+
+if whiptail --yesno "Would you like create swapfile?" 8 65; then
+swapon='1'
+sleep 1
+else
+swapon='0'
+sleep 1
+fi
+
+
+if whiptail --yesno "Would you like use mongod bootstrap file?" 8 65; then
+mongo_bootstrap='1'
+sleep 1
+else
+mongo_bootstrap='0'
+sleep 1
+fi
+
+
+if whiptail --yesno "Would you like install FluxNode watchdog?" 8 65; then
+watchdog='1'
+sleep 1
+else
+watchdog='0'
+sleep 1
+fi
+
+rm /home/$USER/install_conf.json > /dev/null 2>&1
+sudo touch /home/$USER/install_conf.json
+sudo chown $USER:$USER /home/$USER/install_conf.json
+ cat << EOF > /home/$USER/install_conf.json
+{
+ "import_settings": "${import_settings}",
+ "prvkey": "${prvkey}",
+ "outpoint": "${outpoint}",
+ "index": "${index}",
+ "zelid": "${zel_id}",
+ "kda_address": "${kda_address}",
+ "ssh_port": "${ssh_port}",
+ "firewall_disable": "${firewall_disable}",
+ "bootstrap_url": "${bootstrap_url}",
+ "bootstrap_zip_del": "${bootstrap_zip_del}",
+ "swapon": "${swapon}",
+ "mongo_bootstrap": "${mongo_bootstrap}",
+ "use_old_chain": "${use_old_chain}",
+ "watchdog": "${watchdog}"
+}
+EOF
+config_file
+echo
+
+
+
+}
+
+
+function install_watchdog() {
+
+if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+fi
+
+echo -e "${GREEN}Module: Install watchdog for FluxNode${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+if ! pm2 -v > /dev/null 2>&1
+then
+pm2_install
+ if [[ "$PM2_INSTALL" == "0" ]]; then
+ exit
+ fi
+echo -e ""
+fi
+
+echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
+pm2 del watchdog > /dev/null 2>&1
+pm2 save > /dev/null 2>&1
+sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
+
+echo -e "${ARROW} ${CYAN}Downloading...${NC}"
+cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1
+echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}"
+wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1
+mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
+sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
+echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}"
+cd watchdog && npm install > /dev/null 2>&1
+echo -e "${ARROW} ${CYAN}Creating config file....${NC}"
+
+
+#if whiptail --yesno "Would you like enable FluxOS auto update?" 8 60; then
+flux_update='1'
+#sleep 1
+#else
+##flux_update='0'
+#sleep 1
+#fi
+
+#if whiptail --yesno "Would you like enable Flux daemon auto update?" 8 60; then
+daemon_update='1'
+##sleep 1
+#else
+#daemon_update='0'
+##sleep 1
+#fi
+
+#if whiptail --yesno "Would you like enable Flux benchmark auto update?" 8 60; then
+bench_update='1'
+#sleep 1
+#else
+##bench_update='0'
+##sleep 1
+#fi
+
+#if whiptail --yesno "Would you like enable fix action (restart daemon, benchmark, mongodb)?" 8 75; then
+fix_action='1'
+#sleep 1
+#else
+#fix_action='0'
+##sleep 1
+#fi
+
+telegram_alert=0;
+discord=0;
+
+if whiptail --yesno "Would you like enable alert notification?" 8 60; then
+
+sleep 1
+
+whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60
+
+sleep 1
+
+CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \
+ "1" "Discord notification " ON \
+ "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 )
+
+if [ -z "$CHOICES" ]; then
+
+ echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}"
+ sleep 1
+ discord=0;
+ ping=0;
+ telegram_alert=0;
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ node_label=0;
+
+else
+ for CHOICE in $CHOICES; do
+ case "$CHOICE" in
+ "1")
+
+ discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3)
+ sleep 1
+
+ if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then
+
+ while true
+ do
+ ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3)
+ if [[ $ping == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "UserID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "UserID is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+ else
+ ping=0;
+ sleep 1
+ fi
+
+ ;;
+ "2")
+
+ telegram_alert=1;
+
+ while true
+ do
+ telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3)
+ if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then
+ string_limit_check_mark "Bot token is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Bot token is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+ while true
+ do
+ telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3)
+ if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then
+ string_limit_check_mark "Chat ID is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Chat ID is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+ ;;
+ esac
+ done
+fi
+
+ while true
+ do
+ node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3)
+ if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
+ string_limit_check_mark "Node name is valid..........................................."
+ break
+ else
+ string_limit_x_mark "Node name is not valid try again............................."
+ sleep 1
+ fi
+ done
+
+ sleep 1
+
+
+else
+
+ node_label=0;
+ discord=0;
+ ping=0;
+ telegram_alert=0;
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+ sleep 1
+fi
+
+
+if [[ $discord == 0 ]]; then
+ ping=0;
+fi
+
+
+if [[ $telegram_alert == 0 ]]; then
+ telegram_bot_token=0;
+ telegram_chat_id=0;
+fi
+
+
+if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then
+ index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ tx_from_file=$(grep -w zelnodeoutpoint /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
+ stak_info=$(curl -s -m 5 https://explorer.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '10000|25000|100000')
+
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -s -m 5 https://explorer.zelcash.online/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '10000|25000|100000')
+ fi
+fi
+
+if [[ $stak_info == ?(-)+([0-9]) ]]; then
+
+ case $stak_info in
+ "10000") eps_limit=90 ;;
+ "25000") eps_limit=180 ;;
+ "100000") eps_limit=300 ;;
+ esac
+
+else
+eps_limit=0;
+fi
+
+
+sudo touch /home/$USER/watchdog/config.js
+sudo chown $USER:$USER /home/$USER/watchdog/config.js
+ cat << EOF > /home/$USER/watchdog/config.js
+module.exports = {
+ label: '${node_label}',
+ tier_eps_min: '${eps_limit}',
+ zelflux_update: '${flux_update}',
+ zelcash_update: '${daemon_update}',
+ zelbench_update: '${bench_update}',
+ action: '${fix_action}',
+ ping: '${ping}',
+ web_hook_url: '${discord}',
+ telegram_alert: '${telegram_alert}',
+ telegram_bot_token: '${telegram_bot_token}',
+ telegram_chat_id: '${telegram_chat_id}'
+}
+EOF
+
+echo -e "${ARROW} ${CYAN}Starting watchdog...${NC}"
+pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
+pm2 save > /dev/null 2>&1
+if [[ -f /home/$USER/watchdog/watchdog.js ]]
+then
+current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
+#echo -e "${ARROW} ${CYAN}Watchdog ${GREEN}v$current_ver${CYAN} installed successful.${NC}"
+string_limit_check_mark "Watchdog v$current_ver installed..........................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed..........................................."
+else
+#echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}"
+string_limit_x_mark "Watchdog was not installed..........................................."
+fi
+echo
+}
+
+
+
+function flux_daemon_bootstrap() {
+
+ echo -e "${GREEN}Module: Restore Flux blockchain from bootstrap${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+
+ cd
+ echo -e "${NC}"
+ pm2 stop watchdog > /dev/null 2>&1 && sleep 2
+ echo -e "${ARROW} ${CYAN}Stopping Flux daemon service${NC}"
+ sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+
+ if [[ -e /home/$USER/$CONFIG_DIR/blocks ]] && [[ -e /home/$USER/$CONFIG_DIR/chainstate ]]; then
+ echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
+ rm -rf /home/$USER/$CONFIG_DIR/blocks /home/$USER/$CONFIG_DIR/chainstate /home/$USER/$CONFIG_DIR/determ_zelnodes
+ fi
+
+ BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+
+ echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}"
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+
+ echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}"
+
+ if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1
+ then
+ echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ printf '\e[A\e[K'
+ echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}"
+ rm -rf $BOOTSTRAP_ZIPFILE
+ fi
+
+ else
+ check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE"
+ fi
+
+ fi
+
+
+ if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then
+
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+ echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ fi
+
+ else
+
+ CHOICE=$(
+ whiptail --title "FLUXNODE INSTALLATION" --menu "Choose a method how to get bootstrap file" 10 47 2 \
+ "1)" "Download from source build in script" \
+ "2)" "Download from own source" 3>&2 2>&1 1>&3
+ )
+
+
+ case $CHOICE in
+ "1)")
+
+ DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height')
+ echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}"
+ echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
+ wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+
+
+
+ ;;
+ "2)")
+ BOOTSTRAP_ZIP="$(whiptail --title "Flux daemon bootstrap setup" --inputbox "Enter your URL (zip, tar.gz)" 8 72 3>&1 1>&2 2>&3)"
+ echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}"
+ BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}"
+
+ if [[ "$BOOTSTRAP_ZIPFILE" != *".zip"* ]]; then
+ BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz'
+ fi
+
+ wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress
+
+ if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then
+ echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}"
+ unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1
+ else
+ tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR"
+ sleep 2
+ fi
+ ;;
+ esac
+
+ fi
+
+
+ if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then
+ rm -rf $BOOTSTRAP_ZIPFILE
+ fi
+
+ sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2
+ NUM='35'
+ MSG1='Starting Flux daemon service...'
+ MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo -e "" && echo -e ""
+ pm2 start watchdog --watch > /dev/null 2>&1 && sleep 2
+}
+
+
+function install_node(){
+
+echo -e "${GREEN}Module: Install FluxNode${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+fi
+
+if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
+
+ echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}"
+ echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+fi
+
+
+if docker run hello-world > /dev/null 2>&1
+then
+echo -e ""
+else
+echo -e "${WORNING}${CYAN}Docker is not working correct or is not installed.${NC}"
+exit
+fi
+
+
+# bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro.sh)
+bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro_testnet.sh)
+
+
+}
+
+
+function install_docker(){
+
+echo -e "${GREEN}Module: Install Docker${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+if [[ "$USER" != "root" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the root account use command 'su -'.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+fi
+
+
+
+if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
+
+ echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}"
+ echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation"
+ echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
+ echo
+ exit
+
+fi
+
+if [[ -z "$usernew" ]]; then
+ usernew="$(whiptail --title "MULTITOOLBOX $dversion" --inputbox "Enter your username" 8 72 3>&1 1>&2 2>&3)"
+ usernew=$(awk '{print tolower($0)}' <<< "$usernew")
+else
+ echo -e "${PIN}${CYAN} Import docker user '$usernew' from environment variable............[${CHECK_MARK}${CYAN}]${NC}"
+fi
+echo -e "${ARROW} ${CYAN}New User: ${GREEN}${usernew}${NC}"
+adduser --gecos "" "$usernew"
+usermod -aG sudo "$usernew" > /dev/null 2>&1
+echo -e "${ARROW} ${YELLOW}Update and upgrade system...${NC}"
+apt update -y && apt upgrade -y
+if ! ufw version > /dev/null 2>&1
+then
+echo -e "${ARROW} ${YELLOW}Installing ufw firewall..${NC}"
+sudo apt-get install -y ufw > /dev/null 2>&1
+fi
+echo -e "${ARROW} ${YELLOW}Installing docker...${NC}"
+echo -e "${ARROW} ${CYAN}Architecture: ${GREEN}$(dpkg --print-architecture)${NC}"
+
+if [[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then
+ sudo rm /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
+fi
+
+if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
+ sudo rm /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
+fi
+
+
+if [[ $(lsb_release -d) = *Debian* ]]
+then
+
+sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
+sudo apt-get update -y > /dev/null 2>&1
+sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
+sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
+#curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - > /dev/null 2>&1
+#sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /dev/null 2>&1
+curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
+echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
+sudo apt-get update -y > /dev/null 2>&1
+sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
+
+else
+
+sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
+sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
+sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
+
+curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
+echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
+#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - > /dev/null 2>&1
+#sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /dev/null 2>&1
+sudo apt-get update -y > /dev/null 2>&1
+sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
+
+fi
+
+# echo -e "${YELLOW}Creating docker group..${NC}"
+# groupadd docker
+echo -e "${ARROW} ${YELLOW}Adding $usernew to docker group...${NC}"
+adduser "$usernew" docker
+echo -e "${NC}"
+echo -e "${YELLOW}=====================================================${NC}"
+echo -e "${YELLOW}Running through some checks...${NC}"
+echo -e "${YELLOW}=====================================================${NC}"
+
+if sudo docker run hello-world > /dev/null 2>&1
+then
+ echo -e "${CHECK_MARK} ${CYAN}Docker is installed${NC}"
+else
+ echo -e "${X_MARK} ${CYAN}Docker did not installed${NC}"
+fi
+
+if [[ $(getent group docker | grep "$usernew") ]]
+then
+ echo -e "${CHECK_MARK} ${CYAN}User $usernew is member of 'docker'${NC}"
+else
+ echo -e "${X_MARK} ${CYAN}User $usernew is not member of 'docker'${NC}"
+fi
+
+echo -e "${YELLOW}=====================================================${NC}"
+echo -e "${NC}"
+read -p "Would you like switch to user account Y/N?" -n 1 -r
+echo -e "${NC}"
+if [[ $REPLY =~ ^[Yy]$ ]]
+then
+su - $usernew
+fi
+
+}
+
+function daemon_reconfiguration()
+{
+
+echo -e "${GREEN}Module: Flux Daemon Reconfiguration${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+fi
+
+echo
+echo -e "${ARROW} ${YELLOW}Fill in all the fields that you want to replace${NC}"
+sleep 4
+skip_change='3'
+zelnodeprivkey="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)"
+sleep 1
+zelnodeoutpoint="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3)"
+sleep 1
+zelnodeindex="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Output Index usually a 0/1" 8 60 3>&1 1>&2 2>&3)"
+sleep 1
+#externalip="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode IP" 8 60 3>&1 1>&2 2>&3)"
+#sleep 1
+
+if [[ "$zelnodeprivkey" == "" ]]; then
+skip_change=$((skip_change-1))
+echo -e "${ARROW} ${CYAN}Replace FluxNode Identity skipped....................[${CHECK_MARK}${CYAN}]${NC}"
+fi
+
+if [[ "$zelnodeoutpoint" == "" ]]; then
+skip_change=$((skip_change-1))
+echo -e "${ARROW} ${CYAN}Replace FluxNode Collateral TX ID skipped ..................[${CHECK_MARK}${CYAN}]${NC}"
+fi
+
+if [[ "$zelnodeindex" == "" ]]; then
+skip_change=$((skip_change-1))
+echo -e "${ARROW} ${CYAN}Replace FluxNode Output Index skipped......................[${CHECK_MARK}${CYAN}]${NC}"
+fi
+
+#if [[ "$externalip" == "" ]]; then
+#skip_change=$((skip_change-1))
+#echo -e "${ARROW} ${CYAN}Replace FluxNode IP skipped.........................[${CHECK_MARK}${CYAN}]${NC}"
+#fi
+
+
+if [[ "$skip_change" == "0" ]]; then
+echo -e "${ARROW} ${YELLOW}All fields are empty changes skipped...${NC}"
+echo
+exit
+fi
+
+echo -e "${ARROW} ${CYAN}Stopping Flux daemon service...${NC}"
+sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2
+sudo fuser -k 16125/tcp > /dev/null 2>&1
+
+
+if [[ "$zelnodeprivkey" != "" ]]; then
+
+if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+echo -e "${ARROW} ${CYAN}Replace FluxNode privkey skipped....................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ sed -i "s/$(grep -e zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeprivkey=$zelnodeprivkey/" ~/$CONFIG_DIR/$CONFIG_FILE
+ if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}FluxNode privkey replaced successful................[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+fi
+
+fi
+
+if [[ "$zelnodeoutpoint" != "" ]]; then
+
+if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+echo -e "${ARROW} ${CYAN}Replace FluxNode outpoint skipped ..................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ sed -i "s/$(grep -e zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeoutpoint=$zelnodeoutpoint/" ~/$CONFIG_DIR/$CONFIG_FILE
+ if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}FluxNode outpoint replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+fi
+
+fi
+
+if [[ "$zelnodeindex" != "" ]]; then
+
+if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+echo -e "${ARROW} ${CYAN}Replace FluxNode index skipped......................[${CHECK_MARK}${CYAN}]${NC}"
+ else
+ sed -i "s/$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeindex=$zelnodeindex/" ~/$CONFIG_DIR/$CONFIG_FILE
+ if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e "${ARROW} ${CYAN}FluxNode index replaced successful..................[${CHECK_MARK}${CYAN}]${NC}"
+
+ fi
+fi
+
+fi
+
+#if [[ "$externalip" != "" ]]; then
+
+#if [[ "externalip=$externalip" == $(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+#echo -e "${ARROW} ${CYAN}Replace FluxNode IP skipped.........................[${CHECK_MARK}${CYAN}]${NC}"
+ # else
+ # sed -i "s/$(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE)/externalip=$externalip/" ~/$CONFIG_DIR/$CONFIG_FILE
+ #if [[ "externalip=$externalip" == $(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ # echo -e "${ARROW} ${CYAN}FluxNode IP replaced successful.....................[${CHECK_MARK}${CYAN}]${NC}"
+
+ # fi
+#fi
+#fi
+
+pm2 restart flux > /dev/null 2>&1
+sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2
+NUM='35'
+MSG1='Restarting daemon service...'
+MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}"
+spinning_timer
+echo -e "" && echo -e ""
+
+}
+
+
+ function update_binary(){
+
+ echo -e "${GREEN}Module: Update flux daemon and benchmark binary${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+
+
+ echo -e "${ARROW} ${CYAN}Stopping flux daemon..${NC}"
+ sudo systemctl stop zelcash > /dev/null 2>&1
+
+
+if [[ $(dpkg --print-architecture) = *amd* ]]; then
+
+ echo -e "${ARROW} ${CYAN}Downloading file...${NC}"
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Flux-amd64-v6.2.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Flux-amd64-v6.2.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1
+
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Fluxbench-Linux-v3.9.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Fluxbench-Linux-v3.9.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1
+ sudo rm -rf /tmp/flux* 2>&1 && sleep 2
+ sudo rm -rf /tmp/Flux* 2>&1 && sleep 2
+
+else
+
+ echo -e "${ARROW} ${CYAN}Downloading file...${NC}"
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Flux-arm-6.2.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Flux-arm-6.2.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1
+
+ sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Fluxbench-arm-v3.9.0.tar.gz -P /tmp > /dev/null 2>&1
+ sudo tar xzvf /tmp/Fluxbench-arm-v3.9.0.tar.gz -C /tmp > /dev/null 2>&1
+ sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1
+ sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1
+ sudo rm -rf /tmp/flux* 2>&1 && sleep 2
+ sudo rm -rf /tmp/Flux* 2>&1 && sleep 2
+
+
+fi
+
+ sudo chmod 755 $COIN_PATH/* > /dev/null 2>&1 && sleep 2
+ echo -e "${ARROW} ${CYAN}Starting flux daemon..${NC}"
+ echo ""
+ sudo systemctl start zelcash > /dev/null 2>&1
+
+ }
+
+
+ function mongod_db_fix() {
+ echo -e "${GREEN}Module: Recover corrupted MongoDB database${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+
+ if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user account.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
+ fi
+
+ echo -e ""
+ sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair
+
+ }
+
+
+if ! figlet -v > /dev/null 2>&1
+then
+sudo apt-get update -y > /dev/null 2>&1
+sudo apt-get install -y figlet > /dev/null 2>&1
+fi
+
+if ! pv -V > /dev/null 2>&1
+then
+sudo apt-get install -y pv > /dev/null 2>&1
+fi
+
+if ! gzip -V > /dev/null 2>&1
+then
+sudo apt-get install -y gzip > /dev/null 2>&1
+fi
+
+if ! zip -v > /dev/null 2>&1
+then
+sudo apt-get install -y zip > /dev/null 2>&1
+fi
+
+if ! whiptail -v > /dev/null 2>&1
+then
+sudo apt-get install -y whiptail > /dev/null 2>&1
+fi
+
+
+
+clear
+sleep 1
+echo -e "${BLUE}"
+figlet -f slant "Multitoolbox TESTNET"
+echo -e "${YELLOW}================================================================${NC}"
+echo -e "${GREEN}Version: $dversion${NC}"
+echo -e "${GREEN}Branch: ${ROOT_BRANCH}${NC}"
+echo -e "${GREEN}OS: Ubuntu 16/18/19/20, Debian 9/10 ${NC}"
+echo -e "${GREEN}Created by: X4MiLX from Flux's team${NC}"
+echo -e "${GREEN}Special thanks to dk808, CryptoWrench && jriggs28${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+echo -e "${CYAN}1 - Install Docker${NC}"
+echo -e "${CYAN}2 - Install FluxNode${NC}"
+echo -e "${CYAN}3 - Update flux daemon and benchmark binary${NC}"
+echo -e "${CYAN}4 - Install/Re-install FluxOS${NC}"
+echo -e "${CYAN}5 - Multinode configuration with UPNP communication (Needs Router with UPNP support) ${NC}"
+echo -e "${YELLOW}================================================================${NC}"
+
+read -rp "Pick an option and hit ENTER: "
+
+ case "$REPLY" in
+
+ 1)
+ clear
+ sleep 1
+ install_docker
+ ;;
+ 2)
+ clear
+ sleep 1
+ install_node
+ ;;
+ 3)
+ clear
+ sleep 1
+ update_binary
+ ;;
+ 4)
+ clear
+ sleep 1
+ install_flux
+ ;;
+ 5)
+ clear
+ sleep 1
+ multinode
+ ;;
+ esac
+
+# USED FOR CLEANUP AT END OF SCRIPT
+unset ROOT_BRANCH
+unset BRANCH_ALREADY_REFERENCED
diff --git a/nodeanalizerandfixer.sh b/nodeanalizerandfixer.sh
old mode 100644
new mode 100755
index a3800f9d..a29ab1b8
--- a/nodeanalizerandfixer.sh
+++ b/nodeanalizerandfixer.sh
@@ -1,5 +1,711 @@
#!/bin/bash
+if [[ -f "/usr/lib/multitoolbox/flux_common.sh" ]]; then
+ source "/usr/lib/multitoolbox/flux_common.sh"
+else
+ source /dev/stdin <<< "$(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh")"
+fi
+
+if [[ -n $FLUXOS_VERSION ]]; then
+ #const
+ REPLACE="0"
+ FLUXCONF="0"
+ FLUXRESTART="0"
+ ZELCONF="0"
+ BTEST="0"
+ LC_CHECK="0"
+ ZELFLUX_PORT1="0"
+ ZELFLUX_PORT2="0"
+ FLUX_UPDATE="0"
+ OWNER="0"
+ IP_FIX="0"
+ SCVESION=v4.0
+ FLUX_DIR='zelflux'
+ COIN_NAME='zelcash'
+ COIN_DAEMON='zelcashd'
+ BENCH_DIR_LOG='.zelbenchmark'
+ BENCH_DAEMON='zelbenchd'
+ BENCH_NAME='zelbench'
+ COIN_CLI='flux-cli -conf=/dat/var/lib/fluxd/flux.conf'
+ BENCH_CLI='fluxbench-cli'
+ CONFIG_FILE='flux.conf'
+ FLUXOS_PATH="/dat/usr/lib/fluxos"
+ FLUX_WATCHDOG_PATH="/dat/usr/lib/fluxwatchdog"
+ FLUX_DAEMON_PATH="/dat/var/lib/fluxd"
+ FLUX_BENCH_PATH="/dat/usr/lib/fluxbenchd"
+ DATA_PATH="/dat"
+ MONGODB_DATA_PATH="/dat/var/lib/mongodb"
+ MONGODB_LOG_PATH="/dat/var/log/mongodb"
+ FLUX_DAEMON_SERVICE="fluxd"
+ FLUX_APPS_FOLDER="/dat/var/lib/fluxos/flux-apps"
+
+
+ get_ip
+ #function
+ function show_time() {
+ num=$1
+ min=0
+ hour=0
+ day=0
+ if((num>59));then
+ ((sec=num%60))
+ ((num=num/60))
+ if((num>59));then
+ ((min=num%60))
+ ((num=num/60))
+ if((num>23));then
+ ((hour=num%24))
+ ((day=num/24))
+ else
+ ((hour=num))
+ fi
+ else
+ ((min=num))
+ fi
+ else
+ ((sec=num))
+ fi
+ echo -e "${PIN} ${CYAN}Last error was \c"
+ echo -e "${RED}$day"d "$hour"h "$min"m "$sec"s"${CYAN} ago.${NC}"
+ }
+ function check_listen_ports(){
+ if ! lsof -v > /dev/null 2>&1; then
+ sudo apt-get install lsof -y > /dev/null 2>&1 && sleep 1
+ fi
+
+ if [[ -f $FLUX_BENCH_PATH/fluxbench.conf ]]; then
+ FluxAPI=$(grep -Po "(?<=fluxport=)\d+" $FLUX_BENCH_PATH/fluxbench.conf)
+ FLUXOS_CONFIG=$(grep -Po "$FluxAPI" $FLUX_BENCH_PATH/fluxbench.conf)
+ if [[ "$FLUXOS_CONFIG" != "" ]]; then
+ FluxUI=$(($FluxAPI-1))
+ UPNP=1
+ else
+ FluxAPI=16127
+ FluxUI=16126
+ UPNP=0
+ fi
+ else
+ FluxAPI=16127
+ FluxUI=16126
+ UPNP=0
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep 27017 | grep mongod > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Mongod listen on port 27017${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Mongod not listen${NC}"
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep 16125 | grep fluxd > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
+ else
+ if sudo lsof -i -n | grep LISTEN | grep 16125 | grep zelcashd > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux daemon not listen${NC}"
+ fi
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep 16224 | grep bench > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux benchmark listen on port 16224${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux benchmark not listen${NC}"
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep $FluxUI | grep node > /dev/null 2>&1; then
+ ZELFLUX_PORT1="1"
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep $FluxAPI | grep node > /dev/null 2>&1 ; then
+ ZELFLUX_PORT2="1"
+ fi
+ if [[ "$ZELFLUX_PORT1" == "1" && "$ZELFLUX_PORT2" == "1" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux listen on ports $FluxUI/$FluxAPI ${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux not listen${NC}"
+ fi
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}FluxOS networking: ${NC}"
+
+ output=$(upnpc -l 2>&1)
+ if echo "$output" | egrep -q "No IGD UPnP Device found|No UPnP-enabled devices|No valid UPNP Internet Gateway Device found"; then
+ echo -e "${PIN} ${CYAN}UPnP STATUS: ${RED}DISABLED${NC}"
+ else
+ echo -e "${PIN} ${CYAN}UPnP STATUS: ${GREEN}ENABLED${NC}"
+ fi
+ echo -e "${PIN} ${CYAN}FluxAPI PORT: ${ORANGE}$FluxAPI ${NC}"
+ echo -e "${PIN} ${CYAN}FluxUI PORT: ${ORANGE}$FluxUI ${NC}"
+
+ error_check=$(sudo journalctl -u fluxos.service -b -n 25 | grep "Deactivated successfully")
+ if [[ "$error_check" != "" ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Checking FluxOS logs... ${NC}"
+ echo -e "${WORNING} ${RED}Problem with UPnP detected, FluxOS Shutting down..."
+ echo -e ""
+ fi
+
+ }
+ function get_last_benchmark(){
+ if [[ "$2" == "check" ]]; then
+ info_check=$(sudo grep 'Found' $FLUX_BENCH_PATH/debug.log | egrep 'Found|Historical' | grep $1 | tail -n1 | egrep -o '[0-9]+(\.[0-9]+)|([0-9]+)' | tail -n1 | awk '{printf "%.2f\n", $1}')
+ if [[ "$info_check" == "" ]]; then
+ skipp_debug=1
+ return 1
+ fi
+ fi
+ if [[ "$1" == "cores" ]]; then
+ cores=$(sudo grep 'Found' $FLUX_BENCH_PATH/debug.log | egrep 'Found|Historical' | grep 'cores' | tail -n1 | egrep -Eo '[^ ]+$')
+ echo -e "${PIN}${CYAN} CORES: ${GREEN}$cores${NC}"
+ fi
+
+ if [[ "$1" == "HDD" || "$1" == "DD_WRITE" || "$1" == "ram" || "$1" == "eps" ]] && [[ "$2" != "check" ]]; then
+
+ info=$(sudo grep 'Found' $FLUX_BENCH_PATH/debug.log | egrep 'Found|Historical' | grep $1 | tail -n1 | egrep -o '[0-9]+(\.[0-9]+)|([0-9]+)' | tail -n1 | awk '{printf "%.2f\n", $1}')
+
+ if [[ "$1" == "ram" ]]; then
+ echo -e "${PIN}${CYAN} RAM: ${GREEN}$info${NC}"
+ fi
+
+ if [[ "$1" == "eps" ]]; then
+ echo -e "${PIN}${CYAN} EPS: ${GREEN}$info${NC}"
+ fi
+
+ if [[ "$1" == "DD_WRITE" ]]; then
+ echo -e "${PIN}${CYAN} DD_WRITE: ${GREEN}$info${NC}"
+ fi
+
+ if [[ "$1" == "HDD" ]]; then
+ echo -e "${PIN}${CYAN} HDD: ${GREEN}$info${NC}"
+ fi
+ fi
+ }
+ function integration(){
+ PATH_TO_FOLDER=( /usr/local/bin/ )
+ if [[ -f /usr/local/bin/fluxd ]]; then
+ FILE_ARRAY=( 'fluxbench-cli' 'fluxbenchd' 'flux-cli' 'fluxd' )
+ else
+ FILE_ARRAY=( 'zelbench-cli' 'zelbenchd' 'zelcash-cli' 'zelcashd' 'zelcash-fetch-params.sh' 'zelcash-tx' )
+ fi
+ ELEMENTS=${#FILE_ARRAY[@]}
+ NOT_FOUND="0"
+ for (( i=0;i<$ELEMENTS;i++)); do
+ if [ -f $PATH_TO_FOLDER${FILE_ARRAY[${i}]} ]; then
+ echo -e "${CHECK_MARK} ${CYAN} ${FILE_ARRAY[${i}]}"
+ else
+ echo -e "${X_MARK} ${CYAN} ${FILE_ARRAY[${i}]}"
+ NOT_FOUND="1"
+ fi
+ done
+ }
+
+ sleep 1
+ if ! bc -v > /dev/null 2>&1 ; then
+ sudo apt install -y bc > /dev/null 2>&1 && sleep 1
+ fi
+ echo -e "${NC}"
+ MOUNT_CHECK=$(df | grep "/dat")
+ BOOT_ID=$(sudo cat /proc/sys/kernel/random/boot_id)
+ LOG_FILE="/var/log/sas.log"
+ LAST_LOG_LINE=$(grep -n "\"boot_id\":\"$BOOT_ID\"" "$LOG_FILE" | grep -E '"level":[5-9][0-9]' | tail -n 1 | cut -d: -f1)
+ if [[ -n "$LAST_LOG_LINE" && $MOUNT_CHECK == "" ]]; then
+ START_LINE=$((LAST_LOG_LINE - 10))
+ if [[ $START_LINE -lt 1 ]]; then
+ START_LINE=1
+ fi
+ echo -e "${WORNING} ${CYAN}Flux System Attestation Service (SAS) error detected! ${NC}"
+ echo -e "${PIN} ${CYAN}Log file: /var/log/sas.log ${NC}"
+ echo -e "${BOOK} ${CYAN}Last error and 10 prior entries for the current boot ${NC}"
+ echo -e "---------------------------------------------------------------------"
+ sed -n "${START_LINE},${LAST_LOG_LINE}p" "$LOG_FILE" | pino-pretty --colorize --translateTime 'dd-mm-yyyy HH:MM:ss'
+ echo -e ""
+ exit
+ fi
+
+ if [[ "$($BENCH_CLI getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
+ echo -e "${BOOK} ${YELLOW}Flux benchmark status:${NC}"
+ bench_getatus=$($BENCH_CLI getstatus)
+ bench_status=$(jq -r '.status' <<< "$bench_getatus")
+ bench_benchmark=$(jq -r '.benchmarking' <<< "$bench_getatus")
+ bench_back=$(jq -r '.zelback' <<< "$bench_getatus")
+ bench_systemsecure=$(jq -r '.systemsecure' <<< "$bench_getatus")
+
+ if [[ "$bench_back" == "null" ]]; then
+ bench_back=$(jq -r '.flux' <<< "$bench_getatus")
+ fi
+
+ bench_getinfo=$($BENCH_CLI getinfo)
+ bench_version=$(jq -r '.version' <<< "$bench_getinfo")
+
+ if [[ "$bench_benchmark" == "failed" || "$bench_benchmark" == "toaster" ]]; then
+ bench_benchmark_color="${RED}$bench_benchmark"
+ else
+ bench_benchmark_color="${SEA}$bench_benchmark"
+ fi
+
+ if [[ "$bench_status" == "online" ]]; then
+ bench_status_color="${SEA}$bench_status"
+ else
+ bench_status_color="${RED}$bench_status"
+ fi
+
+ if [[ "$bench_back" == "connected" ]]; then
+ bench_back_color="${SEA}$bench_back"
+ else
+ bench_back_color="${RED}$bench_back"
+ fi
+
+ if [[ "$bench_systemsecure" == "true" ]]; then
+ bench_systemsecure_color="${SEA}$bench_systemsecure"
+ else
+ bench_systemsecure_color="${RED}$bench_systemsecure"
+ fi
+
+ echo -e "${PIN} ${CYAN}Flux system secure: ${SEA}$bench_systemsecure_color${NC}"
+ echo -e "${PIN} ${CYAN}Flux benchmark version: ${SEA}$bench_version${NC}"
+ echo -e "${PIN} ${CYAN}Flux benchmark status: $bench_status_color${NC}"
+ echo -e "${PIN} ${CYAN}Benchmark: $bench_benchmark_color${NC}"
+ echo -e "${PIN} ${CYAN}Flux: $bench_back_color${NC}"
+ echo -e "${NC}"
+
+ if [[ "$bench_benchmark" == "running" ]]; then
+ echo -e "${ARROW} ${CYAN} Benchmarking hasn't completed, please wait until benchmarking has completed.${NC}"
+ fi
+
+ if [[ "$bench_benchmark" == "CUMULUS" || "$bench_benchmark" == "NIMBUS" || "$bench_benchmark" == "STRATUS" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux benchmark working correct, all requirements met.${NC}"
+ fi
+
+ if [[ "$bench_benchmark" == "failed" ]]; then
+ echo -e "${X_MARK} ${CYAN} Flux benchmark problem detected, check benchmark debug.log${NC}"
+ fi
+
+ core=$($BENCH_CLI getbenchmarks | jq '.cores')
+ if [[ "$bench_benchmark" == "failed" && "$core" > "0" ]]; then
+ BTEST="1"
+ echo -e "${X_MARK} ${CYAN} Flux benchmark working correct but minimum system requirements not met.${NC}"
+ #check_benchmarks "eps" "89.99" " CPU speed" "< 90.00 events per second"
+ #check_benchmarks "ddwrite" "159.99" " Disk write speed" "< 160.00 events per second"
+ fi
+
+ if [[ "$bench_back" == "disconnected" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxBack does not work properly${NC}"
+ if [[ "$WANIP" != "" ]]; then
+ back_error_check=$(curl -s -m 5 http://$WANIP:$FluxAPI/zelid/loginphrase | jq -r .status )
+ if [[ "$back_error_check" != "success" && "$back_error_check" != "" ]]; then
+ back_error=$(curl -s -m 8 http://$WANIP:$FluxAPI/zelid/loginphrase | jq -r .data.message.message 2>/dev/null )
+ if [[ "$back_error" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxBack error: ${RED}$back_error${NC}"
+ else
+ back_error=$(curl -s -m 8 http://$WANIP:$FluxAPI/zelid/loginphrase | jq -r .data.message 2>/dev/null )
+ if [[ "$back_error" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxBack error: ${RED}$back_error${NC}"
+ fi
+ fi
+ fi
+ fi
+ #device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}')
+ #local_device_ip=$(ip a list $device_name | grep -o $WANIP )
+ #if [[ "$WANIP" != "" ]]; then
+ #if [[ "$local_device_ip" == "$WANIP" ]]; then
+ #echo -e "${CHECK_MARK} ${CYAN} Public IP(${GREEN}$WANIP${CYAN}) matches local device(${GREEN}$device_name${CYAN}) IP(${GREEN}$local_device_ip${CYAN})${NC}"
+ #else
+ #echo -e "${X_MARK} ${CYAN} Public IP(${GREEN}$WANIP${CYAN}) not matches local device(${GREEN}$device_name${CYAN}) IP${NC}"
+ #echo -e "${ARROW} ${CYAN} If you under NAT use option 10 from multitoolbox (self-hosting)${NC}"
+ ## dev_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2"0"}')
+ ## sudo ip addr add "$WANPI" dev "$dev_name"
+ # IP_FIX="1"
+ #fi
+ #else
+ #echo -e "${ARROW} ${CYAN} Local device(${GREEN}$device_name${CYAN}) IP veryfication failed...${NC}"
+ #fi
+ fi
+ echo -e "${NC}"
+ fi
+ if [[ "$($COIN_CLI getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
+ echo -e "${BOOK} ${YELLOW}Flux deamon information:${NC}"
+ daemon_getinfo=$($COIN_CLI getinfo)
+ version=$(jq -r '.version' <<< "$daemon_getinfo")
+ blocks_hight=$(jq -r '.blocks' <<< "$daemon_getinfo")
+ protocolversion=$(jq -r '.protocolversion' <<< "$daemon_getinfo")
+ connections=$(jq -r '.connections' <<< "$daemon_getinfo")
+ error=$(jq -r '.error' <<< "$daemon_getinfo")
+ if [[ "$error" != "" && "$error" != null ]]; then
+ echo
+ echo -e "${X_MARK} ${CYAN} Flux daemon error detected: ${RED}$error${CYAN}) IP${NC}"
+ fi
+ echo -e "${PIN} ${CYAN}Version: ${SEA}$version${NC}"
+ echo -e "${PIN} ${CYAN}Protocolversion: ${SEA}$protocolversion${NC}"
+ echo -e "${PIN} ${CYAN}Connections: ${SEA}$connections${NC}"
+ echo -e "${PIN} ${CYAN}Blocks: ${SEA}$blocks_hight${NC}"
+ network_height_01=$(curl -sk -m 5 https://$network_url_1/api/status?q=getInfo getinfo 2>/dev/null | jq '.info.blocks' 2> /dev/null)
+ network_height_02=$(curl -sk -m 5 https://$network_url_2/api/status?q=getInfo getinfo 2>/dev/null | jq '.info.blocks' 2> /dev/null)
+ explorer_network_hight=$(max "$network_height_01" "$network_height_02")
+ block_diff=$((explorer_network_hight-blocks_hight))
+ if [[ "$explorer_network_hight" != "0" ]]; then
+ if [[ "$block_diff" < 10 ]]; then
+ echo -e "${PIN} ${CYAN}Status: ${GREEN}synced${NC}"
+ else
+ echo -e "${PIN} ${CYAN}Status: ${RED}not synced${NC}"
+ fi
+ else
+ echo -e "${PIN} ${CYAN}Info: ${RED}sync check skipped...${NC}"
+ fi
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking node status:${NC}"
+ getzelnodestatus=$($COIN_CLI getzelnodestatus)
+ node_status=$(jq -r '.status' <<< "$getzelnodestatus")
+ collateral=$(jq -r '.collateral' <<< "$getzelnodestatus")
+ if [[ "$node_status" == "CONFIRMED" ]]; then
+ node_status_color="${SEA}$node_status"
+ elif [[ "$node_status" == "STARTED" ]];then
+ node_status_color="${YELLOW}$node_status"
+ else
+ node_status_color="${RED}$node_status"
+ fi
+ echo -e "${PIN} ${CYAN}Node status: $node_status_color${NC}"
+ if [[ "$node_status" == "DOS" ]]; then
+ blocks_till=$($COIN_CLI getdoslist | jq .[] | grep "$collateral" -A5 -B1 | jq .eligible_in)
+ dos_till=$((blocks_hight+blocks_till))
+ echo -e "${PIN} ${RED}DOS ${CYAN}Till: ${ORANGE}$dos_till ${CYAN}EXPIRE_COUNT: ${ORANGE}$blocks_till${CYAN} Time left: ${RED}~$((2*blocks_till)) min. ${NC}"
+ fi
+ echo -e "${PIN} ${CYAN}Collateral: ${SEA}$collateral${NC}"
+ echo -e ""
+ flux_communication=$(curl -SsL -m 10 http://"$WANIP":"$FluxAPI"/flux/checkcommunication 2>/dev/null | jq -r .data.message 2>/dev/null)
+ if [[ "$flux_communication" != "null" && "$flux_communication" != "" ]]; then
+ echo -e "${BOOK} ${YELLOW}Checking FluxOS communication: ${NC}"
+ echo -e "${ARROW} ${CYAN}$flux_communication${NC}"
+ echo -e ""
+ fi
+ if [[ "$explorer_network_hight" != "0" ]]; then
+ echo -e "${BOOK} ${YELLOW}Checking collateral:${NC}"
+ txhash=$(grep -o "\w*" <<< "$collateral")
+ txhash=$(sed -n "2p" <<< "$txhash")
+ txhash=$(egrep "\w{10,50}" <<< "$txhash")
+ if [[ "$txhash" != "" ]]; then
+ stak_info=""
+
+ if [[ -f $FLUX_DAEMON_PATH/flux.conf ]]; then
+ index_from_file=$(grep -w zelnodeindex $FLUX_DAEMON_PATH/flux.conf | sed -e 's/zelnodeindex=//')
+ stak_info=$(curl -s -m 10 https://$network_url_1/api/tx/$txhash 2>/dev/null | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2>/dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -s -m 10 https://$network_url_2/api/tx/$txhash 2>/dev/null | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2>/dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ fi
+ fi
+
+ if [[ "$stak_info" != "" ]]; then
+ type=$(awk '{print $1}' <<< "$stak_info")
+ conf=$($COIN_CLI gettxout $txhash $index_from_file | jq .confirmations)
+ if [[ $conf == ?(-)+([0-9]) ]]; then
+ if [ "$conf" -ge "100" ]; then
+ echo -e "${CHECK_MARK} ${CYAN} Confirmations numbers >= 100($conf)${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Confirmations numbers < 100($conf)${NC}"
+ fi
+ else
+ echo -e "${X_MARK} ${CYAN} FluxNode outpoint is not valid${NC}"
+ fi
+ if [[ $type == ?(-)+([0-9]) ]]; then
+ case $type in
+ "1000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}CUMULUS${NC}" ;;
+ "12500") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}NIMBUS${NC}";;
+ "40000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}STRATUS${NC}";;
+ esac
+ case $bench_benchmark in
+ "CUMULUS") bench_benchmark_value=1000 ;;
+ "NIMBUS") bench_benchmark_value=12500 ;;
+ "STRATUS") bench_benchmark_value=40000 ;;
+ esac
+ if [[ -z bench_benchmark_value ]]; then
+ echo -e ""
+ else
+ if [[ "$bench_benchmark_value" -ge "$type" ]]; then
+ case $type in
+ "1000") bench_benchmark_value_name="CUMULUS" ;;
+ "12500") bench_benchmark_value_name="NIMBUS" ;;
+ "40000") bench_benchmark_value_name="STRATUS" ;;
+ esac
+ else
+ case $type in
+ "1000") bench_benchmark_value_name="CUMULUS" ;;
+ "12500") bench_benchmark_value_name="NIMBUS" ;;
+ "40000") bench_benchmark_value_name="STRATUS" ;;
+ esac
+ if [[ "$bench_benchmark" == "running" ]]; then
+ echo -en ""
+ else
+ echo -en ""
+ fi
+ fi
+ fi
+ fi
+ else
+ echo -e "${X_MARK} ${CYAN} Flux collateral check skipped...${NC}"
+ fi
+ #url_to_check="https://explorer.zel.cash/api/tx/$txhash"
+ #type=$(wget -nv -qO - $url_to_check | jq '.vout' | grep '"value"' | egrep -o '10000|25000|100000')
+ #type=$(zelcash-cli gettxout $txhash 0 | jq .value)
+ fi
+ fi
+ fi
+
+ echo -e "${NC}"
+ echo -e "${BOOK} ${YELLOW}Checking listen ports:${NC}"
+ check_listen_ports
+ echo -e "${NC}"
+ echo -e "${BOOK} ${YELLOW}Files integrity checking:${NC}"
+ integration
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking service:${NC}"
+ docker_working=0
+ docker_running=$(sudo systemctl status docker 2> /dev/null | grep 'running' | grep -o 'since.*')
+ docker_inactive=$(sudo systemctl status docker 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
+ mongod_running=$(sudo systemctl status mongod 2> /dev/null | grep 'running' | grep -o 'since.*')
+ mongod_inactive=$(sudo systemctl status mongod 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
+ daemon_running=$(sudo systemctl status fluxd 2> /dev/null | grep 'running' | grep -o 'since.*')
+ daemon_inactive=$(sudo systemctl status fluxd 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
+ fluxos_running=$(sudo systemctl status fluxos 2> /dev/null | grep 'running' | grep -o 'since.*')
+ fluxos_inactive=$(sudo systemctl status fluxos 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
+ fluxwatchdog_running=$(sudo systemctl status flux-watchdog 2> /dev/null | grep 'running' | grep -o 'since.*')
+ fluxwatchdog_inactive=$(sudo systemctl status flux-watchdog 2> /dev/null | egrep 'inactive|failed')
+ fluxwatchdog_awaiting=$(sudo systemctl status flux-watchdog 2> /dev/null | egrep 'inactive')
+ syncthing_running=$(sudo systemctl status syncthing 2> /dev/null | grep 'running' | grep -o 'since.*')
+ syncthing_inactive=$(sudo systemctl status syncthingg 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
+
+ if sudo systemctl list-units | grep docker.service | egrep -wi 'running' > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN}Docker service running ${SEA}$docker_running${NC}"
+ #docker_working=1
+ else
+ if [[ "$docker_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN}Docker service not running ${RED}$docker_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN}Docker is not installed${NC}"
+ fi
+ fi
+ verifity_mongod=0
+ if sudo systemctl list-units | grep mongod | egrep -wi 'running' > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} MongoDB service running ${SEA}$mongod_running${NC}"
+ else
+ if [[ "$mongod_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} MongoDB service not running ${RED}$mongod_inactive${NC}"
+ verifity_mongod=1
+ else
+ echo -e "${X_MARK} ${CYAN} MongoDB service is not installed${NC}"
+ fi
+ fi
+
+ if sudo systemctl list-units | grep fluxd | egrep -wi 'running' > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux daemon service running ${SEA}$daemon_running${NC}"
+ else
+ if [[ "$daemon_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} Flux daemon service not running ${RED}$daemon_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux daemon service is not installed${NC}"
+ fi
+ fi
+
+ if sudo systemctl list-units | grep fluxos | egrep -wi 'running' > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxOS service running ${SEA}$fluxos_running${NC}"
+ else
+ if [[ "$fluxos_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxOS service not running ${RED}$fluxos_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} FluxOS service is not installed${NC}"
+ fi
+ fi
+
+ if sudo systemctl list-units | grep syncthing | egrep -wi 'running' > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Syncthing service running ${SEA}$syncthing_running${NC}"
+ else
+ if [[ "$syncthing_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} Syncthing service not running ${RED}$syncthing_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Syncthing service is not installed${NC}"
+ fi
+ fi
+
+ if sudo systemctl list-units | grep 'flux-watchdog' | egrep -wi 'running' > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux-watchdog service running ${SEA}$fluxwatchdog_running${NC}"
+ else
+ if [[ "$fluxwatchdog_inactive" != "" || "$fluxwatchdog_awaiting" != "" ]]; then
+ if [[ -n $fluxwatchdog_inactive ]]; then
+ echo -e "${X_MARK} ${CYAN} Flux-watchdog service not running ${RED}$fluxwatchdog_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux-watchdog service awaiting...${NC}"
+ fi
+ else
+ echo -e "${X_MARK} ${CYAN} Flux-watchdog service is not installed${NC}"
+ fi
+ fi
+
+ echo -e ""
+
+ if [[ $(curl -s -m 5 --head "$WANIP:$FluxUI" | head -n 1 | grep "200 OK") ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxOS front is working${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} FluxOS front is not working${NC}"
+ fi
+
+
+ if [ -f $FLUX_BENCH_PATH/debug.log ]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking Flux benchmark $FLUX_BENCH_PATH/debug.log${NC}"
+ if [[ $(sudo egrep -ac -wi --color 'Failed' $FLUX_BENCH_PATH/debug.log) != "0" ]]; then
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(sudo egrep -ac --color 'Failed' $FLUX_BENCH_PATH/debug.log)${CYAN} error events${NC}"
+ #egrep -wi --color 'warning|error|critical|failed' ~/.zelbenchmark/debug.log
+ error_line=$(sudo egrep -a --color 'Failed' $FLUX_BENCH_PATH/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ event_date=$(sudo egrep -a --color 'Failed' $FLUX_BENCH_PATH/debug.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}')
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_time_uxtime=$(date -ud "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ event_time="$event_time_uxtime"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time))
+ show_time "$tdiff"
+ echo -e "${PIN} ${CYAN}Creating Flux benchmark_debug_error.log${NC}"
+ sudo egrep -a --color 'Failed' $FLUX_BENCH_PATH/debug.log > /tmp/benchmark_debug_error.log
+ echo -e ""
+ else
+ echo -e "${GREEN}\xF0\x9F\x94\x8A ${CYAN}Found: ${GREEN}0 errors${NC}"
+ echo -e ""
+ fi
+ skipp_debug=0
+ get_last_benchmark "HDD" "check"
+ if [[ "$skipp_debug" == "0" ]]; then
+ echo -e "${BOOK} ${YELLOW}Last benchmark from $FLUX_BENCH_PATH/debug.log${NC}"
+ get_last_benchmark "HDD"
+ get_last_benchmark "DD_WRITE"
+ get_last_benchmark "ram"
+ get_last_benchmark "cores"
+ echo -e ""
+ fi
+ fi
+ if [ -f $FLUX_DAEMON_PATH/debug.log ]; then
+ echo -e "${BOOK} ${YELLOW}Checking Flux daemon $FLUX_DAEMON_PATH/debug.log${NC}"
+ if [[ $(sudo egrep -ac -wi --color 'error|failed' $FLUX_DAEMON_PATH/debug.log) != "0" ]]; then
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(sudo egrep -ac -wi --color 'error|failed' $FLUX_DAEMON_PATH/debug.log)${CYAN} error events, ${RED}$(sudo egrep -ac -wi --color 'benchmarking' $FLUX_DAEMON_PATH/debug.log) ${CYAN}related to benchmark${NC}"
+ if [[ $(sudo egrep -ac -wi --color 'benchmarking' $FLUX_DAEMON_PATH/debug.log) != "0" ]]; then
+ echo -e "${BOOK} ${CYAN}FluxBench errors info:${NC}"
+ error_line=$(sudo egrep -a --color 'benchmarking' $FLUX_DAEMON_PATH/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ event_date=$(sudo egrep -a --color 'benchmarking' $FLUX_DAEMON_PATH/debug.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}')
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_time_uxtime=$(date -ud "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ event_time="$event_time_uxtime"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time))
+ show_time "$tdiff"
+ fi
+ echo -e "${PIN} ${CYAN}Creating flux_daemon_debug_error.log${NC}"
+ sudo egrep -a --color 'error|failed' $FLUX_DAEMON_PATH/debug.log > /tmp/flux_daemon_debug_error.log
+ echo -e ""
+ else
+ echo -e "${GREEN}\xF0\x9F\x94\x8A ${CYAN}Found: ${GREEN}0 errors${NC}"
+ echo -e ""
+ fi
+ fi
+
+ if [[ -d $FLUXOS_PATH ]]; then
+ FILE=$FLUXOS_PATH/config/userconfig.js
+ if [[ -f "$FILE" ]]; then
+ current_ver=$(jq -r '.version' $FLUXOS_PATH/package.json)
+ required_ver=$(curl -sS --max-time 10 https://raw.githubusercontent.com/RunOnFlux/flux/master/package.json | jq -r '.version')
+ if [[ "$required_ver" != "" ]]; then
+ if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
+ echo -e "${CHECK_MARK} ${CYAN} You have the current version of FluxOS ${GREEN}(v$required_ver)${NC}"
+ else
+ echo -e "${HOT} ${CYAN}New version of FluxOS available ${SEA}$required_ver${NC}"
+ FLUX_UPDATE="1"
+ fi
+ fi
+ echo -e "${CHECK_MARK} ${CYAN} FluxOS config $FLUXOS_PATH/config/userconfig.js exists${NC}"
+ ZELIDLG=`echo -n $(grep -w zelid $FLUXOS_PATH/config/userconfig.js | sed -e "s/'//g" | sed -e "s/,//g" | sed -e "s/.*zelid://g") | wc -m`
+ if [[ "$ZELIDLG" -eq "35" || "$ZELIDLG" -eq "34" || "$ZELIDLG" -eq "33" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux ID is valid${NC}"
+ elif [[ "$ZELIDLG" == "0" || "$ZELIDLG" == "2" ]]; then
+ echo -e "${X_MARK} ${CYAN} Flux ID is missing...${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux ID is not valid${NC}"
+ fi
+
+ if [[ -f $FLUXOS_PATH/error.log ]]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}FluxOS error.log file detected, check $FLUXOS_PATH/error.log"
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(wc -l < $FLUXOS_PATH/error.log)${CYAN} error events${NC}"
+ error_line=$(cat $FLUXOS_PATH/error.log | grep 'Error' | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{3\}Z//' | xargs)
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_date=$(cat $FLUXOS_PATH/error.log | grep 'Error' | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{3\}Z')
+ event_time_uxtime=$(date -d "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time_uxtime))
+ show_time "$tdiff"
+ fi
+ else
+ FLUXCONF="1"
+ echo -e "${X_MARK} ${CYAN}Flux config $FLUXOS_PATH/config/userconfig.js does not exists${NC}"
+ fi
+ else
+ echo -e "${X_MARK} ${CYAN}Directory $FLUXOS_PATH does not exists${CYAN}"
+ fi
+ if [[ "$ZELCONF" == "1" ]]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking $FLUX_DAEMON_PATH/flux.conf${NC}"
+ if [[ $zelnodeprivkey == $(grep -w zelnodeprivkey $FLUX_DAEMON_PATH/flux.conf | sed -e 's/zelnodeprivkey=//') ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxNode Identity Key matches${NC}"
+ else
+ REPLACE="1"
+ echo -e "${X_MARK} ${CYAN} FluxNode Identity Key does not match${NC}"
+ fi
+
+ if [[ $zelnodeoutpoint == $(grep -w zelnodeoutpoint $FLUX_DAEMON_PATH/flux.conf | sed -e 's/zelnodeoutpoint=//') ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxNode Collateral TX ID matches${NC}"
+ else
+ REPLACE="1"
+ echo -e "${X_MARK} ${CYAN} FluxNode Collateral TX ID does not match${NC}"
+ fi
+
+ if [[ $zelnodeindex == $(grep -w zelnodeindex $FLUX_DAEMON_PATH/flux.conf | sed -e 's/zelnodeindex=//') ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxNode Output Index matches${NC}"
+ else
+ REPLACE="1"
+ echo -e "${X_MARK} ${CYAN} FluxNode Output Index does not match${NC}"
+ fi
+
+ fi
+ if [[ -f $FLUX_WATCHDOG_PATH/package.json ]]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking Watchdog:${NC}"
+ current_ver=$(jq -r '.version' $FLUX_WATCHDOG_PATH/package.json)
+ required_ver=$(curl -sS https://raw.githubusercontent.com/RunOnFlux/fluxnode-watchdog/master/package.json | jq -r '.version')
+ if [[ "$required_ver" != "" ]]; then
+ if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
+ echo -e "${CHECK_MARK} ${CYAN} You have the current version of Watchdog ${GREEN}(v$required_ver)${NC}"
+ else
+ echo -e "${HOT} ${CYAN}New version of Watchdog available ${SEA}$required_ver${NC}"
+ fi
+ fi
+ fi
+ if [[ -f $FLUX_WATCHDOG_PATH/watchdog_error.log ]]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Watchdog watchdog_error.log file detected, check $FLUX_WATCHDOG_PATH/watchdog_error.log"
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(wc -l < $FLUX_WATCHDOG_PATH/watchdog_error.log)${CYAN} error events${NC}"
+ error_line=$(cat $FLUX_WATCHDOG_PATH/watchdog_error.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_date=$(cat $FLUX_WATCHDOG_PATH/watchdog_error.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}' | head -n1)
+ event_time_uxtime=$(date -ud "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time_uxtime))
+ show_time "$tdiff"
+ fi
+ echo -e "${YELLOW}===================================================${NC}"
+ echo -e ""
+ exit
+fi
+
#const
REPLACE="0"
FLUXCONF="0"
@@ -14,1076 +720,781 @@ OWNER="0"
IP_FIX="0"
SCVESION=v4.0
-#color codes
-RED='\033[1;31m'
-YELLOW='\033[1;33m'
-BLUE="\\033[38;5;27m"
-SEA="\\033[38;5;49m"
-GREEN='\033[1;32m'
-CYAN='\033[1;36m'
-NC='\033[0m'
-ORANGE='\e[38;5;202m'
-
-#emoji codes
-CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}"
-X_MARK="${RED}\xE2\x9C\x96${NC}"
-PIN="${RED}\xF0\x9F\x93\x8C${NC}"
-BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
-WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
-HOT="${ORANGE}\xF0\x9F\x94\xA5${NC}"
-ARROW="${CYAN}\xE2\x96\xB6${NC}"
-
FLUX_DIR='zelflux'
COIN_NAME='zelcash'
COIN_DAEMON='zelcashd'
-#COIN_CLI='zelcash-cli'
-
-
BENCH_DIR_LOG='.zelbenchmark'
BENCH_DAEMON='zelbenchd'
BENCH_NAME='zelbench'
-#BENCH_CLI='zelbench-cli'
-
-
if [[ -f /usr/local/bin/flux-cli ]]; then
- COIN_CLI='flux-cli'
+ COIN_CLI='flux-cli'
else
- COIN_CLI='zelcash-cli'
+ COIN_CLI='zelcash-cli'
fi
if [[ -f /usr/local/bin/fluxbench-cli ]]; then
- BENCH_CLI='fluxbench-cli'
+ BENCH_CLI='fluxbench-cli'
else
- BENCH_CLI='zelbench-cli'
+ BENCH_CLI='zelbench-cli'
fi
-
-
if [[ -d /home/$USER/.zelcash ]]; then
- CONFIG_DIR='.zelcash'
- CONFIG_FILE='zelcash.conf'
+ CONFIG_DIR='.zelcash'
+ CONFIG_FILE='zelcash.conf'
else
- CONFIG_DIR='.flux'
- CONFIG_FILE='flux.conf'
+ CONFIG_DIR='.flux'
+ CONFIG_FILE='flux.conf'
fi
-
if [[ -d /home/$USER/.zelbenchmark ]]; then
-BENCH_DIR_LOG='.zelbenchmark'
+ BENCH_DIR_LOG='.zelbenchmark'
else
-BENCH_DIR_LOG='.fluxbenchmark'
+ BENCH_DIR_LOG='.fluxbenchmark'
fi
-
-
-
-#dialog color
-export NEWT_COLORS='
-title=black,
-'
-
- WANIP=$(curl --silent -m 15 https://checkip.amazonaws.com | tr -dc '[:alnum:].')
- if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl --silent -m 15 https://ipv4bot.whatismyipaddress.com | tr -dc '[:alnum:].')
- else
- WANIP=$(curl --silent -m 15 https://api.ipify.org | tr -dc '[:alnum:].')
- fi
-
-
+get_ip
#function
function show_time() {
- num=$1
- min=0
- hour=0
- day=0
- if((num>59));then
- ((sec=num%60))
- ((num=num/60))
- if((num>59));then
- ((min=num%60))
- ((num=num/60))
- if((num>23));then
- ((hour=num%24))
- ((day=num/24))
- else
- ((hour=num))
- fi
- else
- ((min=num))
- fi
- else
- ((sec=num))
- fi
- echo -e "${PIN} ${CYAN}Last error was \c"
- echo -e "${RED}$day"d "$hour"h "$min"m "$sec"s"${CYAN} ago.${NC}"
-}
-
-function max(){
-
- local m="0"
- for n in "$@"
- do
- if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then
- [ "$n" -gt "$m" ] && m="$n"
- fi
- done
- echo "$m"
-
-}
-
-function spinning_timer() {
- animation=( ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ )
- end=$((SECONDS+NUM))
- while [ $SECONDS -lt $end ];
- do
- for i in "${animation[@]}";
- do
- echo -ne "${RED}\r$i ${CYAN}${MSG1}${NC}"
- sleep 0.1
- done
- done
- echo -e "${MSG2}"
-}
-
-round() {
- printf "%.${2}f" "${1}"
+ num=$1
+ min=0
+ hour=0
+ day=0
+ if((num>59));then
+ ((sec=num%60))
+ ((num=num/60))
+ if((num>59));then
+ ((min=num%60))
+ ((num=num/60))
+ if((num>23));then
+ ((hour=num%24))
+ ((day=num/24))
+ else
+ ((hour=num))
+ fi
+ else
+ ((min=num))
+ fi
+ else
+ ((sec=num))
+ fi
+ echo -e "${PIN} ${CYAN}Last error was \c"
+ echo -e "${RED}$day"d "$hour"h "$min"m "$sec"s"${CYAN} ago.${NC}"
}
-
function check_listen_ports(){
-
-if ! lsof -v > /dev/null 2>&1; then
-sudo apt-get install lsof -y > /dev/null 2>&1 && sleep 2
-fi
-
-
-if sudo lsof -i -n | grep LISTEN | grep 27017 | grep mongod > /dev/null 2>&1; then
-echo -e "${CHECK_MARK} ${CYAN} Mongod listen on port 27017${NC}"
-else
-echo -e "${X_MARK} ${CYAN} Mongod not listen${NC}"
-fi
-
-if sudo lsof -i -n | grep LISTEN | grep 16125 | grep fluxd > /dev/null 2>&1; then
-echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
-else
-
- if sudo lsof -i -n | grep LISTEN | grep 16125 | grep zelcashd > /dev/null 2>&1; then
- echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
- else
- echo -e "${X_MARK} ${CYAN} Flux daemon not listen${NC}"
- fi
-
-fi
-
-#if [[ sudo lsof -i -n | grep LISTEN | grep 16125 | grep fluxd > /dev/null 2>&1 ]] || [[ sudo lsof -i -n | grep LISTEN | grep 16125 | grep zelcashd > /dev/null 2>&1 ]]; then
-#echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
-#else
-#echo -e "${X_MARK} ${CYAN} Flux daemon not listen${NC}"
-#fi
-
-if sudo lsof -i -n | grep LISTEN | grep 16224 | grep bench > /dev/null 2>&1; then
-echo -e "${CHECK_MARK} ${CYAN} Flux benchmark listen on port 16224${NC}"
-else
-echo -e "${X_MARK} ${CYAN} Flux benchmark not listen${NC}"
-fi
-
-if sudo lsof -i -n | grep LISTEN | grep 16126 | grep node > /dev/null 2>&1
-then
-ZELFLUX_PORT1="1"
-fi
-
-if sudo lsof -i -n | grep LISTEN | grep 16127 | grep node > /dev/null 2>&1
-then
-ZELFLUX_PORT2="1"
-fi
-
-if [[ "$ZELFLUX_PORT1" == "1" && "$ZELFLUX_PORT2" == "1" ]]
-then
-echo -e "${CHECK_MARK} ${CYAN} Flux listen on ports 16126/16127${NC}"
-else
-echo -e "${X_MARK} ${CYAN} Flux not listen${NC}"
-fi
-
+ if ! lsof -v > /dev/null 2>&1; then
+ sudo apt-get install lsof -y > /dev/null 2>&1 && sleep 1
+ fi
+ if [[ -f /home/$USER/.fluxbenchmark/fluxbench.conf ]]; then
+ FluxAPI=$(grep -Po "(?<=fluxport=)\d+" /home/$USER/.fluxbenchmark/fluxbench.conf)
+ FLUXOS_CONFIG=$(grep -Po "$FluxAPI" /home/$USER/zelflux/config/userconfig.js)
+ if [[ "$FLUXOS_CONFIG" != "" ]]; then
+ FluxUI=$(($FluxAPI-1))
+ UPNP=1
+ else
+ FluxAPI=16127
+ FluxUI=16126
+ UPNP=0
+ fi
+ else
+ FluxAPI=16127
+ FluxUI=16126
+ UPNP=0
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep 27017 | grep mongod > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Mongod listen on port 27017${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Mongod not listen${NC}"
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep 16125 | grep fluxd > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
+ else
+ if sudo lsof -i -n | grep LISTEN | grep 16125 | grep zelcashd > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux daemon listen on port 16125${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux daemon not listen${NC}"
+ fi
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep 16224 | grep bench > /dev/null 2>&1; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux benchmark listen on port 16224${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux benchmark not listen${NC}"
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep $FluxUI | grep node > /dev/null 2>&1; then
+ ZELFLUX_PORT1="1"
+ fi
+ if sudo lsof -i -n | grep LISTEN | grep $FluxAPI | grep node > /dev/null 2>&1 ; then
+ ZELFLUX_PORT2="1"
+ fi
+ if [[ "$ZELFLUX_PORT1" == "1" && "$ZELFLUX_PORT2" == "1" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux listen on ports $FluxUI/$FluxAPI ${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux not listen${NC}"
+ fi
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}FluxOS networking: ${NC}"
+ if [[ "$UPNP" == "1" ]]; then
+ echo -e "${PIN} ${CYAN}UPnP MODE: ${GREEN}ENABLED${NC}"
+ else
+ echo -e "${PIN} ${CYAN}UPnP MODE: ${RED}DISABLED${NC}"
+ fi
+ echo -e "${PIN} ${CYAN}FluxAPI PORT: ${ORANGE}$FluxAPI ${NC}"
+ echo -e "${PIN} ${CYAN}FluxUI PORT: ${ORANGE}$FluxUI ${NC}"
+ if [[ -f /home/$USER/.pm2/logs/flux-out.log ]]; then
+ error_check=$(tail -n10 /home/$USER/.pm2/logs/flux-out.log | grep "UPnP failed")
+ if [[ "$error_check" != "" ]]; then
+ echo -e ""
+ echo -e "${ARROW} ${YELLOW}Checking FluxOS logs... ${NC}"
+ echo -e "${WORNING} ${RED}Problem with UPnP detected, FluxOS Shutting down..."
+ echo -e ""
+ fi
+ fi
}
+function get_last_benchmark(){
+ if [[ "$2" == "check" ]]; then
+
+ info_check=$(grep 'Found' /home/$USER/$BENCH_DIR_LOG/debug.log | egrep 'Found|Historical' | grep $1 | tail -n1 | egrep -o '[0-9]+(\.[0-9]+)|([0-9]+)' | tail -n1 | awk '{printf "%.2f\n", $1}')
+ if [[ "$info_check" == "" ]]; then
+ skipp_debug=1
+ return 1
+ fi
+
+ fi
-function get_last_benchmark()
-{
-
- if [[ "$2" == "check" ]]; then
-
- info_check=$(grep 'Found' /home/$USER/$BENCH_DIR_LOG/debug.log | egrep 'Found|Historical' | grep $1 | tail -n1 | egrep -o '[0-9]+(\.[0-9]+)|([0-9]+)' | tail -n1 | awk '{printf "%.2f\n", $1}')
- if [[ "$info_check" == "" ]]; then
- skipp_debug=1
- return 1
- fi
-
- fi
-
-
- if [[ "$1" == "cores" ]]; then
- cores=$(grep 'Found' /home/$USER/$BENCH_DIR_LOG/debug.log | egrep 'Found|Historical' | grep 'cores' | tail -n1 | egrep -Eo '[^ ]+$')
- echo -e "${PIN}${CYAN} CORES: ${GREEN}$cores${NC}"
- fi
-
- if [[ "$1" == "HDD" || "$1" == "DD_WRITE" || "$1" == "ram" || "$1" == "eps" ]] && [[ "$2" != "check" ]]; then
-
- info=$(grep 'Found' /home/$USER/$BENCH_DIR_LOG/debug.log | egrep 'Found|Historical' | grep $1 | tail -n1 | egrep -o '[0-9]+(\.[0-9]+)|([0-9]+)' | tail -n1 | awk '{printf "%.2f\n", $1}')
- if [[ "$1" == "ram" ]]; then
- echo -e "${PIN}${CYAN} RAM: ${GREEN}$info${NC}"
- fi
+ if [[ "$1" == "cores" ]]; then
+ cores=$(grep 'Found' /home/$USER/$BENCH_DIR_LOG/debug.log | egrep 'Found|Historical' | grep 'cores' | tail -n1 | egrep -Eo '[^ ]+$')
+ echo -e "${PIN}${CYAN} CORES: ${GREEN}$cores${NC}"
+ fi
- if [[ "$1" == "eps" ]]; then
- echo -e "${PIN}${CYAN} EPS: ${GREEN}$info${NC}"
- fi
+ if [[ "$1" == "HDD" || "$1" == "DD_WRITE" || "$1" == "ram" || "$1" == "eps" ]] && [[ "$2" != "check" ]]; then
- if [[ "$1" == "DD_WRITE" ]]; then
- echo -e "${PIN}${CYAN} DD_WRITE: ${GREEN}$info${NC}"
- fi
+ info=$(grep 'Found' /home/$USER/$BENCH_DIR_LOG/debug.log | egrep 'Found|Historical' | grep $1 | tail -n1 | egrep -o '[0-9]+(\.[0-9]+)|([0-9]+)' | tail -n1 | awk '{printf "%.2f\n", $1}')
- if [[ "$1" == "HDD" ]]; then
- echo -e "${PIN}${CYAN} HDD: ${GREEN}$info${NC}"
- fi
+ if [[ "$1" == "ram" ]]; then
+ echo -e "${PIN}${CYAN} RAM: ${GREEN}$info${NC}"
+ fi
- fi
+ if [[ "$1" == "eps" ]]; then
+ echo -e "${PIN}${CYAN} EPS: ${GREEN}$info${NC}"
+ fi
+ if [[ "$1" == "DD_WRITE" ]]; then
+ echo -e "${PIN}${CYAN} DD_WRITE: ${GREEN}$info${NC}"
+ fi
+ if [[ "$1" == "HDD" ]]; then
+ echo -e "${PIN}${CYAN} HDD: ${GREEN}$info${NC}"
+ fi
+ fi
}
-
function integration(){
-
-PATH_TO_FOLDER=( /usr/local/bin/ )
-if [[ -f /usr/local/bin/fluxd ]]; then
- FILE_ARRAY=( 'fluxbench-cli' 'fluxbenchd' 'flux-cli' 'fluxd' 'flux-fetch-params.sh' 'flux-tx' )
-else
- FILE_ARRAY=( 'zelbench-cli' 'zelbenchd' 'zelcash-cli' 'zelcashd' 'zelcash-fetch-params.sh' 'zelcash-tx' )
-fi
-
-ELEMENTS=${#FILE_ARRAY[@]}
-NOT_FOUND="0"
-
-for (( i=0;i<$ELEMENTS;i++)); do
-
- if [ -f $PATH_TO_FOLDER${FILE_ARRAY[${i}]} ]; then
- echo -e "${CHECK_MARK} ${CYAN} ${FILE_ARRAY[${i}]}"
- else
- echo -e "${X_MARK} ${CYAN} ${FILE_ARRAY[${i}]}"
- NOT_FOUND="1"
- fi
-done
-
-}
-
-function check_benchmarks() {
- var_benchmark=$($BENCH_CLI getbenchmarks | jq ".$1")
- limit=$2
- if [[ $(echo "$limit>$var_benchmark" | bc) == "1" ]]; then
- var_round=$(round "$var_benchmark" 2)
- echo -e "${X_MARK} ${CYAN}$3 $var_round $4${NC}"
- fi
-
+ PATH_TO_FOLDER=( /usr/local/bin/ )
+ if [[ -f /usr/local/bin/fluxd ]]; then
+ FILE_ARRAY=( 'fluxbench-cli' 'fluxbenchd' 'flux-cli' 'fluxd' 'flux-fetch-params.sh' 'flux-tx' )
+ else
+ FILE_ARRAY=( 'zelbench-cli' 'zelbenchd' 'zelcash-cli' 'zelcashd' 'zelcash-fetch-params.sh' 'zelcash-tx' )
+ fi
+ ELEMENTS=${#FILE_ARRAY[@]}
+ NOT_FOUND="0"
+ for (( i=0;i<$ELEMENTS;i++)); do
+ if [ -f $PATH_TO_FOLDER${FILE_ARRAY[${i}]} ]; then
+ echo -e "${CHECK_MARK} ${CYAN} ${FILE_ARRAY[${i}]}"
+ else
+ echo -e "${X_MARK} ${CYAN} ${FILE_ARRAY[${i}]}"
+ NOT_FOUND="1"
+ fi
+ done
}
-if [[ "$USER" == "root" ]]
-then
- echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
- echo -e "${CYAN}Please switch to the user accont.${NC}"
- echo -e "${YELLOW}================================================================${NC}"
- echo -e "${NC}"
- exit
+if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
+ echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
+ echo -e "${CYAN}Please switch to the user accont.${NC}"
+ echo -e "${YELLOW}================================================================${NC}"
+ echo -e "${NC}"
+ exit
fi
-
sleep 1
-sudo apt install bc > /dev/null 2>&1
+if ! bc -v > /dev/null 2>&1 ; then
+ sudo apt install -y bc > /dev/null 2>&1 && sleep 1
+fi
echo -e "${NC}"
if [ -f /home/$USER/$BENCH_DIR_LOG/debug.log ]; then
-echo -e "${BOOK} ${YELLOW}Checking Flux benchmark $BENCH_DIR_LOG/debug.log${NC}"
-if [[ $(egrep -ac -wi --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log) != "0" ]]; then
-echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(egrep -ac --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log)${CYAN} error events${NC}"
-#egrep -wi --color 'warning|error|critical|failed' ~/.zelbenchmark/debug.log
-error_line=$(egrep -a --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
-event_date=$(egrep -a --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}')
-echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
-event_time_uxtime=$(date -ud "$event_date" +"%s")
-event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
-event_time="$event_time_uxtime"
-now_date=$(date +%s)
-tdiff=$((now_date-event_time))
-show_time "$tdiff"
-echo -e "${PIN} ${CYAN}Creating Flux benchmark_debug_error.log${NC}"
-egrep -a --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log > /home/$USER/benchmark_debug_error.log
-echo
-else
-echo -e "${GREEN}\xF0\x9F\x94\x8A ${CYAN}Found: ${GREEN}0 errors${NC}"
-echo
-fi
-
-skipp_debug=0
-
-get_last_benchmark "HDD" "check"
-
-if [[ "$skipp_debug" == "0" ]]; then
-
- echo -e "${BOOK} ${YELLOW}Last benchmark from ~/$BENCH_DIR_LOG/debug.log${NC}"
- get_last_benchmark "HDD"
- get_last_benchmark "DD_WRITE"
- get_last_benchmark "ram"
- get_last_benchmark "cores"
- echo
-fi
-#else
-#echo -e "${RED}Debug file not exists${NC}"
-#echo
+ echo -e "${BOOK} ${YELLOW}Checking Flux benchmark $BENCH_DIR_LOG/debug.log${NC}"
+ if [[ $(egrep -ac -wi --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log) != "0" ]]; then
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(egrep -ac --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log)${CYAN} error events${NC}"
+ #egrep -wi --color 'warning|error|critical|failed' ~/.zelbenchmark/debug.log
+ error_line=$(egrep -a --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ event_date=$(egrep -a --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}')
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_time_uxtime=$(date -ud "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ event_time="$event_time_uxtime"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time))
+ show_time "$tdiff"
+ echo -e "${PIN} ${CYAN}Creating Flux benchmark_debug_error.log${NC}"
+ egrep -a --color 'Failed' /home/$USER/$BENCH_DIR_LOG/debug.log > /home/$USER/benchmark_debug_error.log
+ echo -e ""
+ else
+ echo -e "${GREEN}\xF0\x9F\x94\x8A ${CYAN}Found: ${GREEN}0 errors${NC}"
+ echo -e ""
+ fi
+ skipp_debug=0
+ get_last_benchmark "HDD" "check"
+ if [[ "$skipp_debug" == "0" ]]; then
+ echo -e "${BOOK} ${YELLOW}Last benchmark from ~/$BENCH_DIR_LOG/debug.log${NC}"
+ get_last_benchmark "HDD"
+ get_last_benchmark "DD_WRITE"
+ get_last_benchmark "ram"
+ get_last_benchmark "cores"
+ echo -e ""
+ fi
fi
-
-
-
if [ -f /home/$USER/$CONFIG_DIR/debug.log ]; then
-echo -e "${BOOK} ${YELLOW}Checking Flux daemon ~/$CONFIG_DIR/debug.log${NC}"
-if [[ $(egrep -ac -wi --color 'error|failed' /home/$USER//$CONFIG_DIR/debug.log) != "0" ]]; then
-echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(egrep -ac -wi --color 'error|failed' /home/$USER/$CONFIG_DIR/debug.log)${CYAN} error events, ${RED}$(egrep -ac -wi --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log) ${CYAN}related to benchmark${NC}"
-if [[ $(egrep -ac -wi --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log) != "0" ]]; then
-echo -e "${BOOK} ${CYAN}FluxBench errors info:${NC}"
-error_line=$(egrep -a --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
-event_date=$(egrep -a --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}')
-echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
-event_time_uxtime=$(date -ud "$event_date" +"%s")
-event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
-event_time="$event_time_uxtime"
-now_date=$(date +%s)
-tdiff=$((now_date-event_time))
-show_time "$tdiff"
-fi
-echo -e "${PIN} ${CYAN}Creating flux_daemon_debug_error.log${NC}"
-egrep -a --color 'error|failed' /home/$USER/$CONFIG_DIR/debug.log > /home/$USER/flux_daemon_debug_error.log
-echo
-else
-echo -e "${GREEN}\xF0\x9F\x94\x8A ${CYAN}Found: ${GREEN}0 errors${NC}"
-echo
+ echo -e "${BOOK} ${YELLOW}Checking Flux daemon ~/$CONFIG_DIR/debug.log${NC}"
+ if [[ $(egrep -ac -wi --color 'error|failed' /home/$USER//$CONFIG_DIR/debug.log) != "0" ]]; then
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(egrep -ac -wi --color 'error|failed' /home/$USER/$CONFIG_DIR/debug.log)${CYAN} error events, ${RED}$(egrep -ac -wi --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log) ${CYAN}related to benchmark${NC}"
+ if [[ $(egrep -ac -wi --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log) != "0" ]]; then
+ echo -e "${BOOK} ${CYAN}FluxBench errors info:${NC}"
+ error_line=$(egrep -a --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ event_date=$(egrep -a --color 'benchmarking' /home/$USER/$CONFIG_DIR/debug.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}')
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_time_uxtime=$(date -ud "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ event_time="$event_time_uxtime"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time))
+ show_time "$tdiff"
+ fi
+ echo -e "${PIN} ${CYAN}Creating flux_daemon_debug_error.log${NC}"
+ egrep -a --color 'error|failed' /home/$USER/$CONFIG_DIR/debug.log > /home/$USER/flux_daemon_debug_error.log
+ echo -e ""
+ else
+ echo -e "${GREEN}\xF0\x9F\x94\x8A ${CYAN}Found: ${GREEN}0 errors${NC}"
+ echo -e ""
+ fi
fi
-#else
-#echo -e "${RED}Debug file not exists${NC}"
-#echo
+usercheck=$(getent group docker)
+if [[ "$usercheck" =~ "," ]]; then
+ echo -e ""
+ echo -e "${WORNING} ${CYAN} Detected multiple users in docker group...${NC}"
+ echo -e "${WORNING} ${CYAN} More then one instance of flux daemon will cause it to malfunction...${NC}"
+ echo -e "${WORNING} ${CYAN} If u installed FluxOS on more then one user you need delete one instance of it...${NC}"
+ echo -e "${WORNING} ${CYAN} To check the list of users type: getent group docker ${NC}"
+ echo -e "${WORNING} ${CYAN} To remove unwanted users type: sudo deluser --remove-home user_name ${NC}"
+ echo -e "${WORNING} ${CYAN} To reboot server type: sudo reboot -n ${NC}"
fi
-
-
-
if [[ "$($BENCH_CLI getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
+ echo -e "${BOOK} ${YELLOW}Flux benchmark status:${NC}"
+ bench_getatus=$($BENCH_CLI getstatus)
+ bench_status=$(jq -r '.status' <<< "$bench_getatus")
+ bench_benchmark=$(jq -r '.benchmarking' <<< "$bench_getatus")
+ bench_back=$(jq -r '.zelback' <<< "$bench_getatus")
+ if [[ "$bench_back" == "null" ]]; then
+ bench_back=$(jq -r '.flux' <<< "$bench_getatus")
+ fi
-echo -e "${BOOK} ${YELLOW}Flux benchmark status:${NC}"
-bench_getatus=$($BENCH_CLI getstatus)
-bench_status=$(jq -r '.status' <<< "$bench_getatus")
-bench_benchmark=$(jq -r '.benchmarking' <<< "$bench_getatus")
-bench_back=$(jq -r '.zelback' <<< "$bench_getatus")
-if [[ "$bench_back" == "null" ]]; then
-bench_back=$(jq -r '.flux' <<< "$bench_getatus")
-fi
-
-
-bench_getinfo=$($BENCH_CLI getinfo)
-bench_version=$(jq -r '.version' <<< "$bench_getinfo")
-
-if [[ "$bench_benchmark" == "failed" || "$bench_benchmark" == "toaster" ]]; then
-bench_benchmark_color="${RED}$bench_benchmark"
-else
-bench_benchmark_color="${SEA}$bench_benchmark"
-fi
-
-if [[ "$bench_status" == "online" ]]; then
-bench_status_color="${SEA}$bench_status"
-else
-bench_status_color="${RED}$bench_status"
-fi
-
-if [[ "$bench_back" == "connected" ]]; then
-bench_back_color="${SEA}$bench_back"
-else
-bench_back_color="${RED}$bench_back"
-fi
-
-echo -e "${PIN} ${CYAN}Flux benchmark version: ${SEA}$bench_version${NC}"
-echo -e "${PIN} ${CYAN}Flux benchmark status: $bench_status_color${NC}"
-echo -e "${PIN} ${CYAN}Benchmark: $bench_benchmark_color${NC}"
-echo -e "${PIN} ${CYAN}Flux: $bench_back_color${NC}"
-echo -e "${NC}"
-
-if [[ "$bench_benchmark" == "running" ]]; then
-echo -e "${ARROW} ${CYAN} Benchmarking hasn't completed, please wait until benchmarking has completed.${NC}"
-fi
-
-if [[ "$bench_benchmark" == "BASIC" || "$bench_benchmark" == "SUPER" || "$bench_benchmark" == "BAMF" ]]; then
-echo -e "${CHECK_MARK} ${CYAN} Flux benchmark working correct, all requirements met.${NC}"
-fi
-
-if [[ "$bench_benchmark" == "failed" ]]; then
-echo -e "${X_MARK} ${CYAN} Flux benchmark problem detected, check benchmark debug.log${NC}"
-fi
-
-core=$($BENCH_CLI getbenchmarks | jq '.cores')
-
-if [[ "$bench_benchmark" == "failed" && "$core" > "0" ]]; then
-BTEST="1"
-echo -e "${X_MARK} ${CYAN} Flux benchmark working correct but minimum system requirements not met.${NC}"
-check_benchmarks "eps" "89.99" " CPU speed" "< 90.00 events per second"
-check_benchmarks "ddwrite" "159.99" " Disk write speed" "< 160.00 events per second"
-fi
-#if [[ "$zelbench_benchmark" == "toaster" || "$zelbench_benchmark" == "failed" ]]; then
-##lc_numeric_var=$(locale | grep LC_NUMERIC | sed -e 's/.*LC_NUMERIC=//')
-##lc_numeric_need='"en_US.UTF-8"'
-##if [ "$lc_numeric_var" == "$lc_numeric_need" ]
-##then
-##echo -e "${CHECK_MARK} ${CYAN} LC_NUMERIC is correct${NC}"
-##else
-##echo -e "${X_MARK} ${CYAN} You need set LC_NUMERIC to en_US.UTF-8${NC}"
-##LC_CHECK="1"
-##fi
-#fi
-if [[ "$bench_back" == "disconnected" ]]; then
-echo -e "${X_MARK} ${CYAN} FluxBack does not work properly${NC}"
+ bench_getinfo=$($BENCH_CLI getinfo)
+ bench_version=$(jq -r '.version' <<< "$bench_getinfo")
-WANIP=$(wget http://ipecho.net/plain -O - -q)
-if [[ "$WANIP" == "" ]]; then
- WANIP=$(curl ifconfig.me)
-fi
-
-if [[ "$WANIP" != "" ]]; then
+ if [[ "$bench_benchmark" == "failed" || "$bench_benchmark" == "toaster" ]]; then
+ bench_benchmark_color="${RED}$bench_benchmark"
+ else
+ bench_benchmark_color="${SEA}$bench_benchmark"
+ fi
-back_error_check=$(curl -s -m 5 http://$WANIP:16127/zelid/loginphrase | jq -r .data[]? | wc -l)
+ if [[ "$bench_status" == "online" ]]; then
+ bench_status_color="${SEA}$bench_status"
+ else
+ bench_status_color="${RED}$bench_status"
+ fi
- if [[ "$back_error_check" == "" ]]; then
-
- sudo ufw allow from any to any port 16127 > /dev/null 2>&1
- sudo ufw allow out to any port 16127 > /dev/null 2>&1
- sudo ufw reload > /dev/null 2>&1
-
- else
+ if [[ "$bench_back" == "connected" ]]; then
+ bench_back_color="${SEA}$bench_back"
+ else
+ bench_back_color="${RED}$bench_back"
+ fi
- if [[ "$back_error_check" == "7" ]]; then
- back_error=$(curl -s -m 3 http://$WANIP:16127/zelid/loginphrase | jq -r .data.message.message)
- echo -e "${X_MARK} ${CYAN} FluxBack error: ${RED}$back_error${NC}"
- sudo ufw allow from any to any port 16127 > /dev/null 2>&1
- sudo ufw allow out to any port 16127 > /dev/null 2>&1
- sudo ufw reload > /dev/null 2>&1
-
- fi
-
- if [[ "$back_error_check" == "3" ]]; then
- back_error=$(curl -s -m 3 http://$WANIP:16127/zelid/loginphrase | jq -r .data.message)
- echo -e "${X_MARK} ${CYAN} FluxBack error: ${RED}$back_error${NC}"
- sudo ufw allow from any to any port 16127 > /dev/null 2>&1
- sudo ufw allow out to any port 16127 > /dev/null 2>&1
- sudo ufw reload > /dev/null 2>&1
-
- fi
- fi
-fi
+ echo -e "${PIN} ${CYAN}Flux benchmark version: ${SEA}$bench_version${NC}"
+ echo -e "${PIN} ${CYAN}Flux benchmark status: $bench_status_color${NC}"
+ echo -e "${PIN} ${CYAN}Benchmark: $bench_benchmark_color${NC}"
+ echo -e "${PIN} ${CYAN}Flux: $bench_back_color${NC}"
+ echo -e "${NC}"
-device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}')
-local_device_ip=$(ip a list $device_name | grep -o $WANIP )
+ if [[ "$bench_benchmark" == "running" ]]; then
+ echo -e "${ARROW} ${CYAN} Benchmarking hasn't completed, please wait until benchmarking has completed.${NC}"
+ fi
-if [[ "$WANIP" != "" ]]; then
+ if [[ "$bench_benchmark" == "CUMULUS" || "$bench_benchmark" == "NIMBUS" || "$bench_benchmark" == "STRATUS" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Flux benchmark working correct, all requirements met.${NC}"
+ fi
- if [[ "$local_device_ip" == "$WANIP" ]]; then
- echo -e "${CHECK_MARK} ${CYAN} Public IP(${GREEN}$WANIP${CYAN}) matches local device(${GREEN}$device_name${CYAN}) IP(${GREEN}$local_device_ip${CYAN})${NC}"
- else
- echo -e "${X_MARK} ${CYAN} Public IP(${GREEN}$WANIP${CYAN}) not matches local device(${GREEN}$device_name${CYAN}) IP${NC}"
- echo -e "${ARROW} ${CYAN} If you under NAT try add your public IP to netplan, netplan.io or /etc/network/interfaces${NC}"
- ## dev_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2"0"}')
- ## sudo ip addr add "$WANPI" dev "$dev_name"
- IP_FIX="1"
- fi
-
-else
-echo -e "${ARROW} ${CYAN} Local device(${GREEN}$device_name${CYAN}) IP veryfication failed...${NC}"
-fi
+ if [[ "$bench_benchmark" == "failed" ]]; then
+ echo -e "${X_MARK} ${CYAN} Flux benchmark problem detected, check benchmark debug.log${NC}"
+ fi
+ core=$($BENCH_CLI getbenchmarks | jq '.cores')
+ if [[ "$bench_benchmark" == "failed" && "$core" > "0" ]]; then
+ BTEST="1"
+ echo -e "${X_MARK} ${CYAN} Flux benchmark working correct but minimum system requirements not met.${NC}"
+ check_benchmarks "eps" "89.99" " CPU speed" "< 90.00 events per second"
+ check_benchmarks "ddwrite" "159.99" " Disk write speed" "< 160.00 events per second"
+ fi
+ #if [[ "$zelbench_benchmark" == "toaster" || "$zelbench_benchmark" == "failed" ]]; then
+ ##lc_numeric_var=$(locale | grep LC_NUMERIC | sed -e 's/.*LC_NUMERIC=//')
+ ##lc_numeric_need='"en_US.UTF-8"'
+ ##if [ "$lc_numeric_var" == "$lc_numeric_need" ]
+ ##then
+ ##echo -e "${CHECK_MARK} ${CYAN} LC_NUMERIC is correct${NC}"
+ ##else
+ ##echo -e "${X_MARK} ${CYAN} You need set LC_NUMERIC to en_US.UTF-8${NC}"
+ ##LC_CHECK="1"
+ ##fi
+ #fi
+ if [[ "$bench_back" == "disconnected" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxBack does not work properly${NC}"
+ if [[ "$WANIP" != "" ]]; then
+ back_error_check=$(curl -s -m 5 http://$WANIP:$FluxAPI/zelid/loginphrase | jq -r .status )
+ if [[ "$back_error_check" != "success" && "$back_error_check" != "" ]]; then
+ back_error=$(curl -s -m 8 http://$WANIP:$FluxAPI/zelid/loginphrase | jq -r .data.message.message 2>/dev/null )
+ if [[ "$back_error" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxBack error: ${RED}$back_error${NC}"
+ else
+ back_error=$(curl -s -m 8 http://$WANIP:$FluxAPI/zelid/loginphrase | jq -r .data.message 2>/dev/null )
+ if [[ "$back_error" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} FluxBack error: ${RED}$back_error${NC}"
+ fi
+ fi
+ fi
+ fi
+ device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}')
+ local_device_ip=$(ip a list $device_name | grep -o $WANIP )
+ if [[ "$WANIP" != "" ]]; then
+ if [[ "$local_device_ip" == "$WANIP" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Public IP(${GREEN}$WANIP${CYAN}) matches local device(${GREEN}$device_name${CYAN}) IP(${GREEN}$local_device_ip${CYAN})${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Public IP(${GREEN}$WANIP${CYAN}) not matches local device(${GREEN}$device_name${CYAN}) IP${NC}"
+ echo -e "${ARROW} ${CYAN} If you under NAT use option 10 from multitoolbox (self-hosting)${NC}"
+ ## dev_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2"0"}')
+ ## sudo ip addr add "$WANPI" dev "$dev_name"
+ # IP_FIX="1"
+ fi
+ else
+ echo -e "${ARROW} ${CYAN} Local device(${GREEN}$device_name${CYAN}) IP veryfication failed...${NC}"
+ fi
+ fi
+ echo -e "${NC}"
fi
-echo -e "${NC}"
-fi
-
if [[ "$($COIN_CLI getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then
-echo -e "${BOOK} ${YELLOW}Flux deamon information:${NC}"
-daemon_getinfo=$($COIN_CLI getinfo)
-version=$(jq -r '.version' <<< "$daemon_getinfo")
-blocks_hight=$(jq -r '.blocks' <<< "$daemon_getinfo")
-protocolversion=$(jq -r '.protocolversion' <<< "$daemon_getinfo")
-connections=$(jq -r '.connections' <<< "$daemon_getinfo")
-error=$(jq -r '.error' <<< "$daemon_getinfo")
-
-if [[ "$error" != "" && "$error" != null ]]; then
-echo
-echo -e "${X_MARK} ${CYAN} Flux daemon error detected: ${RED}$error${CYAN}) IP${NC}"
-fi
-
-echo -e "${PIN} ${CYAN}Version: ${SEA}$version${NC}"
-echo -e "${PIN} ${CYAN}Protocolversion: ${SEA}$protocolversion${NC}"
-echo -e "${PIN} ${CYAN}Connections: ${SEA}$connections${NC}"
-echo -e "${PIN} ${CYAN}Blocks: ${SEA}$blocks_hight${NC}"
-
-network_height_01=$(curl -sk -m 5 https://explorer.runonflux.io/api/status?q=getInfo | jq '.info.blocks')
-network_height_02=$(curl -sk -m 5 https://explorer.flux.zelcore.io/api/status?q=getInfo | jq '.info.blocks')
-network_height_03=$(curl -sk -m 5 https://explorer.zelcash.online/api/status?q=getInfo | jq '.info.blocks')
-
-explorer_network_hight=$(max "$network_height_01" "$network_height_02" "$network_height_03")
-
-block_diff=$((explorer_network_hight-blocks_hight))
-
-if [[ "$block_diff" < 10 ]]; then
-echo -e "${PIN} ${CYAN}Status: ${GREEN}synced${NC}"
-else
-echo -e "${PIN} ${CYAN}Status: ${RED}not synced${NC}"
-fi
-
-echo -e ""
-echo -e "${BOOK} ${YELLOW}Checking node status:${NC}"
-getzelnodestatus=$($COIN_CLI getzelnodestatus)
-node_status=$(jq -r '.status' <<< "$getzelnodestatus")
-collateral=$(jq -r '.collateral' <<< "$getzelnodestatus")
-
-if [ "$node_status" == "CONFIRMED" ]
-then
-node_status_color="${SEA}$node_status"
-elif [ "$node_status" == "STARTED" ]
-then
-node_status_color="${YELLOW}$node_status"
-else
-node_status_color="${RED}$node_status"
-fi
-
-echo -e "${PIN} ${CYAN}Node status: $node_status_color${NC}"
-
-if [[ "$node_status" == "DOS" ]]; then
-blocks_till=$($COIN_CLI getdoslist | jq .[] | grep "$collateral" -A4 -B1 | jq .eligible_in)
-dos_till=$((blocks_hight+blocks_till))
-echo -e "${PIN} ${RED}DOS ${CYAN}Till: ${ORANGE}$dos_till ${CYAN}EXPIRE_COUNT: ${ORANGE}$blocks_till${CYAN} Time left: ${RED}~$((2*blocks_till)) min. ${NC}"
-fi
-
-
-echo -e "${PIN} ${CYAN}Collateral: ${SEA}$collateral${NC}"
-echo -e ""
-
-if [ "$node_status" != "CONFIRMED" ]
-then
-
-if whiptail --yesno "Would you like to verify $CONFIG_FILE Y/N?" 8 60; then
-ZELCONF="1"
-zelnodeprivkey="$(whiptail --title "Deamon configuration" --inputbox "Enter your FluxNode Private Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)"
-zelnodeoutpoint="$(whiptail --title "Deamon configuration" --inputbox "Enter your FluxNode Output TX ID" 8 72 3>&1 1>&2 2>&3)"
-zelnodeindex="$(whiptail --title "Deamon configuration" --inputbox "Enter your FluxNode Output Index" 8 60 3>&1 1>&2 2>&3)"
-fi
-
-fi
-
-
-echo -e "${BOOK} ${YELLOW}Checking collateral:${NC}"
-txhash=$(grep -o "\w*" <<< "$collateral")
-txhash=$(sed -n "2p" <<< "$txhash")
-txhash=$(egrep "\w{10,50}" <<< "$txhash")
-
-if [[ "$txhash" != "" ]]; then
-#url_to_check="https://explorer.zel.cash/api/tx/$txhash"
-#conf=$(wget -nv -qO - $url_to_check | jq '.confirmations')
-stak_info=""
-if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then
- index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
- #collateral_index=$(awk '{print $1}' <<< "$stak_info")
- stak_info=$(curl -s -m 5 https://explorer.runonflux.io/api/tx/$txhash | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep '10000|25000|100000')
-
- if [[ "$stak_info" != "" ]]; then
- stak_info=$(curl -s -m 5 https://explorer.flux.zelcore.io/api/tx/$txhash | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep '10000|25000|100000')
+ echo -e "${BOOK} ${YELLOW}Flux deamon information:${NC}"
+ daemon_getinfo=$($COIN_CLI getinfo)
+ version=$(jq -r '.version' <<< "$daemon_getinfo")
+ blocks_hight=$(jq -r '.blocks' <<< "$daemon_getinfo")
+ protocolversion=$(jq -r '.protocolversion' <<< "$daemon_getinfo")
+ connections=$(jq -r '.connections' <<< "$daemon_getinfo")
+ error=$(jq -r '.error' <<< "$daemon_getinfo")
+ if [[ "$error" != "" && "$error" != null ]]; then
+ echo
+ echo -e "${X_MARK} ${CYAN} Flux daemon error detected: ${RED}$error${CYAN}) IP${NC}"
fi
-
-fi
-
- if [[ "$stak_info" != "" ]]; then
-
- #if [[ -f /home/$USER/.zelcash/zelcash.conf ]]; then
-
- #index_from_file=$(grep -w zelnodeindex /home/$USER/.zelcash/zelcash.conf | sed -e 's/zelnodeindex=//')
- #collateral_index=$(awk '{print $2}' <<< "$stak_info")
-
- #if [[ "$index_from_file" == "$collateral_index" ]]; then
- #echo -e "${CHECK_MARK} ${CYAN} Zelnodeindex is correct"
- #else
- #echo -e "${X_MARK} ${CYAN} Zelnodeindex is not correct, correct one is $collateral_index"
- #fi
- #else
- #collateral_index=$(awk '{print $1}' <<< "$stak_info")
- #fi
- type=$(awk '{print $1}' <<< "$stak_info")
- conf=$($COIN_CLI gettxout $txhash $index_from_file | jq .confirmations)
-
- if [[ $conf == ?(-)+([0-9]) ]]; then
- if [ "$conf" -ge "100" ]; then
- echo -e "${CHECK_MARK} ${CYAN} Confirmations numbers >= 100($conf)${NC}"
- else
- echo -e "${X_MARK} ${CYAN} Confirmations numbers < 100($conf)${NC}"
- fi
+ echo -e "${PIN} ${CYAN}Version: ${SEA}$version${NC}"
+ echo -e "${PIN} ${CYAN}Protocolversion: ${SEA}$protocolversion${NC}"
+ echo -e "${PIN} ${CYAN}Connections: ${SEA}$connections${NC}"
+ echo -e "${PIN} ${CYAN}Blocks: ${SEA}$blocks_hight${NC}"
+ network_height_01=$(curl -sk -m 5 https://$network_url_1/api/status?q=getInfo getinfo 2>/dev/null | jq '.info.blocks' 2> /dev/null)
+ network_height_02=$(curl -sk -m 5 https://$network_url_2/api/status?q=getInfo getinfo 2>/dev/null | jq '.info.blocks' 2> /dev/null)
+ explorer_network_hight=$(max "$network_height_01" "$network_height_02")
+ block_diff=$((explorer_network_hight-blocks_hight))
+ if [[ "$explorer_network_hight" != "0" ]]; then
+ if [[ "$block_diff" < 10 ]]; then
+ echo -e "${PIN} ${CYAN}Status: ${GREEN}synced${NC}"
else
- echo -e "${X_MARK} ${CYAN} FluxNode outpoint is not valid${NC}"
+ echo -e "${PIN} ${CYAN}Status: ${RED}not synced${NC}"
fi
-
-
- if [[ $type == ?(-)+([0-9]) ]]; then
-
- case $type in
- "10000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}BASIC${NC}" ;;
- "25000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}SUPER${NC}";;
- "100000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}BAMF${NC}";;
- esac
-
- case $bench_benchmark in
- "BASIC") bench_benchmark_value=10000 ;;
- "SUPER") bench_benchmark_value=25000 ;;
- "BAMF") bench_benchmark_value=100000 ;;
- esac
-
- #echo -e "$zelbench_benchmark_value" -> 10000 BASIC
- # echo -e "$type" -> 25000 SUPER
+ else
+ echo -e "${PIN} ${CYAN}Info: ${RED}sync check skipped...${NC}"
+ fi
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking node status:${NC}"
+ getzelnodestatus=$($COIN_CLI getzelnodestatus)
+ node_status=$(jq -r '.status' <<< "$getzelnodestatus")
+ collateral=$(jq -r '.collateral' <<< "$getzelnodestatus")
+ if [[ "$node_status" == "CONFIRMED" ]]; then
+ node_status_color="${SEA}$node_status"
+ elif [[ "$node_status" == "STARTED" ]];then
+ node_status_color="${YELLOW}$node_status"
+ else
+ node_status_color="${RED}$node_status"
+ fi
+ echo -e "${PIN} ${CYAN}Node status: $node_status_color${NC}"
+ if [[ "$node_status" == "DOS" ]]; then
+ blocks_till=$($COIN_CLI getdoslist | jq .[] | grep "$collateral" -A5 -B1 | jq .eligible_in)
+ dos_till=$((blocks_hight+blocks_till))
+ echo -e "${PIN} ${RED}DOS ${CYAN}Till: ${ORANGE}$dos_till ${CYAN}EXPIRE_COUNT: ${ORANGE}$blocks_till${CYAN} Time left: ${RED}~$((2*blocks_till)) min. ${NC}"
+ fi
+ echo -e "${PIN} ${CYAN}Collateral: ${SEA}$collateral${NC}"
+ echo -e ""
+ if [[ "$node_status" != "CONFIRMED" ]]; then
+ if whiptail --yesno "Would you like to verify $CONFIG_FILE Y/N?" 8 60; then
+ ZELCONF="1"
+ zelnodeprivkey="$(whiptail --title "Deamon configuration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)"
+ zelnodeoutpoint="$(whiptail --title "Deamon configuration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3)"
+ zelnodeindex="$(whiptail --title "Deamon configuration" --inputbox "Enter your FluxNode Output Index usually a 0/1" 8 60 3>&1 1>&2 2>&3)"
+ fi
+ fi
+ flux_communication=$(curl -SsL -m 10 http://"$WANIP":"$FluxAPI"/flux/checkcommunication 2>/dev/null | jq -r .data.message 2>/dev/null)
+ if [[ "$flux_communication" != "null" && "$flux_communication" != "" ]]; then
+ echo -e "${BOOK} ${YELLOW}Checking FluxOS communication: ${NC}"
+ echo -e "${ARROW} ${CYAN}$flux_communication${NC}"
+ echo -e ""
+ fi
+ if [[ "$explorer_network_hight" != "0" ]]; then
+ echo -e "${BOOK} ${YELLOW}Checking collateral:${NC}"
+ txhash=$(grep -o "\w*" <<< "$collateral")
+ txhash=$(sed -n "2p" <<< "$txhash")
+ txhash=$(egrep "\w{10,50}" <<< "$txhash")
+ if [[ "$txhash" != "" ]]; then
+ stak_info=""
+
+ if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then
+ index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
+ stak_info=$(curl -s -m 10 https://$network_url_1/api/tx/$txhash 2>/dev/null | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2>/dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ if [[ "$stak_info" == "" ]]; then
+ stak_info=$(curl -s -m 10 https://$network_url_2/api/tx/$txhash 2>/dev/null | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2>/dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
+ fi
+ fi
- if [[ -z bench_benchmark_value ]]; then
- echo -e ""
- else
-
- if [[ "$bench_benchmark_value" -ge "$type" ]]; then
-
- case $type in
- "10000") bench_benchmark_value_name="BASIC" ;;
- "25000") bench_benchmark_value_name="SUPER" ;;
- "100000") bench_benchmark_value_name="BAMF" ;;
- esac
-
- #echo -e "${CHECK_MARK} ${CYAN} Benchmark passed for ${GREEN}$bench_benchmark${CYAN} required ${GREEN}$bench_benchmark_value_name${NC}"
- else
-
- case $type in
- "10000") bench_benchmark_value_name="BASIC" ;;
- "25000") bench_benchmark_value_name="SUPER" ;;
- "100000") bench_benchmark_value_name="BAMF" ;;
- esac
-
- if [[ "$bench_benchmark" == "running" ]]; then
- echo -en ""
+ if [[ "$stak_info" != "" ]]; then
+ type=$(awk '{print $1}' <<< "$stak_info")
+ conf=$($COIN_CLI gettxout $txhash $index_from_file | jq .confirmations)
+ if [[ $conf == ?(-)+([0-9]) ]]; then
+ if [ "$conf" -ge "100" ]; then
+ echo -e "${CHECK_MARK} ${CYAN} Confirmations numbers >= 100($conf)${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Confirmations numbers < 100($conf)${NC}"
+ fi
else
-
- # if [[ "$bench_benchmark" == "failed" ]]; then
- echo -en ""
- # else
- # echo -e "${X_MARK} ${CYAN} Benchmark passed for ${GREEN}$bench_benchmark${CYAN} required ${RED}$bench_benchmark_value_name${NC}"
- # fi
-
- fi
+ echo -e "${X_MARK} ${CYAN} FluxNode outpoint is not valid${NC}"
+ fi
+ if [[ $type == ?(-)+([0-9]) ]]; then
+ case $type in
+ "1000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}CUMULUS${NC}" ;;
+ "12500") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}NIMBUS${NC}";;
+ "40000") echo -e "${ARROW} ${CYAN}Tier: ${GREEN}STRATUS${NC}";;
+ esac
+ case $bench_benchmark in
+ "CUMULUS") bench_benchmark_value=1000 ;;
+ "NIMBUS") bench_benchmark_value=12500 ;;
+ "STRATUS") bench_benchmark_value=40000 ;;
+ esac
+ if [[ -z bench_benchmark_value ]]; then
+ echo -e ""
+ else
+ if [[ "$bench_benchmark_value" -ge "$type" ]]; then
+ case $type in
+ "1000") bench_benchmark_value_name="CUMULUS" ;;
+ "12500") bench_benchmark_value_name="NIMBUS" ;;
+ "40000") bench_benchmark_value_name="STRATUS" ;;
+ esac
+ else
+ case $type in
+ "1000") bench_benchmark_value_name="CUMULUS" ;;
+ "12500") bench_benchmark_value_name="NIMBUS" ;;
+ "40000") bench_benchmark_value_name="STRATUS" ;;
+ esac
+ if [[ "$bench_benchmark" == "running" ]]; then
+ echo -en ""
+ else
+ echo -en ""
+ fi
+ fi
+ fi
+ fi
+ else
+ echo -e "${X_MARK} ${CYAN} Flux collateral check skipped...${NC}"
fi
- fi
-
- fi
-
- else
- echo -e "${X_MARK} ${CYAN} Fluxnodeoutpoint is not valid${NC}"
+ #url_to_check="https://explorer.zel.cash/api/tx/$txhash"
+ #type=$(wget -nv -qO - $url_to_check | jq '.vout' | grep '"value"' | egrep -o '10000|25000|100000')
+ #type=$(zelcash-cli gettxout $txhash 0 | jq .value)
+ fi
fi
-#url_to_check="https://explorer.zel.cash/api/tx/$txhash"
-#type=$(wget -nv -qO - $url_to_check | jq '.vout' | grep '"value"' | egrep -o '10000|25000|100000')
-#type=$(zelcash-cli gettxout $txhash 0 | jq .value)
-fi
fi
echo -e "${NC}"
echo -e "${BOOK} ${YELLOW}Checking listen ports:${NC}"
check_listen_ports
echo -e "${NC}"
-echo -e "${BOOK} ${YELLOW}File integration checking:${NC}"
+echo -e "${BOOK} ${YELLOW}Daemon files integrity checking:${NC}"
integration
echo -e ""
-#if ! whiptail --yesno "Detected IP address is $WANIP is this correct?" 8 60; then
- #WANIP=$(whiptail --title "ZelNode ANALIZER/FiXER $SCVESION" --inputbox " Enter IP address" 8 36 3>&1 1>&2 2>&3)
-#fi
echo -e "${BOOK} ${YELLOW}Checking service:${NC}"
-
docker_working=0
-snap_docker_running=$(sudo systemctl status snap.docker.dockerd.service 2> /dev/null | grep 'running' | grep -o 'since.*')
-snap_docker_inactive=$(sudo systemctl status snap.docker.dockerd.service 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
-
docker_running=$(sudo systemctl status docker 2> /dev/null | grep 'running' | grep -o 'since.*')
docker_inactive=$(sudo systemctl status docker 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
-
mongod_running=$(sudo systemctl status mongod 2> /dev/null | grep 'running' | grep -o 'since.*')
mongod_inactive=$(sudo systemctl status mongod 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
-
daemon_running=$(sudo systemctl status zelcash 2> /dev/null | grep 'running' | grep -o 'since.*')
daemon_inactive=$(sudo systemctl status zelcash 2> /dev/null | egrep 'inactive|failed' | grep -o 'since.*')
-if sudo systemctl list-units | grep snap.docker.dockerd.service | egrep -wi 'running' > /dev/null 2>&1; then
-echo -e "${ARROW} ${CYAN}Docker(SNAP) service running ${SEA}$snap_docker_running${NC}"
-docker_working=1
-else
-
-if [ "$snap_docker_inactive" != "" ]; then
-echo -e "${ARROW} ${CYAN}Docker(SNAP) service not running ${RED}$snap_docker_inactive${NC}"
-else
-echo -e "${ARROW} ${CYAN}Docker(SNAP) is not installed${NC}"
-fi
-
-fi
-
if sudo systemctl list-units | grep docker.service | egrep -wi 'running' > /dev/null 2>&1; then
-echo -e "${ARROW} ${CYAN}Docker service running ${SEA}$docker_running${NC}"
-docker_working=1
-else
-if [[ "$docker_inactive" != "" ]]; then
-echo -e "${ARROW} ${CYAN}Docker service not running ${RED}$docker_inactive${NC}"
+ echo -e "${CHECK_MARK} ${CYAN}Docker service running ${SEA}$docker_running${NC}"
+ #docker_working=1
else
-echo -e "${ARROW} ${CYAN}Docker is not installed${NC}"
-fi
-
-fi
-
-if [[ "$docker_working" == "1" ]]; then
-echo -e "${CHECK_MARK} ${CYAN} Docker is working correct${NC}"
-else
-echo -e "${X_MARK} ${CYAN} Docker is not working${NC}"
+ if [[ "$docker_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN}Docker service not running ${RED}$docker_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN}Docker is not installed${NC}"
+ fi
fi
-
-#if systemctl list-units | grep docker.socket | egrep -wi 'running' > /dev/null 2>&1; then
-#echo -e "${CHECK_MARK} ${CYAN} Docker Socket for the API running ${SEA}$docker_socket_running${NC}"
-#else
-#if [[ "$docker_socket_inactive" != "" ]]; then
-#echo -e "${X_MARK} ${CYAN}Docker Socket for the API not running ${RED}$docker_socket_inactive ${NC}"
-#else
-#echo -e "${X_MARK} ${CYAN}Docker Socket for the API is not installed${NC}"
-#fi
-#fi
-
verifity_mongod=0
-
if sudo systemctl list-units | grep mongod | egrep -wi 'running' > /dev/null 2>&1; then
-echo -e "${CHECK_MARK} ${CYAN} MongoDB service running ${SEA}$mongod_running${NC}"
-else
-
-if [[ "$mongod_inactive" != "" ]]; then
-echo -e "${X_MARK} ${CYAN} MongoDB service not running ${RED}$mongod_inactive${NC}"
-verifity_mongod=1
+ echo -e "${CHECK_MARK} ${CYAN} MongoDB service running ${SEA}$mongod_running${NC}"
else
-echo -e "${X_MARK} ${CYAN} MongoDB service is not installed${NC}"
-fi
-
+ if [[ "$mongod_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} MongoDB service not running ${RED}$mongod_inactive${NC}"
+ verifity_mongod=1
+ else
+ echo -e "${X_MARK} ${CYAN} MongoDB service is not installed${NC}"
+ fi
fi
if sudo systemctl list-units | grep zelcash | egrep -wi 'running' > /dev/null 2>&1; then
-echo -e "${CHECK_MARK} ${CYAN} Flux daemon service running ${SEA}$daemon_running${NC}"
-else
-if [[ "$daemon_inactive" != "" ]]; then
-echo -e "${X_MARK} ${CYAN} Flux daemon service not running ${RED}$daemon_inactive${NC}"
+ echo -e "${CHECK_MARK} ${CYAN} Flux daemon service running ${SEA}$daemon_running${NC}"
else
-echo -e "${X_MARK} ${CYAN} Flux daemon service is not installed${NC}"
-fi
+ if [[ "$daemon_inactive" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} Flux daemon service not running ${RED}$daemon_inactive${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Flux daemon service is not installed${NC}"
+ fi
fi
echo -e ""
-
if [[ "$verifity_mongod" != "0" ]]; then
+ mongod_lib_dir_ownership=$(ls -l /var/lib/mongodb | awk '{print $3}' | tail -n1)
+ mongod_log_dir_ownership=$(ls -l /var/log/mongodb | awk '{print $3}' | tail -n1)
+ if [[ -f /tmp/mongodb-27017.sock ]]; then
+ mongod_tmp_sock_ownership=$(ls -l /tmp/mongodb-27017.sock | awk '{print $3}')
+ else
+ mongod_tmp_sock_ownership="mongodb"
+ fi
-
- mongod_lib_dir_ownership=$(ls -l /var/lib/mongodb | awk '{print $3}' | tail -n1)
- mongod_log_dir_ownership=$(ls -l /var/log/mongodb | awk '{print $3}' | tail -n1)
-
- if [[ -f /tmp/mongodb-27017.sock ]]; then
- mongod_tmp_sock_ownership=$(ls -l /tmp/mongodb-27017.sock | awk '{print $3}')
- else
- mongod_tmp_sock_ownership="mongodb"
- fi
-
- if [[ "$mongod_lib_dir_ownership" != "mongodb" || "$mongod_log_dir_ownership" != "mongodb" || "$mongod_tmp_sock_ownership" != "mongodb" ]]; then
-
- echo -e "${BOOK} ${YELLOW}Checking MongoDB:${NC}"
- echo -e "${X_MARK} ${CYAN} MongodDB directory/ownership detected!"
- echo
-
-
- if [[ ! -d /var/lib/mongodb ]]; then
- sudo mkdir /var/lib/mongodb > /dev/null 2>&1
- fi
-
- sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1
-
- if [[ ! -d /var/log/mongodb ]]; then
- sudo mkdir /var/log/mongodb > /dev/null 2>&1
- fi
-
- sudo chown -R mongodb:mongodb /var/log/mongodb > /dev/null 2>&1
- chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
-
- fi
-
+ if [[ "$mongod_lib_dir_ownership" != "mongodb" || "$mongod_log_dir_ownership" != "mongodb" || "$mongod_tmp_sock_ownership" != "mongodb" ]]; then
+ echo -e "${BOOK} ${YELLOW}Checking MongoDB:${NC}"
+ echo -e "${X_MARK} ${CYAN} MongodDB directory/ownership detected!"
+ echo -e ""
+ if [[ ! -d /var/lib/mongodb ]]; then
+ sudo mkdir /var/lib/mongodb > /dev/null 2>&1
+ fi
+ sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1
+ if [[ ! -d /var/log/mongodb ]]; then
+ sudo mkdir /var/log/mongodb > /dev/null 2>&1
+ fi
+ sudo chown -R mongodb:mongodb /var/log/mongodb > /dev/null 2>&1
+ chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
+ fi
fi
-
-echo -e "${BOOK} ${YELLOW}Checking Flux:${NC}"
-
+echo -e "${BOOK} ${YELLOW}Checking FluxOS:${NC}"
if pm2 -v > /dev/null 2>&1; then
-pm2_flux_status=$(pm2 info flux 2> /dev/null | grep 'status' | sed -r 's/│//gi' | sed 's/status.//g' | xargs)
-if [[ "$pm2_flux_status" == "online" ]]; then
-pm2_flux_uptime=$(pm2 info flux | grep 'uptime' | sed -r 's/│//gi' | sed 's/uptime//g' | xargs)
-pm2_flux_restarts=$(pm2 info flux | grep 'restarts' | sed -r 's/│//gi' | xargs)
-echo -e "${CHECK_MARK} ${CYAN} Pm2 Flux info => status: ${GREEN}$pm2_flux_status${CYAN}, uptime: ${GREEN}$pm2_flux_uptime${NC} ${SEA}$pm2_flux_restarts${NC}"
-else
-if [[ "$pm2_flux_status" != "" ]]; then
-echo -e "${X_MARK} ${CYAN} Pm2 Flux status: ${RED}$pm2_flux_status ${NC}"
-fi
-fi
-
-pm2_flux_status=$(pm2 info zelflux 2> /dev/null | grep 'status' | sed -r 's/│//gi' | sed 's/status.//g' | xargs)
-if [[ "$pm2_flux_status" == "online" ]]; then
-pm2_flux_uptime=$(pm2 info zelflux | grep 'uptime' | sed -r 's/│//gi' | sed 's/uptime//g' | xargs)
-pm2_flux_restarts=$(pm2 info zelflux | grep 'restarts' | sed -r 's/│//gi' | xargs)
-echo -e "${CHECK_MARK} ${CYAN} Pm2 Flux info => status: ${GREEN}$pm2_flux_status${CYAN}, uptime: ${GREEN}$pm2_flux_uptime${NC} ${SEA}$pm2_flux_restarts${NC}"
-else
-if [[ "$pm2_flux_status" != "" ]]; then
-echo -e "${X_MARK} ${CYAN} Pm2 Flux status: ${RED}$pm2_flux_status ${NC}"
-fi
-fi
-
-else
-echo -e "${X_MARK} ${CYAN} Pm2 is not installed${NC}"
-fi
-
-if [[ $(curl -s -m 5 --head "$WANIP:16126" | head -n 1 | grep "200 OK") ]]
-then
-echo -e "${CHECK_MARK} ${CYAN} Flux front is working${NC}"
-else
-echo -e "${X_MARK} ${CYAN} Flux front is not working${NC}"
-fi
-
-if [ -d /home/$USER/$FLUX_DIR ]
-then
-FILE=/home/$USER/$FLUX_DIR/config/userconfig.js
-if [ -f "$FILE" ]
-then
-
- current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
- required_ver=$(curl -sS --max-time 10 https://raw.githubusercontent.com/zelcash/zelflux/master/package.json | jq -r '.version')
-
-if [[ "$required_ver" != "" ]]; then
- if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
- echo -e "${CHECK_MARK} ${CYAN} You have the current version of Flux ${GREEN}(v$required_ver)${NC}"
- else
- echo -e "${HOT} ${CYAN}New version of Flux available ${SEA}$required_ver${NC}"
- FLUX_UPDATE="1"
- fi
- fi
-
-echo -e "${CHECK_MARK} ${CYAN} Flux config ~/$FLUX_DIR/config/userconfig.js exists${NC}"
-ZELIDLG=`echo -n $(grep -w zelid /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//') | wc -m`
-if [ "$ZELIDLG" -eq "36" ] || [ "$ZELIDLG" -eq "35" ]; then
-echo -e "${CHECK_MARK} ${CYAN} Zel ID is valid${NC}"
-elif [[ "$ZELIDLG" == "0" || "$ZELIDLG" == "2" ]]; then
-echo -e "${X_MARK} ${CYAN} Zel ID is missing...${NC}"
-else
-echo -e "${X_MARK} ${CYAN} Zel ID is not valid${NC}"
-fi
-
-if [ -f ~/$FLUX_DIR/error.log ]
-then
-echo
-echo -e "${BOOK} ${YELLOW}Flux error.log file detected, check ~/zelflux/error.log"
-echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(wc -l < /home/$USER/$FLUX_DIR/error.log)${CYAN} error events${NC}"
-error_line=$(cat /home/$USER/$FLUX_DIR/error.log | grep 'Error' | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{3\}Z//' | xargs)
-echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
-event_date=$(cat /home/$USER/$FLUX_DIR/error.log | grep 'Error' | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{3\}Z')
-event_time_uxtime=$(date -d "$event_date" +"%s")
-event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
-now_date=$(date +%s)
-tdiff=$((now_date-event_time_uxtime))
-show_time "$tdiff"
-fi
-
-if [ ! -f ~/$FLUX_DIR/ZelFront/dist/index.html ]
-then
-echo -e "${WORNING} ${CYAN}Flux problem detected, missing ~/$FLUX_DIR/ZelFront/dist/index.html"
-fi
+ pm2_flux_status=$(pm2 info flux 2> /dev/null | grep 'status' | sed -r 's/│//gi' | sed 's/status.//g' | xargs)
+ if [[ "$pm2_flux_status" == "online" ]]; then
+ pm2_flux_uptime=$(pm2 info flux | grep 'uptime' | sed -r 's/│//gi' | sed 's/uptime//g' | xargs)
+ pm2_flux_restarts=$(pm2 info flux | grep 'restarts' | sed -r 's/│//gi' | xargs)
+ echo -e "${CHECK_MARK} ${CYAN} Pm2 FluxOS info => status: ${GREEN}$pm2_flux_status${CYAN}, uptime: ${GREEN}$pm2_flux_uptime${NC} ${SEA}$pm2_flux_restarts${NC}"
+ else
+ if [[ "$pm2_flux_status" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} Pm2 FluxOS status: ${RED}$pm2_flux_status ${NC}"
+ fi
+ fi
+ pm2_flux_status=$(pm2 info zelflux 2> /dev/null | grep 'status' | sed -r 's/│//gi' | sed 's/status.//g' | xargs)
+ if [[ "$pm2_flux_status" == "online" ]]; then
+ pm2_flux_uptime=$(pm2 info zelflux | grep 'uptime' | sed -r 's/│//gi' | sed 's/uptime//g' | xargs)
+ pm2_flux_restarts=$(pm2 info zelflux | grep 'restarts' | sed -r 's/│//gi' | xargs)
+ echo -e "${CHECK_MARK} ${CYAN} Pm2 Flux info => status: ${GREEN}$pm2_flux_status${CYAN}, uptime: ${GREEN}$pm2_flux_uptime${NC} ${SEA}$pm2_flux_restarts${NC}"
+ else
+ if [[ "$pm2_flux_status" != "" ]]; then
+ echo -e "${X_MARK} ${CYAN} Pm2 FluxOS status: ${RED}$pm2_flux_status ${NC}"
+ fi
+ fi
else
-FLUXCONF="1"
- echo -e "${X_MARK} ${CYAN}Flux config ~/$FLUX_DIR/config/userconfig.js does not exists${NC}"
+ echo -e "${X_MARK} ${CYAN} Pm2 is not installed${NC}"
fi
-
+if [[ $(curl -s -m 5 --head "$WANIP:$FluxUI" | head -n 1 | grep "200 OK") ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxOS front is working${NC}"
else
- echo -e "${X_MARK} ${CYAN}Directory ~/$FLUX_DIR does not exists${CYAN}"
-fi
+ echo -e "${X_MARK} ${CYAN} FluxOS front is not working${NC}"
+fi
+if [[ -d /home/$USER/$FLUX_DIR ]]; then
+ FILE=/home/$USER/$FLUX_DIR/config/userconfig.js
+ if [[ -f "$FILE" ]]; then
+ current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
+ required_ver=$(curl -sS --max-time 10 https://raw.githubusercontent.com/RunOnFlux/flux/master/package.json | jq -r '.version')
+ if [[ "$required_ver" != "" ]]; then
+ if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
+ echo -e "${CHECK_MARK} ${CYAN} You have the current version of FluxOS ${GREEN}(v$required_ver)${NC}"
+ else
+ echo -e "${HOT} ${CYAN}New version of FluxOS available ${SEA}$required_ver${NC}"
+ FLUX_UPDATE="1"
+ fi
+ fi
+ echo -e "${CHECK_MARK} ${CYAN} FluxOS config ~/$FLUX_DIR/config/userconfig.js exists${NC}"
+ ZELIDLG=`echo -n $(grep -w zelid /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e "s/'//g" | sed -e "s/,//g" | sed -e "s/.*zelid://g") | wc -m`
+ if [[ "$ZELIDLG" -eq "35" || "$ZELIDLG" -eq "34" || "$ZELIDLG" -eq "33" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} Zel ID is valid${NC}"
+ elif [[ "$ZELIDLG" == "0" || "$ZELIDLG" == "2" ]]; then
+ echo -e "${X_MARK} ${CYAN} Zel ID is missing...${NC}"
+ else
+ echo -e "${X_MARK} ${CYAN} Zel ID is not valid${NC}"
+ fi
-if [[ "$ZELCONF" == "1" ]]
-then
-echo
-echo -e "${BOOK} ${YELLOW}Checking ~/$CONFIG_DIR/$CONFIG_FILE${NC}"
-if [[ $zelnodeprivkey == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//') ]]
-then
-echo -e "${CHECK_MARK} ${CYAN} FluxNode privkey matches${NC}"
+ if [[ -f ~/$FLUX_DIR/error.log ]]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}FluxOS error.log file detected, check ~/zelflux/error.log"
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(wc -l < /home/$USER/$FLUX_DIR/error.log)${CYAN} error events${NC}"
+ error_line=$(cat /home/$USER/$FLUX_DIR/error.log | grep 'Error' | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{3\}Z//' | xargs)
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_date=$(cat /home/$USER/$FLUX_DIR/error.log | grep 'Error' | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{3\}Z')
+ event_time_uxtime=$(date -d "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time_uxtime))
+ show_time "$tdiff"
+ fi
+ else
+ FLUXCONF="1"
+ echo -e "${X_MARK} ${CYAN}Flux config ~/$FLUX_DIR/config/userconfig.js does not exists${NC}"
+ fi
else
-REPLACE="1"
-echo -e "${X_MARK} ${CYAN} FluxNode privkey does not match${NC}"
+ echo -e "${X_MARK} ${CYAN}Directory ~/$FLUX_DIR does not exists${CYAN}"
fi
+if [[ "$ZELCONF" == "1" ]]; then
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking ~/$CONFIG_DIR/$CONFIG_FILE${NC}"
+ if [[ $zelnodeprivkey == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeprivkey=//') ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxNode Identity Key matches${NC}"
+ else
+ REPLACE="1"
+ echo -e "${X_MARK} ${CYAN} FluxNode Identity Key does not match${NC}"
+ fi
-if [[ $zelnodeoutpoint == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//') ]]
-then
-echo -e "${CHECK_MARK} ${CYAN} FluxNode outpoint matches${NC}"
-else
-REPLACE="1"
-echo -e "${X_MARK} ${CYAN} FluxNode outpoint does not match${NC}"
-fi
+ if [[ $zelnodeoutpoint == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//') ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxNode Collateral TX ID matches${NC}"
+ else
+ REPLACE="1"
+ echo -e "${X_MARK} ${CYAN} FluxNode Collateral TX ID does not match${NC}"
+ fi
-if [[ $zelnodeindex == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//') ]]
-then
-echo -e "${CHECK_MARK} ${CYAN} FluxNode index matches${NC}"
-else
-REPLACE="1"
-echo -e "${X_MARK} ${CYAN} FluxNode index does not match${NC}"
-fi
+ if [[ $zelnodeindex == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//') ]]; then
+ echo -e "${CHECK_MARK} ${CYAN} FluxNode Output Index matches${NC}"
+ else
+ REPLACE="1"
+ echo -e "${X_MARK} ${CYAN} FluxNode Output Index does not match${NC}"
+ fi
fi
-
if [[ -f /home/$USER/watchdog/package.json ]]; then
-echo
-echo -e "${BOOK} ${YELLOW}Checking Watchdog:${NC}"
-
-current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
-required_ver=$(curl -sS https://raw.githubusercontent.com/XK4MiLX/watchdog/master/package.json | jq -r '.version')
-
- if [[ "$required_ver" != "" ]]; then
- if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
- echo -e "${CHECK_MARK} ${CYAN} You have the current version of Watchdog ${GREEN}(v$required_ver)${NC}"
- else
- echo -e "${HOT} ${CYAN}New version of Watchdog available ${SEA}$required_ver${NC}"
- fi
- fi
-
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Checking Watchdog:${NC}"
+ current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
+ required_ver=$(curl -sS https://raw.githubusercontent.com/RunOnFlux/fluxnode-watchdog/master/package.json | jq -r '.version')
+ if [[ "$required_ver" != "" ]]; then
+ if [ "$(printf '%s\n' "$required_ver" "$current_ver" | sort -V | head -n1)" = "$required_ver" ]; then
+ echo -e "${CHECK_MARK} ${CYAN} You have the current version of Watchdog ${GREEN}(v$required_ver)${NC}"
+ else
+ echo -e "${HOT} ${CYAN}New version of Watchdog available ${SEA}$required_ver${NC}"
+ fi
+ fi
fi
-
if [[ -f /home/$USER/watchdog/watchdog_error.log ]]; then
-echo
-echo -e "${BOOK} ${YELLOW}Watchdog watchdog_error.log file detected, check ~/watchdog/watchdog_error.log"
-echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(wc -l < /home/$USER/watchdog/watchdog_error.log)${CYAN} error events${NC}"
-error_line=$(cat /home/$USER/watchdog/watchdog_error.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
-echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
-event_date=$(cat /home/$USER/watchdog/watchdog_error.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}' | head -n1)
-event_time_uxtime=$(date -ud "$event_date" +"%s")
-
-event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
-
-echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
-now_date=$(date +%s)
-tdiff=$((now_date-event_time_uxtime))
-show_time "$tdiff"
+ echo -e ""
+ echo -e "${BOOK} ${YELLOW}Watchdog watchdog_error.log file detected, check ~/watchdog/watchdog_error.log"
+ echo -e "${YELLOW}${WORNING} ${CYAN}Found: ${RED}$(wc -l < /home/$USER/watchdog/watchdog_error.log)${CYAN} error events${NC}"
+ error_line=$(cat /home/$USER/watchdog/watchdog_error.log | tail -1 | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.//')
+ echo -e "${PIN} ${CYAN}Last error line: $error_line${NC}"
+ event_date=$(cat /home/$USER/watchdog/watchdog_error.log | tail -1 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}.[0-9]\{2\}' | head -n1)
+ event_time_uxtime=$(date -ud "$event_date" +"%s")
+ event_human_time_local=$(date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ event_human_time_utc=$(TZ=GMT date -d @"$event_time_uxtime" +'%Y-%m-%d %H:%M:%S [%z]')
+ echo -e "${PIN} ${CYAN}Last error time: ${SEA}$event_human_time_local${NC} / ${GREEN}$event_human_time_utc${NC}"
+ now_date=$(date +%s)
+ tdiff=$((now_date-event_time_uxtime))
+ show_time "$tdiff"
fi
echo -e "${YELLOW}===================================================${NC}"
if [[ "$FLUX_UPDATE" == "1" ]]; then
-read -p "Would you like to update Flux Y/N?" -n 1 -r
-echo -e ""
-if [[ $REPLY =~ ^[Yy]$ ]]; then
-cd /home/$USER/$FLUX_DIR && git pull > /dev/null 2>&1 && cd
-current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
-required_ver=$(curl -sS https://raw.githubusercontent.com/zelcash/zelflux/master/package.json | jq -r '.version')
-if [[ "$required_ver" == "$current_ver" ]]; then
-echo -e "${CHECK_MARK} ${CYAN}Flux updated successfully.${NC}"
-echo -e ""
-else
-echo -e "${X_MARK} ${CYAN}Flux was not updated.${NC}"
-echo -e ""
-fi
-fi
+ read -p "Would you like to update Flux Y/N?" -n 1 -r
+ echo -e ""
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ cd /home/$USER/$FLUX_DIR && git pull > /dev/null 2>&1 && cd
+ current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
+ required_ver=$(curl -sS https://raw.githubusercontent.com/RunOnFlux/flux/master/package.json | jq -r '.version')
+ if [[ "$required_ver" == "$current_ver" ]]; then
+ echo -e "${CHECK_MARK} ${CYAN}Flux updated successfully.${NC}"
+ echo -e ""
+ else
+ echo -e "${X_MARK} ${CYAN}Flux was not updated.${NC}"
+ echo -e ""
+ fi
+ fi
fi
-
if [[ "$REPLACE" == "1" ]]; then
-read -p "Would you like to correct daemon config errors Y/N?" -n 1 -r
-echo -e ""
-if [[ $REPLY =~ ^[Yy]$ ]]; then
-echo -e "${YELLOW}Stopping Flux daemon serivce...${NC}"
-sudo systemctl stop "$COIN_NAME"
-sudo fuser -k 16125/tcp > /dev/null 2>&1
-echo -e ""
-
-if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "\c"
- else
- sed -i "s/$(grep -e zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeprivkey=$zelnodeprivkey/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e " ${CYAN}FluxNode privkey replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
- fi
-fi
-if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "\c"
- else
- sed -i "s/$(grep -e zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeoutpoint=$zelnodeoutpoint/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e " ${CYAN}FluxNode outpoint replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
- fi
-fi
-if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
-echo -e "\c"
- else
- sed -i "s/$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeindex=$zelnodeindex/" ~/$CONFIG_DIR/$CONFIG_FILE
- if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
- echo -e " ${CYAN}FluxNode index replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
- fi
-fi
-echo -e ""
-sudo systemctl start "$COIN_NAME"
-NUM='35'
-MSG1=' Restarting Flux daemon serivce...'
-MSG2="${CYAN}............[${CHECK_MARK}${CYAN}]${NC}"
-spinning_timer
-echo -e ""
-fi
-fi
-
-if [ "$IP_FIX" == "1" ]; then
-
-netplan_io=$(dpkg -l netplan.io | grep -w 'netplan.io' | awk '{print $3}')
-
-if [[ "$netplan_io" != "" ]]; then
-
-if [[ ! -f /etc/netplan/666-static.yaml ]]; then
-read -p "Would you like to add your public ip to netplan.io? (recommended for NAT users) Y/N?" -n 1 -r
-echo -e ""
-if [[ $REPLY =~ ^[Yy]$ ]]; then
-
-sudo ip addr add $WANIP dev $device_name:0 && sleep 2
-ip_address=$(ip a list $device_name | grep -o $WANIP.* | awk '{printf $1}')
-
-
-sudo touch /etc/netplan/666-static.yaml
-sudo chown $USER:$USER /etc/netplan/666-static.yaml
-sudo cat << EOF > /etc/netplan/666-static.yaml
-network:
- version: 2
- renderer: networkd
- ethernets:
- $device_name:
- addresses:
- - $ip_address
-EOF
-sudo chown root:root /etc/netplan/666-static.yaml
-fi
-
-fi
+ read -p "Would you like to correct daemon config errors Y/N?" -n 1 -r
+ echo -e ""
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ echo -e "${YELLOW}Stopping Flux daemon serivce...${NC}"
+ sudo systemctl stop "$COIN_NAME"
+ sudo fuser -k 16125/tcp > /dev/null 2>&1
+ echo -e ""
+ if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e "\c"
+ else
+ if [[ "$zelnodeprivkey" == "" ]]; then
+ echo -e " ${CYAN}FluxNode Identity Key skipped...............${NC}"
+ else
+ sed -i "s/$(grep -e zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeprivkey=$zelnodeprivkey/" ~/$CONFIG_DIR/$CONFIG_FILE
+ if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e " ${CYAN}FluxNode Identity Key replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ fi
-fi
+ if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e "\c"
+ else
+ if [[ "$zelnodeoutpoint" == "" ]]; then
+ echo -e " ${CYAN}FluxNode Collateral TX ID skipped...............${NC}"
+ else
+ sed -i "s/$(grep -e zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeoutpoint=$zelnodeoutpoint/" ~/$CONFIG_DIR/$CONFIG_FILE
+ if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e " ${CYAN}FluxNode Collateral TX ID replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ fi
+ if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e "\c"
+ else
+ if [[ "$zelnodeindex" == "" ]]; then
+ echo -e " ${CYAN}FluxNode Output Index skipped...............${NC}"
+ else
+ sed -i "s/$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeindex=$zelnodeindex/" ~/$CONFIG_DIR/$CONFIG_FILE
+ if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then
+ echo -e " ${CYAN}FluxNode Output Index replaced successful...............[${CHECK_MARK}${CYAN}]${NC}"
+ fi
+ fi
+ fi
+ echo -e ""
+ sudo systemctl start "$COIN_NAME"
+ NUM='35'
+ MSG1=' Restarting Flux daemon serivce...'
+ MSG2="${CYAN}............[${CHECK_MARK}${CYAN}]${NC}"
+ spinning_timer
+ echo -e ""
+ fi
fi
-echo
-#if [ "$LC_CHECK" == "1" ]; then
-#read -p "Would you like to change LC_NUMERIC to en_US.UTF-8 Y/N?" -n 1 -r
-#echo -e ""
-#if [[ $REPLY =~ ^[Yy]$ ]]; then
-#sudo bash -c 'echo "LC_NUMERIC="en_US.UTF-8"" >>/etc/default/locale'
-#echo -e ""
-#echo -e "${CHECK_MARK} ${CYAN}LC_NUMERIC changed to en_US.UTF-8 now you need restart pc${NC}"
-#read -p "Would you like to reboot pc Y/N?" -n 1 -r
-#echo -e ""
-#if [[ $REPLY =~ ^[Yy]$ ]]; then
-#sudo reboot -n
-#fi
-#fi
-#fi
+echo -e ""
diff --git a/scripts/ip_check.sh b/scripts/ip_check.sh
new file mode 100644
index 00000000..f0157d32
--- /dev/null
+++ b/scripts/ip_check.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+url_array=(
+ "https://api4.my-ip.io/ip"
+ "https://checkip.amazonaws.com"
+ "https://api.ipify.org"
+)
+
+function get_ip() {
+ for url in "$@"; do
+ WANIP=$(curl --silent -m 15 "$url" | tr -dc '[:alnum:].')
+ # Remove dots from the IP address
+ IP_NO_DOTS=$(echo "$WANIP" | tr -d '.')
+ # Check if the result is a valid number
+ if [[ "$IP_NO_DOTS" != "" && "$IP_NO_DOTS" =~ ^[0-9]+$ ]]; then
+ break
+ fi
+ done
+}
+
+function get_device_name(){
+ if [[ -f /home/$USER/device_conf.json ]]; then
+ device_name=$(jq -r .device_name /home/$USER/device_conf.json)
+ else
+ device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}')
+ fi
+}
+
+if [[ $1 == "restart" ]]; then
+ #give 3min to connect with internet
+ sleep 180
+ get_ip "${url_array[@]}"
+ get_device_name
+ if [[ "$device_name" != "" && "$WANIP" != "" ]]; then
+ date_timestamp=$(date '+%Y-%m-%d %H:%M:%S')
+ echo -e "New IP detected during $1, IP: $WANIP was added to $device_name at $date_timestamp" >> /home/$USER/ip_history.log
+ sudo ip addr add $WANIP dev $device_name && sleep 2
+ fi
+fi
+if [[ $1 == "ip_check" ]]; then
+ get_ip "${url_array[@]}"
+ get_device_name
+ api_port=$(grep -w apiport /home/$USER/zelflux/config/userconfig.js | grep -o '[[:digit:]]*')
+ if [[ "$api_port" == "" ]]; then
+ api_port="16127"
+ fi
+ confirmed_ip=$(curl -SsL -m 10 http://localhost:$api_port/flux/info 2>/dev/null | jq -r .data.node.status.ip | sed -r 's/:.+//')
+ if [[ "$WANIP" != "" && "$confirmed_ip" != "" && "$confirmed_ip" != "null" ]]; then
+ if [[ "$WANIP" != "$confirmed_ip" ]]; then
+ date_timestamp=$(date '+%Y-%m-%d %H:%M:%S')
+ echo -e "New IP detected during $1, IP: $WANIP was added to $device_name at $date_timestamp" >> /home/$USER/ip_history.log
+ sudo ip addr add $WANIP dev $device_name && sleep 2
+ fi
+ fi
+fi
diff --git a/scripts/start_daemon_service.sh b/scripts/start_daemon_service.sh
new file mode 100644
index 00000000..78cd2b7f
--- /dev/null
+++ b/scripts/start_daemon_service.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+#color codes
+RED='\033[1;31m'
+CYAN='\033[1;36m'
+NC='\033[0m'
+#emoji codes
+BOOK="${RED}\xF0\x9F\x93\x8B${NC}"
+WORNING="${RED}\xF0\x9F\x9A\xA8${NC}"
+directory="/usr/local/bin"
+current_user="$USER"
+sleep 2
+# Check if the directory exists
+if [ -d "$directory" ]; then
+ echo "Checking for files in $directory..."
+ # Use find to search for all files in the directory
+ all_files=$(find "$directory" -maxdepth 1)
+ if [ -n "$all_files" ]; then
+ # Identify files not owned by the current user
+ non_user_files=$(find "$directory" -maxdepth 1 ! -user "$current_user")
+ if [ -n "$non_user_files" ]; then
+ echo "Files not owned by $current_user found:"
+ echo "$non_user_files"
+ # Change ownership of non-user files to the current user
+ echo "Changing ownership to $current_user..."
+ sudo chown "$current_user":"$current_user" $non_user_files
+ echo "Ownership changed successfully."
+ else
+ echo "All files are owned by $current_user."
+ fi
+ else
+ echo "No files found in $directory."
+ fi
+else
+ echo "Directory $directory does not exist."
+fi
+echo -e "${BOOK} ${CYAN}Pre-start process starting...${NC}"
+echo -e "${BOOK} ${CYAN}Checking if benchmark or daemon is running${NC}"
+bench_status_pind=$(pgrep fluxbenchd)
+daemon_status_pind=$(pgrep fluxd)
+if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then
+ echo -e "${BOOK} ${CYAN}No running instance detected...${NC}"
+else
+ if [[ "$bench_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running benchmark process detected${NC}"
+ echo -e "${WORNING} Killing benchmark...${NC}"
+ sudo killall -9 fluxbenchd > /dev/null 2>&1 && sleep 2
+ fi
+ if [[ "$daemon_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running daemon process detected${NC}"
+ echo -e "${WORNING} Killing daemon...${NC}"
+ sudo killall -9 fluxd > /dev/null 2>&1 && sleep 2
+ fi
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+fi
+bench_status_pind=$(pgrep zelbenchd)
+daemon_status_pind=$(pgrep zelcashd)
+if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then
+ echo -e "${BOOK} ${CYAN}No running instance detected...${NC}"
+else
+ if [[ "$bench_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running benchmark process detected${NC}"
+ echo -e "${WORNING} Killing benchmark...${NC}"
+ sudo killall -9 zelbenchd > /dev/null 2>&1 && sleep 2
+ fi
+ if [[ "$daemon_status_pind" != "" ]]; then
+ echo -e "${WORNING} Running daemon process detected${NC}"
+ echo -e "${WORNING} Killing daemon...${NC}"
+ sudo killall -9 zelcashd > /dev/null 2>&1 && sleep 2
+ fi
+ sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1
+fi
+if [[ -f /usr/local/bin/fluxd ]]; then
+bash -c "fluxd"
+ exit
+else
+ bash -c "zelcashd"
+ exit
+fi
diff --git a/scripts/stop_daemon_service.sh b/scripts/stop_daemon_service.sh
new file mode 100644
index 00000000..02e50b77
--- /dev/null
+++ b/scripts/stop_daemon_service.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [[ -f /usr/local/bin/flux-cli ]]; then
+ bash -c "flux-cli stop"
+else
+ bash -c "zelcash-cli stop"
+fi
+exit