├── .editorconfig ├── .github ├── CODE_OF_CONDUCT.md └── ISSUE_TEMPLATE │ ├── bug.yml │ ├── feature-request.yml │ ├── question.yml │ └── share-feedback.md ├── .vscode └── settings.json ├── README.md ├── apps_info.sh ├── cdn-speedtest.sh ├── flux_common.sh ├── hardwarebench.sh ├── image ├── Menu12.jpg ├── development.jpg ├── discord1.png ├── main.jpg ├── menu_5v1.png ├── menu_v5.jpg ├── mongo.png ├── multitoolbox01.jpg ├── new_menu_v3.jpg ├── pic011.jpg ├── pic02.jpg ├── pic03.jpg ├── pic03v2.jpg ├── picm1v3.jpg ├── picm2.jpg ├── picm3.png ├── picm4.jpg ├── picm6.jpg ├── picm7.jpg ├── picm8.jpg ├── picm9.jpg ├── update_menu.png ├── v6.png ├── w1pic.jpg ├── w2pic.jpg ├── w_menu.jpg └── watchdog01.jpg ├── install_pro.sh ├── install_pro_testnet.sh ├── log_viewer.sh ├── multinode.sh ├── multitoolbox.sh ├── multitoolbox_testnet.sh ├── nodeanalizerandfixer.sh ├── post-merge └── scripts ├── ip_check.sh ├── start_daemon_service.sh └── stop_daemon_service.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | # Top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style end-of-line characters 5 | [*] 6 | end_of_line = LF 7 | 8 | # Use UTF-8 encoding 9 | [*.{sh,bash}] 10 | charset = utf-8 11 | 12 | # Indentation settings 13 | [*.{sh,bash}] 14 | indent_style = space 15 | indent_size = 2 16 | 17 | # Trailing whitespace 18 | [*.{sh,bash}] 19 | trim_trailing_whitespace = true 20 | 21 | # Insert final newline 22 | [*.{sh,bash}] 23 | insert_final_newline = true 24 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of 4 | fostering an open and welcoming community, we pledge to respect all people who 5 | contribute through reporting issues, posting feature requests, updating 6 | documentation, submitting pull requests or patches, and other activities. 7 | 8 | We are committed to making participation in this project a harassment-free 9 | experience for everyone, regardless of level of experience, gender, gender 10 | identity and expression, sexual orientation, disability, personal appearance, 11 | body size, race, ethnicity, age, religion, or nationality. 12 | 13 | Examples of unacceptable behavior by participants include: 14 | 15 | * The use of sexualized language or imagery 16 | * Personal attacks 17 | * Trolling or insulting/derogatory comments 18 | * Public or private harassment 19 | * Publishing other's private information, such as physical or electronic 20 | addresses, without explicit permission 21 | * Other unethical or unprofessional conduct 22 | 23 | Project maintainers have the right and responsibility to remove, edit, or 24 | reject comments, commits, code, wiki edits, issues, and other contributions 25 | that are not aligned to this Code of Conduct, or to ban temporarily or 26 | permanently any contributor for other behaviors that they deem inappropriate, 27 | threatening, offensive, or harmful. Note that contributors may be volunteers 28 | who do not represent Electric Coin Company. They are free to express their own 29 | opinions so long as they adhere to these guidelines. 30 | 31 | By adopting this Code of Conduct, project maintainers commit themselves to 32 | fairly and consistently applying these principles to every aspect of managing 33 | this project. Project maintainers who do not follow or enforce the Code of 34 | Conduct may be permanently removed from the project team. 35 | 36 | This Code of Conduct applies both within project spaces and in public spaces 37 | when an individual is representing the project or its community. 38 | 39 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 40 | reported by contacting a project maintainer (see below). All 41 | complaints will be reviewed and investigated and will result in a response that 42 | is deemed necessary and appropriate to the circumstances. Maintainers are 43 | obligated to maintain confidentiality with regard to the reporter of an 44 | incident. 45 | 46 | If you wish to contact specific maintainers directly, the following have made 47 | themselves available for conduct issues: 48 | 49 | - N/A 50 | 51 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 52 | version 1.3.0, available at 53 | [https://www.contributor-covenant.org/version/1/3/0/][version] 54 | 55 | [homepage]: https://www.contributor-covenant.org 56 | [version]: https://www.contributor-covenant.org/version/1/3/0/ 57 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 🐛 2 | description: Report something that's not working the way it's (probably) intended to 3 | title: '[BUG] ' 4 | labels: ['🐛 Bug'] 5 | assignees: 6 | - matthewjdegarmo 7 | body: 8 | - type: dropdown 9 | id: environment 10 | attributes: 11 | label: Environment 12 | description: Where are you running multitoolbox? 13 | options: 14 | - Self-Hosted 15 | - VPS 16 | - Other (Specify below) 17 | validations: 18 | required: true 19 | - type: input 20 | id: system 21 | attributes: 22 | label: System 23 | description: >- 24 | For deployment issues, specify your [distro or OS](https://whatsmyos.com/). 25 | placeholder: e.g. Ubuntu 20.04 LTS 26 | validations: 27 | required: false 28 | - type: input 29 | id: version 30 | attributes: 31 | label: Version 32 | description: What version of multitoolbox are you running? 33 | placeholder: v4.2.0 ← should look like this (check multitoolbox options prompt for this) 34 | validations: 35 | required: false 36 | - type: textarea 37 | id: repro 38 | attributes: 39 | label: Describe the problem 40 | description: Please describe exactly what is not working, include the steps to reproduce, actual result and expected result 41 | placeholder: When doing ABC then DEF, I expect to see XYZ, but I actually see ZYX 42 | validations: 43 | required: true 44 | - type: textarea 45 | id: logs 46 | attributes: 47 | label: Additional info 48 | description: Logs? Screenshots? Yes, please. 49 | placeholder: Take care to blank out any personal info. 50 | validations: 51 | required: false 52 | - type: checkboxes 53 | id: idiot-check 54 | attributes: 55 | label: Please tick the boxes 56 | description: Before submitting, please ensure that 57 | options: 58 | - label: You have explained the issue clearly, and included all relevant info 59 | required: true 60 | - label: You are using the latest version of multitoolbox 61 | required: true 62 | - label: You've checked that this [issue hasn't already been raised](https://github.com/RunOnFlux/fluxnode-multitool/issues?q=is%3Aissue) 63 | required: true 64 | - label: You've checked the official [RunOnFlux Discord](https://discord.gg/runonflux) Pinned messages and FAQ ![important](https://img.shields.io/badge/Important!-F6094E) 65 | required: true 66 | - label: You agree to the [code of conduct](https://github.com/RunOnFlux/fluxnode-multitool/blob/master/.github/CODE_OF_CONDUCT.md) 67 | required: true 68 | - type: markdown 69 | attributes: 70 | value: |- 71 | ## Thanks 🙏 72 | <img align="left" width="160" src="https://i.ibb.co/S5vCnhL/gh-thanks.gif" alt="🐙" /> 73 | Thank you for raising this ticket - in doing so you are helping to make the app better for everyone 💪<br> 74 | ⭐️ Consider dropping the repo a star if you're enjoying multitoolbox!<br> 75 | validations: 76 | required: false 77 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request ✨ 2 | description: Suggest an idea for future development of multitoolbox 3 | title: '[FEATURE_REQUEST] <title>' 4 | labels: ['🦄 Feature Request'] 5 | 6 | body: 7 | 8 | # Field 1 - Is it bug-related 9 | - type: textarea 10 | id: issue 11 | attributes: 12 | label: Is your feature request related to a problem? If so, please describe. 13 | description: 14 | placeholder: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 15 | validations: 16 | required: false 17 | 18 | # Field 2 - Describe feature 19 | - type: textarea 20 | id: solution 21 | attributes: 22 | label: Describe the solution you'd like 23 | placeholder: An outline of how you would like this to be implemented, include as much details as possible 24 | validations: 25 | required: true 26 | 27 | # Field 3 - Priority 28 | - type: dropdown 29 | id: priority 30 | attributes: 31 | label: Priority 32 | description: How urgent is the development of this feature 33 | options: 34 | - Low (Nice-to-have) 35 | - Medium (Would be very useful) 36 | - High (The app does not function without it) 37 | validations: 38 | required: true 39 | 40 | # Field 3 - Can the user implement 41 | - type: dropdown 42 | id: canImplement 43 | attributes: 44 | label: Is this something you would be keen to implement 45 | description: Are you raising this ticket in order to get an issue number for your PR? 46 | options: 47 | - 'No' 48 | - 'Maybe' 49 | - 'Yes!' 50 | validations: 51 | required: false 52 | 53 | # Final text 54 | - type: markdown 55 | attributes: 56 | value: |- 57 | ## Thanks 🙏 58 | Thank you for your feature suggestion! 59 | Please note that there is no guarantee that your idea will be implemented 60 | 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 61 | validations: 62 | required: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | name: Question 🤷‍♂️ 2 | description: Got a question about multitoolbox, deployment, development or usage? 3 | title: '[QUESTION] <title>' 4 | labels: ['🤷‍♂️ Question'] 5 | 6 | body: 7 | # Filed 1 - Intro Text 8 | - type: markdown 9 | attributes: 10 | value: > 11 | Thanks for using multitoolbox! Questions are welcome. 12 | Quick questions should be asked in the [Official RunOnFlux Discord](https://discord.gg/runonflux) support channels, Please. :) 13 | validations: 14 | required: false 15 | 16 | # Field 2 - The actual question 17 | - type: textarea 18 | id: question 19 | attributes: 20 | label: Question 21 | description: Outline your question in a clear and concise manner 22 | validations: 23 | required: true 24 | 25 | # Field 3 - Category 26 | - type: dropdown 27 | id: category 28 | attributes: 29 | label: Category 30 | description: What part of the application does this relate to? 31 | options: 32 | - Option 1 33 | - Option 2 34 | - Option 3 35 | - Option 4 36 | - Option 5 37 | - Option 6 38 | - Option 7 39 | - Option 8 40 | - Option 9 41 | - Option 10 42 | - Option 11 43 | - Option 12 44 | - Option 13 45 | - Option 14 46 | validations: 47 | required: true 48 | 49 | # Field 4 - User has RTFM first, and agrees to code of conduct, etc 50 | - type: checkboxes 51 | id: idiot-check 52 | attributes: 53 | label: Please tick the boxes 54 | description: Before submitting, please ensure that 55 | options: 56 | - label: You have explained the issue clearly, and included all relevant info 57 | required: true 58 | - label: You are using the latest version of multitoolbox 59 | required: true 60 | - label: You've checked that this [issue hasn't already been raised](https://github.com/RunOnFlux/fluxnode-multitool/issues?q=is%3Aissue) 61 | required: true 62 | - label: You've checked the official [RunOnFlux Discord](https://discord.gg/runonflux) Pinned messages and FAQ ![important](https://img.shields.io/badge/Important!-F6094E) 63 | required: true 64 | - label: You agree to the [code of conduct](https://github.com/RunOnFlux/fluxnode-multitool/blob/master/.github/CODE_OF_CONDUCT.md) 65 | required: true 66 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/share-feedback.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Share Feedback \U0001F308" 3 | about: Share what you think about multitoolbox, and any ideas or suggestions you have 4 | title: "[FEEDBACK]" 5 | labels: "\U0001F308 Feedback" 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 2, 3 | "editor.insertSpaces": false, 4 | "editor.detectIndentation": false 5 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MULTITOOLBOX FOR FLUXNODE OPERATORS 2 | 3 | <b>1) HOW RUN SCRIPT</b> 4 | ```bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)``` 5 | 6 | Note: If you are having difficulties, try fastgit.org provider 7 | 8 | ```bash -i <(curl -s https://raw.fastgit.org/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)``` 9 | 10 | <b>2) MENU:</b> 11 | ![screen1](https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/image/main.jpg) 12 | 13 | <b>3) HOW USE MULTITOOLBOX TO SETUP FLUXNODE:</b> 14 | https://medium.com/zelinsights/zelnode-setup-the-easy-peasy-lemon-squeezy-way-fd89706ea03c <br> 15 | https://www.youtube.com/watch?v=i4dS-683Dlo 16 | 17 | <b>4) BOOTSTRAP AUTODEPLOY SERVICE (ALWAYS FRESH COPY):</b> 18 | https://fluxnodeservice.com 19 | 20 | <b>5) HARDWARE REQUIREMENTS DEPEND ON MongoDB</b> 21 | https://www.mongodb.com/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms 22 | 23 | <br> 24 | <b>Any donations are welcomed and appreciated. Thanks.</b> 25 | <p>https://kamil.coinrequest.io</p> 26 | 27 | ``` 28 | FLUX: t1f66kBo9xzpgPJV6wvzT7MY6unpm42kvST 29 | BTC: 1NDVjrP1zg35nfSD1WBKyYSBf8dgJ8AKay 30 | ETH: 0xf515e0e2ba9347c208418c88a7d75bee3288a010 31 | LTC: LgST14gr5LH93U8NBeAdFZVwsLzxTBRTq8 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /apps_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if ! [[ -z $1 ]]; then 3 | if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then 4 | export ROOT_BRANCH="$1" 5 | export BRANCH_ALREADY_REFERENCED='1' 6 | bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/apps_info.sh) $ROOT_BRANCH $2 7 | unset ROOT_BRANCH 8 | unset BRANCH_ALREADY_REFERENCED 9 | exit 10 | fi 11 | else 12 | export ROOT_BRANCH='master' 13 | fi 14 | 15 | function max(){ 16 | m="0" 17 | for n in "$@" 18 | do 19 | if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then 20 | [ "$n" -gt "$m" ] && m="$n" 21 | fi 22 | done 23 | echo "$m" 24 | } 25 | 26 | network_url_1="explorer.zelcash.online" 27 | network_url_2="explorer.runonflux.io" 28 | 29 | apps_info=$(curl -SsL -m 10 https://api.runonflux.io/apps/globalappsspecifications) 30 | name=($(jq -r .data[].name <<< "$apps_info")) 31 | height=($(jq -r .data[].height <<< "$apps_info")) 32 | network_height_01=$(curl -sk -m 5 https://$network_url_1/api/status?q=getInfo | jq '.info.blocks') 33 | network_height_02=$(curl -sk -m 5 https://$network_url_2/api/status?q=getInfo | jq '.info.blocks') 34 | explorer_network_hight=$(max "$network_height_01" "$network_height_02") 35 | echo -e "" 36 | echo -e "Apps count: ${#name[@]}" 37 | echo -e "-------------------------------------" 38 | for((i=0;i<${#name[@]};i++)); 39 | do 40 | expire=$((${height[i]}+22000)) 41 | block_diff=$((expire-explorer_network_hight)) 42 | if [[ "$2" =~ '^[0-9]+$' ]]; then 43 | block_limit="$2" 44 | else 45 | block_limit="1000" 46 | fi 47 | if [[ "$block_diff" -le "$block_limit" ]]; then 48 | echo -e "Apps name: ${name[i]}" 49 | echo -e "Registered height: ${height[i]}" 50 | echo -e "Expire height: $expire" 51 | if [[ "$block_diff" -gt "0" ]]; then 52 | echo -e "Block till expire: $block_diff" 53 | else 54 | echo -e "Info: Apps expired!" 55 | fi 56 | echo -e "-------------------------------------" 57 | fi 58 | done 59 | unset ROOT_BRANCH 60 | unset BRANCH_ALREADY_REFERENCED 61 | -------------------------------------------------------------------------------- /cdn-speedtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Usage: 4 | # bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) "<test_time_in_s>" "<file_name>" "<array_url_list_via_export>" 5 | # 6 | # Example 1 ( for testing custom servers ): 7 | # export list=("http://cdn-11.runonflux.io/apps/fluxshare/getfile/" "http://cdn-11.runonflux.io/apps/fluxshare/getfile/") 8 | # bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) "6" "flux_explorer_bootstrap.tar.gz" "${list[@]}" 9 | # 10 | # Example 2 ( for testing cdn with 6s download test of each server ) 11 | # bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) "6" 12 | # 13 | # Example 3 ( for testing cdn with default settings ) 14 | # bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/development/cdn-speedtest.sh) 15 | # 16 | # 17 | #color codes 18 | YELLOW='\033[1;33m' 19 | GREEN='\033[1;32m' 20 | CYAN='\033[1;36m' 21 | NC='\033[0m' 22 | #emoji codes 23 | ARROW="${SEA}\xE2\x96\xB6${NC}" 24 | RIGHT_ANGLE="${GREEN}\xE2\x88\x9F${NC}" 25 | CHECK_MARK="${GREEN}\xE2\x9C\x94${NC}" 26 | #global variable 27 | failed_counter="0" 28 | 29 | if ! bc -v > /dev/null 2>&1 ; then 30 | sudo apt install -y bc > /dev/null 2>&1 && sleep 1 31 | fi 32 | if [[ -z $1 ]]; then 33 | dTime="5" 34 | else 35 | dTime="$1" 36 | fi 37 | if [[ -z $2 || "$2" == "0" ]]; then 38 | BOOTSTRAP_FILE="flux_explorer_bootstrap.tar.gz" 39 | else 40 | BOOTSTRAP_FILE="$2" 41 | fi 42 | 43 | if [[ -z $3 ]]; then 44 | rand_by_domain=("5" "6" "7" "8" "9" "10" "11" "12") 45 | else 46 | msg="$3" 47 | shift 48 | shift 49 | rand_by_domain=("$@") 50 | custom_url="1" 51 | fi 52 | size_list=() 53 | i=0 54 | len=${#rand_by_domain[@]} 55 | echo -e "${ARROW} ${CYAN}Running quick download speed test for ${BOOTSTRAP_FILE}, Servers: ${GREEN}$len${NC}" 56 | start_test=`date +%s` 57 | while [ $i -lt $len ]; 58 | do 59 | if [[ "$custom_url" == "1" ]]; then 60 | testing=$(curl -m ${dTime} ${rand_by_domain[$i]}${BOOTSTRAP_FILE} --output testspeed -fail --silent --show-error 2>&1) 61 | else 62 | testing=$(curl -m ${dTime} http://cdn-${rand_by_domain[$i]}.runonflux.io/apps/fluxshare/getfile/${BOOTSTRAP_FILE} --output testspeed -fail --silent --show-error 2>&1) 63 | fi 64 | testing_size=$(grep -Po "\d+" <<< "$testing" | paste - - - - | awk '{printf "%d\n",$3}') 65 | mb=$(bc <<<"scale=2; $testing_size / 1048576 / $dTime" | awk '{printf "%2.2f\n", $1}') 66 | if [[ "$custom_url" == "1" ]]; then 67 | domain=$(sed -e 's|^[^/]*//||' -e 's|/.*$||' <<< ${rand_by_domain[$i]}) 68 | echo -e " ${RIGHT_ANGLE} ${GREEN}URL - ${YELLOW}${domain}${GREEN} - Bits Downloaded: ${YELLOW}$testing_size${NC} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}" 69 | else 70 | 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}" 71 | fi 72 | size_list+=($testing_size) 73 | if [[ "$testing_size" == "0" ]]; then 74 | failed_counter=$(($failed_counter+1)) 75 | fi 76 | i=$(($i+1)) 77 | done 78 | rServerList=$((${#size_list[@]}-$failed_counter)) 79 | echo -e "${ARROW} ${CYAN}Valid servers: ${GREEN}${rServerList} ${CYAN}- Duration: ${GREEN}$((($(date +%s)-$start_test)/60)) min. $((($(date +%s)-$start_test) % 60)) sec.${NC}" 80 | sudo rm -rf testspeed > /dev/null 2>&1 81 | if [[ "$rServerList" == "0" ]]; then 82 | exit 83 | fi 84 | arr_max=$(printf '%s\n' "${size_list[@]}" | sort -n | tail -1) 85 | for i in "${!size_list[@]}"; do 86 | [[ "${size_list[i]}" == "$arr_max" ]] && 87 | max_indexes+=($i) 88 | done 89 | server_index=${rand_by_domain[${max_indexes[0]}]} 90 | if [[ "$custom_url" == "1" ]]; then 91 | BOOTSTRAP_URL="$server_index" 92 | else 93 | BOOTSTRAP_URL="http://cdn-${server_index}.runonflux.io/apps/fluxshare/getfile/" 94 | fi 95 | DOWNLOAD_URL="${BOOTSTRAP_URL}${BOOTSTRAP_FILE}" 96 | mb=$(bc <<<"scale=2; $arr_max / 1048576 / $dTime" | awk '{printf "%2.2f\n", $1}') 97 | if [[ "$custom_url" == "1" ]]; then 98 | domain=$(sed -e 's|^[^/]*//||' -e 's|/.*$||' <<< ${server_index}) 99 | echo -e "${ARROW} ${CYAN}Best server is: ${YELLOW}${domain} ${GREEN}Average speed: ${YELLOW}$mb ${GREEN}MB/s${NC}" 100 | else 101 | 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}" 102 | fi 103 | echo -e "${CHECK_MARK} ${GREEN}Fastest Server: ${YELLOW}${DOWNLOAD_URL}${NC}" 104 | -------------------------------------------------------------------------------- /hardwarebench.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | LC_ALL="en_US.UTF-8" 3 | LC_NUMERIC="en_US.UTF-8" 4 | LANG="en_US.UTF-8" 5 | LANGUAGE="en_US:en" 6 | SSD=0 7 | HDD=0 8 | SCORE=0 9 | RED='\033[1;31m' 10 | GREEN='\033[1;32m' 11 | NC='\033[0m' 12 | CYAN='\033[1;36m' 13 | command_exists() 14 | { 15 | command -v "$@" > /dev/null 2>&1 16 | } 17 | 18 | Bps_to_MiBps() 19 | { 20 | awk '{ printf "%.2f\n", $0 / 1024 / 1024 } END { if (NR == 0) { print "error" } }' 21 | } 22 | 23 | B_to_MiB() 24 | { 25 | awk '{ printf "%.0f MiB\n", $0 / 1024 / 1024 } END { if (NR == 0) { print "error" } }' 26 | } 27 | 28 | finish() 29 | { 30 | printf '\n' 31 | sudo rm -f test_$$ 32 | exit 33 | } 34 | 35 | trap finish EXIT INT TERM 36 | 37 | dd_benchmark() 38 | { 39 | cd $HOME && sudo LC_ALL=C timeout 25s dd if=/dev/zero of=$1/test_$$ bs=64k count=16k conv=fdatasync 2>&1 | \ 40 | awk -F, ' 41 | { 42 | io=$NF 43 | } 44 | END { 45 | if (io ~ /TB\/s/) {printf("%.0f\n", 1000*1000*1000*1000*io)} 46 | else if (io ~ /GB\/s/) {printf("%.0f\n", 1000*1000*1000*io)} 47 | else if (io ~ /MB\/s/) {printf("%.0f\n", 1000*1000*io)} 48 | else if (io ~ /KB\/s/) {printf("%.0f\n", 1000*io)} 49 | else { printf("%.0f", 1*io)} 50 | }' 51 | sudo rm -f $1/test_* 52 | } 53 | if ! command_exists dd; then 54 | printf '%s\n' 'This script requires dd, but it could not be found.' 1>&2 55 | exit 1 56 | fi 57 | if [[ "$(sysbench --version)" == "" ]]; then 58 | 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 59 | sudo apt -y install sysbench > /dev/null 2>&1 60 | if [[ "$(sysbench --version)" == "" ]]; then 61 | echo -e "" 62 | echo -e "-------------------------------------------" 63 | echo -e "| HARDWARE BENCHMARK" 64 | echo -e "-------------------------------------------" 65 | echo -e "| Benchmark: FAILED" 66 | echo -e "| Error: Sysbench installation failed..." 67 | echo -e "-------------------------------------------" 68 | echo -e "" 69 | exit 70 | fi 71 | fi 72 | vcore=$(getconf _NPROCESSORS_ONLN) 73 | 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 ) 74 | core=$(awk -F: '/cpu cores/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \\t]*//;s/[ \\t]*$//') 75 | if [[ "$core" == "" ]]; then 76 | core=$(grep 'processor' /proc/cpuinfo | wc -l) 77 | fi 78 | echo -e "" 79 | echo -e "-------------------------" 80 | echo -e "| MEMORY BENCHMARK" 81 | echo -e "-------------------------" 82 | echo -e "| RAM: ${CYAN}${ram}${NC}" 83 | echo -e "-------------------------" 84 | echo -e "| CPU BENCHMARK" 85 | echo -e "-------------------------" 86 | 87 | 88 | if [[ "$(dpkg --print-architecture)" = *"Jetson"* ]]; then 89 | cumulus_ram=3 90 | else 91 | cumulus_ram=7 92 | fi 93 | 94 | if [[ "$ram" -ge "$cumulus_ram" ]] && [[ "$vcore" -ge 4 ]]; then 95 | status="CUMULUS" 96 | fi 97 | if [[ "$ram" -ge 30 ]] && [[ "$vcore" -ge 8 ]]; then 98 | status="NIMBUS" 99 | fi 100 | if [[ "$ram" -ge 61 ]] && [[ "$vcore" -ge 16 ]]; then 101 | status="STRATUS" 102 | fi 103 | if [[ "$status" == "" ]]; then 104 | status="FAILED" 105 | fi 106 | 107 | 108 | echo -e "| CPU vcores: ${CYAN}${vcore}${NC}" 109 | 110 | if [[ "$ram" -ge "$cumulus_ram" ]] && [[ "$vcore" -ge 4 ]]; then 111 | status="CUMULUS" 112 | fi 113 | if [[ "$ram" -ge 30 ]] && [[ "$vcore" -ge 8 ]]; then 114 | status="NIMBUS" 115 | fi 116 | if [[ "$ram" -ge 61 ]] && [[ "$vcore" -ge 16 ]]; then 117 | status="STRATUS" 118 | fi 119 | if [[ "$status" == "" ]]; then 120 | status="FAILED" 121 | fi 122 | 123 | if [[ -n $FLUXOS_VERSION ]]; then 124 | outputdiskbench="Disk Bench:"; 125 | mount_size=$(sudo lvs --units g --nosuffix --noheadings -o lv_size,vg_name | awk '/vg_flux/ {sum += $1} END {print sum}') 126 | device_name=$(LC_ALL=C lsblk -l -b -n | grep 'crypt' | grep '/dat' | awk {'printf("%s\n", $1)'}) 127 | if [[ "$mount_size" != "" ]]; then 128 | mount_path="/dat" 129 | io1=$( dd_benchmark "$mount_path" ) 130 | io2=$( dd_benchmark "$mount_path" ) 131 | io3=$( dd_benchmark "$mount_path" ) 132 | if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then 133 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps ) 134 | elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then 135 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps ) 136 | else 137 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps ) 138 | fi 139 | outputdiskbench+=" $device_name $mount_size $ioavg" 140 | if [[ "${ioavg%%.*}" -ge "180" ]]; then 141 | SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$mount_size"')}') 142 | else 143 | HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$mount_size"')}') 144 | fi 145 | fi 146 | else 147 | outputdiskbench="Disks Bench:"; 148 | #checking loop for lxc only if mount == '/' 149 | loop_mount=$(cd $HOME && LC_ALL=C lsblk -l -b -n | grep 'loop' | awk '{ if ($7 == "/") printf("%.2f\n", $4/(1024*1024*1024))}') 150 | if [[ "$loop_mount" != "" ]]; then 151 | 152 | #echo -e "Device type: loop" 153 | #echo -e "" 154 | mount_path="/" 155 | io1=$( dd_benchmark "$mount_path" ) 156 | #printf '1st run: %s\n' "$(printf '%d\n' "$io1" | Bps_to_MiBps)" 157 | io2=$( dd_benchmark "$mount_path" ) 158 | #printf '2nd run: %s\n' "$(printf '%d\n' "$io2" | Bps_to_MiBps)" 159 | io3=$( dd_benchmark "$mount_path" ) 160 | #printf '3rd run: %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)" 161 | # Calculating avg I/O (better approach with awk for non int values) 162 | 163 | if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then 164 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps ) 165 | elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then 166 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps ) 167 | else 168 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps ) 169 | fi 170 | 171 | #echo -e "-----------------------------" 172 | outputdiskbench+=" loop $loop_mount $ioavg" 173 | if [[ "${ioavg%%.*}" -ge "180" ]]; then 174 | SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$loop_mount"')}') 175 | else 176 | HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$loop_mount"')}') 177 | fi 178 | echo -e "$outputdiskbench" 179 | echo -e "" 180 | exit 181 | ###In this case we exit no other partition will be tested 182 | 183 | fi 184 | ################################# 185 | lvm_mount="" 186 | raid_list=() 187 | #create disk array ( check only disk > 2GB && name not mmcblk0/mmcblk0p1 to not run disk speed on microsd cards ) 188 | 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}')) 189 | #echo -e "" 190 | #echo -e "Disk count: ${#disc__array[@]}" 191 | #echo -e "-----------------------------" 192 | for((i=0;i<${#disc__array[@]};i++)); 193 | do 194 | #checking if disk structure is accessable 195 | cd $HOME && lsblk -l -b -n /dev/${disc__array[i]} > /dev/null 2>&1 196 | if [ $? != 0 ]; then 197 | #echo -e "Disk name: ${disc__array[i]}" 198 | #echo -e "Error: Can't grab device stucture... device skipped!" 199 | #echo -e "-----------------------------" 200 | continue 201 | fi 202 | #checking direct mount 203 | 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"}') 204 | if [[ "$disk_mount_check" == "no" ]]; then 205 | #checking lvm mount 206 | lvm_mount=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{ print $7 }' ) 207 | lvm_name=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{ print $1 }' ) 208 | 209 | if [[ "$lvm_name" != "" ]]; then 210 | count=$(echo ${mount_list[@]} | tr ' ' '\n' | awk '$1 == "'"$lvm_mount"'"{print $0}' | wc -l) 211 | if [[ "$count" == "0" ]]; then 212 | mount_list+=("$lvm_mount") 213 | else 214 | #echo -e "Disk name: ${disc__array[i]}" 215 | #echo -e "Error: Mount point already checked... device skipped!" 216 | #echo -e "-----------------------------" 217 | continue 218 | fi 219 | fi 220 | 221 | if [[ "$lvm_name" != "" && "$lvm_mount" == "" ]]; then 222 | 223 | if [[ ! -d /.benchmark_test ]]; then 224 | sudo mkdir /.benchmark_test 225 | fi 226 | sudo mount /dev/mapper/$lvm_name /.benchmark_test 227 | fi 228 | 229 | lvm_mount=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --sort SIZE | egrep ' lvm| dm' | tail -n1 | awk '{ print $7 }' ) 230 | 231 | if [[ "$lvm_mount" != "" ]]; then 232 | 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) }') 233 | else 234 | 235 | #checking if disk partition type is LVM2_member 236 | 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) 237 | if [[ "$part_type_check" != "0" ]]; then 238 | #skipp disk 239 | partition_name=$(awk '{print $1}' <<< $part_type_check) 240 | #echo -e "Disk name: ${disc__array[i]}" 241 | #echo -e "Error: LVM2_member partition detected... device skipped!" 242 | #echo -e "-----------------------------" 243 | continue 244 | fi 245 | 246 | #checking raid 247 | 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) }') 248 | 249 | if [[ "$partition_output" == "" ]]; then 250 | #checking part ( when not lvm and raid ) 251 | 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) }') 252 | else 253 | 254 | partition_name=$(awk '{print $1}' <<< $partition_output) 255 | #add raid name to skip list 256 | if [[ ! " ${raid_list[@]} " =~ " ${partition_name} " ]]; then 257 | raid_list+=("$partition_name") 258 | else 259 | #skipped raid already tested 260 | #echo -e "Disk name: ${disc__array[i]}" 261 | #echo -e "Info: Disk skipped - raid already tested!" 262 | #echo -e "-----------------------------" 263 | continue 264 | fi 265 | fi 266 | fi 267 | 268 | else 269 | 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) }') 270 | fi 271 | 272 | partition_name=$(awk '{print $1}' <<< $partition_output) 273 | partition_size=$(awk '{printf("%.2f",$2)}' <<< $partition_output) 274 | 275 | if [[ "$lvm_mount" == "" && "$raid_list" == "" ]]; then 276 | disk_size=$(cd $HOME && LC_ALL=C lsblk -l -b /dev/${disc__array[i]} --noheadings | head -n1 | awk '{printf("%.2f",$4/(1024*1024*1024))}') 277 | else 278 | disk_size=$partition_size 279 | fi 280 | if [[ "$lvm_mount" == "" ]]; then 281 | if [[ ! -d /.benchmark_test ]]; then 282 | sudo mkdir /.benchmark_test 283 | fi 284 | sudo mount /dev/$partition_name /.benchmark_test 285 | 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"}') 286 | else 287 | 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"}') 288 | fi 289 | #echo -e "Disk Name: ${disc__array[i]}" 290 | #echo -e "Partition: /dev/$partition_name" 291 | #echo -e "Size: $disk_size" 292 | #echo -e "Available space: $available_space" 293 | if [[ "$available_space" != "null" && "$available_space" != "" ]]; then 294 | 295 | if [[ "$lvm_mount" == "" ]]; then 296 | mount_path="/.benchmark_test" 297 | else 298 | mount_path="$lvm_mount" 299 | fi 300 | #echo -e "Mount point: $mount_path" 301 | io1=$( dd_benchmark "$mount_path" ) 302 | #printf ' 1st run: %s\n' "$(printf '%d\n' "$io1" | Bps_to_MiBps)" 303 | io2=$( dd_benchmark "$mount_path" ) 304 | #printf ' 2nd run: %s\n' "$(printf '%d\n' "$io2" | Bps_to_MiBps)" 305 | io3=$( dd_benchmark "$mount_path" ) 306 | #printf ' 3rd run: %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)" 307 | # Calculating avg I/O (better approach with awk for non int values) 308 | if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then 309 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps ) 310 | elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then 311 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps ) 312 | else 313 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps ) 314 | fi 315 | 316 | outputdiskbench+=" ${disc__array[i]} $disk_size $ioavg" 317 | if [[ "${ioavg%%.*}" -ge "180" ]]; then 318 | SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$disk_size"')}') 319 | else 320 | HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$disk_size"')}') 321 | fi 322 | #echo -e "-----------------------------" 323 | if [[ "$lvm_mount" == "" ]]; then 324 | sudo umount /.benchmark_test 325 | if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then 326 | echo -e "" 327 | else 328 | sudo rm -rf /.benchmark_test 329 | fi 330 | 331 | fi 332 | #check if test point mounted if exist unmount it LVM case 333 | if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then 334 | sudo umount /.benchmark_test 335 | if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then 336 | echo -e "" 337 | else 338 | sudo rm -rf /.benchmark_test 339 | fi 340 | fi 341 | 342 | else 343 | 344 | #echo -e "Error: space not enough... write test skipped!" 345 | #echo -e "-----------------------------" 346 | if [[ "$lvm_mount" == "" ]]; then 347 | 348 | sudo umount /.benchmark_test 349 | if [[ $(cd $HOME && lsblk -l | grep "benchmark_test") ]]; then 350 | echo -e "" 351 | else 352 | sudo rm -rf /.benchmark_test 353 | fi 354 | fi 355 | fi 356 | 357 | done 358 | 359 | if [[ "$outputdiskbench" == "Disks Bench:" ]]; then 360 | # lsblk failed checking direct mount from df 361 | 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))}') 362 | 363 | if [[ df_direct_mount != "" ]]; then 364 | 365 | device_name=$(awk '{print $1}' <<< $df_direct_mount) 366 | partition_size=$(awk '{print $2}' <<< $df_direct_mount) 367 | 368 | #echo -e "Device name: $device_name" 369 | #echo -e "Device size: $partition_size" 370 | mount_path="/" 371 | #echo -e "Mount point: $mount_path" 372 | io1=$( dd_benchmark "$mount_path" ) 373 | #printf ' 1st run: %s\n' "$(printf '%d\n' "$io1" | Bps_to_MiBps)" 374 | io2=$( dd_benchmark "$mount_path" ) 375 | #printf ' 2nd run: %s\n' "$(printf '%d\n' "$io2" | Bps_to_MiBps)" 376 | io3=$( dd_benchmark "$mount_path" ) 377 | #printf ' 3rd run: %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)" 378 | # Calculating avg I/O (better approach with awk for non int values) 379 | 380 | if [[ "$io1" -le "$io2" ]] && [[ "$io1" -le "$io3" ]]; then 381 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io2"' + '"$io3"')/2)}' | Bps_to_MiBps ) 382 | elif [[ "$io2" -le "$io1" ]] && [[ "$io2" -le "$io3" ]]; then 383 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io3"')/2)}' | Bps_to_MiBps ) 384 | else 385 | ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"')/2)}' | Bps_to_MiBps ) 386 | fi 387 | 388 | #echo -e "-----------------------------" 389 | outputdiskbench+=" $device_name $partition_size $ioavg" 390 | if [[ "${ioavg%%.*}" -ge "180" ]]; then 391 | SSD=$(awk 'BEGIN{printf("%d",'"$SSD"'+'"$partition_size"')}') 392 | else 393 | HDD=$(awk 'BEGIN{printf("%d",'"$HDD"'+'"$partition_size"')}') 394 | fi 395 | #echo -e "$outputdiskbench" 396 | #echo -e "" 397 | fi 398 | fi 399 | fi 400 | if [[ $status == "CUMULUS" ]]; then 401 | SCORE=1 402 | fi 403 | if [[ $status == "NIMBUS" ]]; then 404 | SCORE=2 405 | fi 406 | if [[ $status == "STRATUS" ]]; then 407 | SCORE=3 408 | fi 409 | if [[ "$SSD" -lt 220 ]] || [[ "$SCORE" == 0 ]] ; then 410 | status="FAILED" 411 | fi 412 | if [[ "$SSD" -ge 220 ]] && [[ "$SCORE" -ge 1 ]]; then 413 | status="CUMULUS" 414 | eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*4}') 415 | fi 416 | if [[ "$HDD" -ge 9200 ]] && [[ "$SCORE" -ge 1 ]]; then 417 | status="THUNDER" 418 | eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*4}') 419 | fi 420 | if [[ "$SSD" -ge 440 ]] && [[ "$SCORE" -ge 2 ]]; then 421 | status="NIMBUS" 422 | eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*8}') 423 | fi 424 | if [[ "$SSD" -ge 880 ]] && [[ "$SCORE" -ge 3 ]] ; then 425 | if [[ "${ioavg%%.*}" -ge "400" ]] && [[ "$(dpkg --print-architecture)" == "amd64" ]]; then 426 | status="STRATUS" 427 | eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*16}') 428 | else 429 | status="NIMBUS" 430 | eps=$(LC_ALL=C sysbench cpu --cpu-max-prime=60000 --time=20 run 2> /dev/null | grep 'events per second' | awk '{print $4*8}') 431 | fi 432 | fi 433 | if [[ "${eps%%.*}" -lt 240 ]]; then 434 | status="FAILED" 435 | fi 436 | if [[ "${eps%%.*}" -ge 240 && "$status" == "THUNDER" ]]; then 437 | status="THUNDER" 438 | fi 439 | if [[ "${eps%%.*}" -ge 240 && "$status" == "CUMULUS" ]]; then 440 | status="CUMULUS" 441 | fi 442 | if [[ "${eps%%.*}" -ge 640 && "$status" == "NIMBUS" ]]; then 443 | status="NIMBUS" 444 | fi 445 | if [[ "${eps%%.*}" -ge 1520 && "$status" == "STRATUS" ]]; then 446 | status="STRATUS" 447 | fi 448 | if [[ "$status" != "FAILED" ]]; then 449 | echo -e "| EPS: ${CYAN}${eps}${NC}" 450 | fi 451 | echo -e "-------------------------" 452 | echo -e "| DISK BENCHMARK" 453 | echo -e "-------------------------" 454 | echo -e "| SSD: ${CYAN}${SSD}${NC}" 455 | echo -e "| HDD: ${CYAN}${HDD}${NC}" 456 | echo -e "| WRITESPEED: ${CYAN}${ioavg%%.*}${NC}" 457 | echo -e "-------------------------" 458 | if [[ "$status" != "FAILED" ]]; then 459 | echo -e "| Benchmark: ${GREEN}$status${NC}" 460 | else 461 | echo -e "| Benchmark: ${RED}$status${NC}" 462 | fi 463 | echo -e "-------------------------" 464 | -------------------------------------------------------------------------------- /image/Menu12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/Menu12.jpg -------------------------------------------------------------------------------- /image/development.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/development.jpg -------------------------------------------------------------------------------- /image/discord1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/discord1.png -------------------------------------------------------------------------------- /image/main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/main.jpg -------------------------------------------------------------------------------- /image/menu_5v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/menu_5v1.png -------------------------------------------------------------------------------- /image/menu_v5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/menu_v5.jpg -------------------------------------------------------------------------------- /image/mongo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/mongo.png -------------------------------------------------------------------------------- /image/multitoolbox01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/multitoolbox01.jpg -------------------------------------------------------------------------------- /image/new_menu_v3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/new_menu_v3.jpg -------------------------------------------------------------------------------- /image/pic011.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/pic011.jpg -------------------------------------------------------------------------------- /image/pic02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/pic02.jpg -------------------------------------------------------------------------------- /image/pic03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/pic03.jpg -------------------------------------------------------------------------------- /image/pic03v2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/pic03v2.jpg -------------------------------------------------------------------------------- /image/picm1v3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm1v3.jpg -------------------------------------------------------------------------------- /image/picm2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm2.jpg -------------------------------------------------------------------------------- /image/picm3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm3.png -------------------------------------------------------------------------------- /image/picm4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm4.jpg -------------------------------------------------------------------------------- /image/picm6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm6.jpg -------------------------------------------------------------------------------- /image/picm7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm7.jpg -------------------------------------------------------------------------------- /image/picm8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm8.jpg -------------------------------------------------------------------------------- /image/picm9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/picm9.jpg -------------------------------------------------------------------------------- /image/update_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/update_menu.png -------------------------------------------------------------------------------- /image/v6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/v6.png -------------------------------------------------------------------------------- /image/w1pic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/w1pic.jpg -------------------------------------------------------------------------------- /image/w2pic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/w2pic.jpg -------------------------------------------------------------------------------- /image/w_menu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/w_menu.jpg -------------------------------------------------------------------------------- /image/watchdog01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/8bc839c136a5a55fa950371140a82ddb1f6e67f7/image/watchdog01.jpg -------------------------------------------------------------------------------- /install_pro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/flux_common.sh)" 3 | #wallet information 4 | COIN_NAME='flux' 5 | CONFIG_DIR='.flux' 6 | CONFIG_FILE='flux.conf' 7 | BENCH_NAME='fluxbench' 8 | BENCH_CLI='fluxbench-cli' 9 | BENCH_DIR_LOG='.fluxbenchmark' 10 | COIN_DAEMON='fluxd' 11 | COIN_CLI='flux-cli' 12 | COIN_PATH='/usr/local/bin' 13 | USERNAME="$(whoami)" 14 | FLUX_DIR='zelflux' 15 | #Install variable 16 | IMPORT_ZELCONF="0" 17 | IMPORT_ZELID="0" 18 | CORRUPTED="0" 19 | BOOTSTRAP_SKIP="0" 20 | WATCHDOG_INSTALL="0" 21 | SKIP_OLD_CHAIN="0" 22 | #Zelflux ports 23 | ZELFRONTPORT=16126 24 | LOCPORT=16127 25 | ZELNODEPORT=16128 26 | #MDBPORT=27017 27 | 28 | 29 | function config_veryfity(){ 30 | if [[ -f /home/$USER/.flux/flux.conf ]]; then 31 | echo -e "${ARROW} ${YELLOW}Checking config file...${NC}" 32 | insightexplorer=$(cat /home/$USER/.flux/flux.conf | grep 'insightexplorer=1' | wc -l) 33 | if [[ "$insightexplorer" == "1" ]]; then 34 | echo -e "${ARROW} ${CYAN}Insightexplorer enabled.................[${CHECK_MARK}${CYAN}]${NC}" 35 | else 36 | echo -e "${ARROW} ${CYAN}Insightexplorer enabled.................[${X_MARK}${CYAN}]${NC}" 37 | echo -e "${ARROW} ${CYAN}Removing wallet.dat...${NC}" 38 | echo -e "${ARROW} ${CYAN}Use old chain will be skipped...${NC}" 39 | sudo rm -rf /home/$USER/$CONFIG_DIR/wallet.dat && sleep 1 40 | SKIP_OLD_CHAIN="1" 41 | fi 42 | fi 43 | } 44 | function import_date() { 45 | if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then 46 | if [[ -z "$import_settings" ]]; then 47 | if whiptail --yesno "Would you like to import data from Flux config files Y/N?" 8 60; then 48 | config_smart_create "import" 49 | IMPORT_ZELCONF="1" 50 | if [[ "$ZELID" != "" ]]; then 51 | IMPORT_ZELID="1" 52 | fi 53 | fi 54 | else 55 | if [[ "$import_settings" == "1" ]]; then 56 | config_smart_create "import" 57 | IMPORT_ZELCONF="1" 58 | if [[ "$ZELID" != "" ]]; then 59 | IMPORT_ZELID="1" 60 | fi 61 | fi 62 | fi 63 | fi 64 | echo -e "" 65 | } 66 | function install_watchdog() { 67 | echo -e "${ARROW} ${YELLOW}Watchdog installing...${NC}" 68 | if pm2 -v > /dev/null 2>&1; then 69 | WATCHDOG_INSTALL="1" 70 | cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1 71 | wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1 72 | mv post-merge /home/$USER/watchdog/.git/hooks/post-merge 73 | sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge 74 | cd watchdog && npm install > /dev/null 2>&1 75 | echo -e "${ARROW} ${CYAN}Creating config file....${NC}" 76 | fix_action='1' 77 | if [[ "$import_settings" == "0" && -f /home/$USER/install_conf.json ]]; then 78 | watchdog_conf_create 79 | if [[ -f /home/$USER/watchdog/watchdog.js ]]; then 80 | current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json) 81 | string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................." 82 | 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 83 | pm2 save > /dev/null 2>&1 84 | else 85 | string_limit_x_mark "Watchdog was not installed................................." 86 | fi 87 | return 88 | fi 89 | if [[ "$IMPORT_ZELCONF" == "1" ]]; then 90 | watchdog_conf_create 91 | if [[ -f /home/$USER/watchdog/watchdog.js ]]; then 92 | current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json) 93 | string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................." 94 | 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 95 | pm2 save > /dev/null 2>&1 96 | else 97 | string_limit_x_mark "Watchdog was not installed................................." 98 | fi 99 | return 100 | fi 101 | if whiptail --yesno "Would you like enable autoupdate?" 8 60; then 102 | flux_update='1' 103 | daemon_update='1' 104 | bench_update='1' 105 | else 106 | flux_update='0' 107 | daemon_update='0' 108 | bench_update='0' 109 | fi 110 | discord='0' 111 | if whiptail --yesno "Would you like enable alert notification?" 8 60; then 112 | sleep 1 113 | whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60 114 | sleep 1 115 | CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \ 116 | "1" "Discord notification " ON \ 117 | "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 ) 118 | if [ -z "$CHOICES" ]; then 119 | echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}" 120 | sleep 1 121 | discord="0" 122 | ping="0" 123 | telegram_alert="0" 124 | telegram_bot_token="0" 125 | telegram_chat_id="0" 126 | node_label="0" 127 | else 128 | for CHOICE in $CHOICES; 129 | do 130 | case "$CHOICE" in 131 | "1") 132 | discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3) 133 | sleep 1 134 | if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then 135 | try="0" 136 | while true 137 | do 138 | ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3) 139 | if [[ $ping == ?(-)+([0-9]) ]]; then 140 | string_limit_check_mark "UserID is valid..........................................." 141 | break 142 | else 143 | string_limit_x_mark "UserID is not valid try again............................." 144 | sleep 1 145 | try=$(($try+1)) 146 | if [[ "$try" -gt "3" ]]; then 147 | echo -e "${WORNING} ${CYAN}You have reached the maximum number of attempts...${NC}" 148 | echo -e "${WORNING} ${CYAN}Disabling ping but continue watchdog install ...${NC}" 149 | ping=0; 150 | break 151 | fi 152 | fi 153 | done 154 | sleep 1 155 | else 156 | ping=0; 157 | sleep 1 158 | fi 159 | ;; 160 | "2") 161 | telegram_alert="1" 162 | while true 163 | do 164 | telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3) 165 | if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then 166 | string_limit_check_mark "Bot token is valid..........................................." 167 | break 168 | else 169 | string_limit_x_mark "Bot token is not valid try again............................." 170 | sleep 1 171 | fi 172 | done 173 | sleep 1 174 | while true 175 | do 176 | telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3) 177 | if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then 178 | string_limit_check_mark "Chat ID is valid..........................................." 179 | break 180 | else 181 | string_limit_x_mark "Chat ID is not valid try again............................." 182 | sleep 1 183 | fi 184 | done 185 | sleep 1 186 | ;; 187 | esac 188 | done 189 | fi 190 | while true 191 | do 192 | node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3) 193 | if [[ "$node_label" != "" && "$node_label" != "0" ]]; then 194 | string_limit_check_mark "Node name is valid..........................................." 195 | break 196 | else 197 | string_limit_x_mark "Node name is not valid try again............................." 198 | sleep 1 199 | fi 200 | done 201 | else 202 | discord="0" 203 | ping="0" 204 | telegram_alert="0" 205 | telegram_bot_token="0" 206 | telegram_chat_id="0" 207 | node_label="0" 208 | sleep 1 209 | fi 210 | if [[ "$discord" == 0 ]]; then 211 | ping="0"; 212 | fi 213 | if [[ "$telegram_alert" == 0 ]]; then 214 | telegram_bot_token="0"; 215 | telegram_chat_id="0"; 216 | fi 217 | if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then 218 | index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//') 219 | tx_from_file=$(grep -w zelnodeoutpoint /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//') 220 | 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') 221 | if [[ "$stak_info" == "" ]]; then 222 | 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') 223 | fi 224 | fi 225 | if [[ $stak_info == ?(-)+([0-9]) ]]; then 226 | 227 | case $stak_info in 228 | "1000") eps_limit=240 ;; 229 | "12500") eps_limit=640 ;; 230 | "40000") eps_limit=1520 ;; 231 | esac 232 | else 233 | eps_limit=0; 234 | fi 235 | watchdog_conf_create 236 | 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 237 | pm2 save > /dev/null 2>&1 238 | if [[ -f /home/$USER/watchdog/watchdog.js ]]; then 239 | current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json) 240 | string_limit_check_mark "Watchdog v$current_ver installed................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed................................." 241 | else 242 | string_limit_x_mark "Watchdog was not installed................................." 243 | fi 244 | else 245 | string_limit_x_mark "Watchdog was not installed................................." 246 | fi 247 | } 248 | function wipe_clean() { 249 | echo -e "${ARROW} ${YELLOW}Removing any instances of FluxNode${NC}" 250 | apt_number=$(ps aux | grep 'apt' | wc -l) 251 | if [[ "$apt_number" > 1 ]]; then 252 | sudo killall apt > /dev/null 2>&1 253 | sudo killall apt-get > /dev/null 2>&1 254 | sudo dpkg --configure -a > /dev/null 2>&1 255 | fi 256 | echo -e "${ARROW} ${CYAN}Stopping all services and running processes...${NC}" 257 | sudo killall nano > /dev/null 2>&1 258 | $COIN_CLI stop > /dev/null 2>&1 && sleep 2 259 | sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2 260 | sudo killall -s SIGKILL $COIN_DAEMON > /dev/null 2>&1 && sleep 2 261 | $BENCH_CLI stop > /dev/null 2>&1 && sleep 2 262 | sudo killall -s SIGKILL $BENCH_NAME > /dev/null 2>&1 && sleep 1 263 | sudo fuser -k 16127/tcp > /dev/null 2>&1 && sleep 1 264 | sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1 265 | sudo rm -rf /usr/bin/flux* > /dev/null 2>&1 && sleep 1 266 | echo -e "${ARROW} ${CYAN}Removing daemon && benchmark...${NC}" 267 | sudo apt-get remove $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1 268 | sudo apt-get purge $COIN_NAME $BENCH_NAME -y > /dev/null 2>&1 && sleep 1 269 | sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1 270 | sudo rm -rf /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1 271 | tmux kill-server > /dev/null 2>&1 && sleep 1 272 | echo -e "${ARROW} ${CYAN}Removing PM2...${NC}" 273 | pm2 del zelflux > /dev/null 2>&1 && sleep 1 274 | pm2 del flux > /dev/null 2>&1 && sleep 1 275 | pm2 del watchdog > /dev/null 2>&1 && sleep 1 276 | pm2 save > /dev/null 2>&1 277 | pm2 unstartup > /dev/null 2>&1 && sleep 1 278 | pm2 flush > /dev/null 2>&1 && sleep 1 279 | pm2 save > /dev/null 2>&1 && sleep 1 280 | pm2 kill > /dev/null 2>&1 && sleep 1 281 | npm remove pm2 -g > /dev/null 2>&1 && sleep 1 282 | echo -e "${ARROW} ${CYAN}Removing others files and scripts...${NC}" 283 | sudo rm -rf watchgod > /dev/null 2>&1 && sleep 1 284 | sudo rm -rf $BENCH_DIR_LOG && sleep 1 285 | sudo rm -rf /etc/logrotate.d/bench_debug_log > /dev/null 2>&1 286 | sudo rm -rf /etc/logrotate.d/daemon_debug_log > /dev/null 2>&1 287 | sudo rm -rf /etc/logrotate.d/docker_debug_log > /dev/null 2>&1 288 | rm update.sh > /dev/null 2>&1 289 | rm restart_zelflux.sh > /dev/null 2>&1 290 | rm zelnodeupdate.sh > /dev/null 2>&1 291 | rm start.sh > /dev/null 2>&1 292 | rm update-zelflux.sh > /dev/null 2>&1 293 | sudo systemctl stop zelcash > /dev/null 2>&1 && sleep 2 294 | zelcash-cli stop > /dev/null 2>&1 && sleep 2 295 | sudo killall -s SIGKILL zelcashd > /dev/null 2>&1 296 | zelbench-cli stop > /dev/null 2>&1 297 | sudo killall -s SIGKILL zelbenchd > /dev/null 2>&1 298 | sudo rm /usr/local/bin/zel* > /dev/null 2>&1 && sleep 1 299 | sudo apt-get purge zelcash zelbench -y > /dev/null 2>&1 && sleep 1 300 | sudo apt-get autoremove -y > /dev/null 2>&1 && sleep 1 301 | sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 && sleep 1 302 | sudo rm -rf zelflux > /dev/null 2>&1 && sleep 1 303 | sudo rm -rf .zelbenchmark > /dev/null 2>&1 && sleep 1 304 | sudo rm -rf .fluxbenchmark > /dev/null 2>&1 && sleep 1 305 | sudo rm -rf /home/$USER/stop_zelcash_service.sh > /dev/null 2>&1 306 | sudo rm -rf /home/$USER/start_zelcash_service.sh > /dev/null 2>&1 307 | if [[ -d /home/$USER/.zelcash ]]; then 308 | echo -e "${ARROW} ${CYAN}Moving ~/.zelcash to ~/.flux${NC}" 309 | sudo mv /home/$USER/.zelcash /home/$USER/.flux > /dev/null 2>&1 && sleep 1 310 | sudo mv /home/$USER/.flux/zelcash.conf /home/$USER/.flux/flux.conf > /dev/null 2>&1 && sleep 1 311 | fi 312 | if [[ -d /home/$USER/$CONFIG_DIR ]]; then 313 | config_veryfity 314 | if [[ -z "$use_old_chain" ]]; then 315 | if [[ "$SKIP_OLD_CHAIN" == "0" ]]; then 316 | if ! whiptail --yesno "Would you like to use old chain from Flux daemon config directory?" 8 60; then 317 | echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}" 318 | 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 319 | sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 320 | else 321 | BOOTSTRAP_SKIP="1" 322 | sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat 323 | sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat 324 | sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf 325 | sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat 326 | sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat 327 | sudo rm -rf /home/$USER/$CONFIG_DIR/db.log 328 | sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log 329 | sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf 330 | sudo rm -rf /home/$USER/$CONFIG_DIR/database 331 | sudo rm -rf /home/$USER/$CONFIG_DIR/sporks 332 | fi 333 | else 334 | echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}" 335 | 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 336 | sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 337 | fi 338 | else 339 | if [[ "$use_old_chain" == "1" ]]; then 340 | BOOTSTRAP_SKIP="1" 341 | sudo rm -rf /home/$USER/$CONFIG_DIR/fee_estimates.dat 342 | sudo rm -rf /home/$USER/$CONFIG_DIR/peers.dat 343 | sudo rm -rf /home/$USER/$CONFIG_DIR/zelnode.conf 344 | sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodecache.dat 345 | sudo rm -rf /home/$USER/$CONFIG_DIR/zelnodepayments.dat 346 | sudo rm -rf /home/$USER/$CONFIG_DIR/db.log 347 | sudo rm -rf /home/$USER/$CONFIG_DIR/debug.log 348 | sudo rm -rf /home/$USER/$CONFIG_DIR/flux.conf 349 | sudo rm -rf /home/$USER/$CONFIG_DIR/database 350 | sudo rm -rf /home/$USER/$CONFIG_DIR/sporks 351 | else 352 | echo -e "${ARROW} ${CYAN}Removing Flux daemon config directory...${NC}" 353 | 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 354 | sudo rm -rf /home/$USER/$CONFIG_DIR > /dev/null 2>&1 355 | fi 356 | fi 357 | fi 358 | sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1 359 | sudo rm -rf /home/$USER/stop_daemon_service.sh > /dev/null 2>&1 360 | sudo rm -rf /home/$USER/start_daemon_service.sh > /dev/null 2>&1 361 | echo -e "${ARROW} ${YELLOW}Checking firewall status...${NC}" && sleep 1 362 | if [[ $(sudo ufw status | grep "Status: active") ]]; then 363 | sudo ufw disable > /dev/null 2>&1 364 | echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}" 365 | else 366 | echo -e "${ARROW} ${CYAN}Firewall status: ${RED}Disabled${NC}" 367 | fi 368 | } 369 | function ssh_port() { 370 | if [[ -z "$ssh_port" ]]; then 371 | SSHPORT=$(grep -w Port /etc/ssh/sshd_config | sed -e 's/.*Port //') 372 | echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1 373 | else 374 | pettern='^[0-9]+$' 375 | if [[ $ssh_port =~ $pettern ]] ; then 376 | SSHPORT="$ssh_port" 377 | echo -e "${ARROW} ${YELLOW}Using SSH port:${SEA} $SSHPORT${NC}" && sleep 1 378 | else 379 | echo -e "${ARROW} ${CYAN}SSH port must be integer................[${X_MARK}${CYAN}]${NC}}" 380 | echo 381 | exit 382 | fi 383 | fi 384 | } 385 | function create_conf() { 386 | echo -e "${ARROW} ${YELLOW}Creating Flux daemon config file...${NC}" 387 | if [ -f ~/$CONFIG_DIR/$CONFIG_FILE ]; then 388 | echo -e "${ARROW} ${CYAN}Existing conf file found backing up to $COIN_NAME.old ...${NC}" 389 | mv ~/$CONFIG_DIR/$CONFIG_FILE ~/$CONFIG_DIR/$COIN_NAME.old; 390 | fi 391 | if [[ "$IMPORT_ZELCONF" == "0" ]]; then 392 | zelnodeprivkey=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3) 393 | zelnodeoutpoint=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3) 394 | zelnodeindex=$(whiptail --title "Flux daemon configuration" --inputbox "Enter your FluxNode Output Index usually a 0/1" 8 60 3>&1 1>&2 2>&3) 395 | fi 396 | mkdir /home/$USER/$CONFIG_DIR > /dev/null 2>&1 397 | flux_daemon_conf_create 398 | if [[ "$IMPORT_ZELID" == "0" ]]; then 399 | while true 400 | do 401 | 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) 402 | 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 403 | echo -e "${ARROW} ${CYAN}Zel ID is valid${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}" 404 | break 405 | else 406 | echo -e "${ARROW} ${CYAN}Zel ID is not valid try again...........[${X_MARK}${CYAN}]${NC}" 407 | sleep 4 408 | fi 409 | done 410 | while true 411 | do 412 | 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) 413 | if [[ "$KDA_A" != "" && "$KDA_A" != *kadena* && "$KDA_A" = *k:* ]]; then 414 | echo -e "${ARROW} ${CYAN}Kadena address is valid.................[${CHECK_MARK}${CYAN}]${NC}" 415 | KDA_A="kadena:$KDA_A?chainid=0" 416 | sleep 2 417 | break 418 | else 419 | echo -e "${ARROW} ${CYAN}Kadena address is not valid.............[${X_MARK}${CYAN}]${NC}" 420 | sleep 2 421 | fi 422 | done 423 | fi 424 | } 425 | function install_daemon() { 426 | sudo rm /etc/apt/sources.list.d/zelcash.list > /dev/null 2>&1 427 | sudo rm /etc/apt/sources.list.d/flux.list > /dev/null 2>&1 428 | echo -e "${ARROW} ${YELLOW}Configuring daemon repository and importing public GPG Key${NC}" 429 | sudo chown -R $USER:$USER /usr/share/keyrings > /dev/null 2>&1 430 | sudo chown -R $USER:$USER /home/$USER/.gnupg > /dev/null 2>&1 431 | if [[ "$(lsb_release -cs)" == "xenial" ]]; then 432 | echo 'deb https://apt.runonflux.io/ '$(lsb_release -cs)' main' | sudo tee /etc/apt/sources.list.d/flux.list > /dev/null 2>&1 433 | gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B69CA27A986265D > /dev/null 2>&1 434 | gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1 435 | if ! gpg --list-keys Zel > /dev/null; then 436 | gpg --keyserver hkp://keys.gnupg.net:80 --recv-keys 4B69CA27A986265D > /dev/null 2>&1 437 | gpg --export 4B69CA27A986265D | sudo apt-key add - > /dev/null 2>&1 438 | fi 439 | flux_package && sleep 2 440 | else 441 | sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1 442 | server_check=$(curl -s -m 20 https://apt.runonflux.io/pool/main/f/flux/ | grep -o '[0-9].[0-9].[0-9]' | head -n1) 443 | if [[ $server_check == "" ]]; then 444 | 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 445 | else 446 | 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 447 | fi 448 | # downloading key && save it as keyring 449 | 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 450 | key_counter=0 451 | until [ $key_counter -gt 5 ] 452 | do 453 | if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then 454 | break 455 | fi 456 | echo -e "${CYAN}Retrieve keys failed will try again...${NC}" 457 | sleep 5 458 | sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1 459 | 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 460 | ((key_counter++)) 461 | done 462 | #if ! gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then 463 | #echo -e "${YELLOW}First attempt to retrieve keys failed will try a different keyserver.${NC}" 464 | #sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1 465 | #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 466 | #fi 467 | #if ! gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then 468 | #echo -e "${YELLOW}Last keyserver also failed will try one last keyserver.${NC}" 469 | #sudo rm /usr/share/keyrings/flux-archive-keyring.gpg > /dev/null 2>&1 470 | #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 471 | #fi 472 | if gpg -k --keyring /usr/share/keyrings/flux-archive-keyring.gpg Zel > /dev/null 2>&1; then 473 | flux_package && sleep 2 474 | else 475 | echo -e "" 476 | echo -e "${WORNING} ${RED}Importing public GPG Key failed...${NC}" 477 | echo -e "${WORNING} ${CYAN}Installation stopped...${NC}" 478 | echo -e "" 479 | exit 480 | fi 481 | fi 482 | } 483 | function basic_security() { 484 | echo -e "${ARROW} ${YELLOW}Configuring firewall and enabling fail2ban...${NC}" 485 | sudo ufw allow "$SSHPORT"/tcp > /dev/null 2>&1 486 | sudo ufw logging on > /dev/null 2>&1 487 | sudo ufw default deny incoming > /dev/null 2>&1 488 | sudo ufw allow out from any to any port 123 > /dev/null 2>&1 489 | sudo ufw allow out to any port 80 > /dev/null 2>&1 490 | sudo ufw allow out to any port 443 > /dev/null 2>&1 491 | sudo ufw allow out to any port 53 > /dev/null 2>&1 492 | #FluxOS communication 493 | sudo ufw allow 16100:16199/tcp > /dev/null 2>&1 494 | #sudo ufw default deny outgoing > /dev/null 2>&1 495 | sudo ufw limit OpenSSH > /dev/null 2>&1 496 | echo "y" | sudo ufw enable > /dev/null 2>&1 497 | sudo ufw reload > /dev/null 2>&1 498 | sudo systemctl enable fail2ban > /dev/null 2>&1 499 | sudo systemctl start fail2ban > /dev/null 2>&1 500 | } 501 | function start_daemon() { 502 | sudo systemctl enable zelcash.service > /dev/null 2>&1 503 | sudo systemctl start zelcash > /dev/null 2>&1 504 | x=1 505 | while [ $x -le 6 ] 506 | do 507 | NUM='300' 508 | MSG1='Starting daemon & syncing with chain please be patient this will take about 5 min...' 509 | MSG2='' 510 | spinning_timer 511 | chain_check=$($COIN_CLI $1 getinfo 2>&1 >/dev/null | grep "Activating" | wc -l) 512 | if [[ "$chain_check" == "1" ]]; then 513 | echo -e "" 514 | echo -e "${ARROW} ${CYAN}Activating best chain detected....Awaiting increased for next 5min${NC}" 515 | fi 516 | if [[ "$($COIN_CLI $1 getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then 517 | break 518 | fi 519 | if [[ "$x" -gt 6 ]]; then 520 | echo -e "${ARROW} ${CYAN}Maximum timeout exceeded...${NC}" 521 | break 522 | fi 523 | x=$(( $x + 1 )) 524 | done 525 | if [[ "$($COIN_CLI $1 getinfo 2>/dev/null | jq -r '.version' 2>/dev/null)" != "" ]]; then 526 | NUM='2' 527 | MSG1='Getting info...' 528 | MSG2="${CYAN}.........................[${CHECK_MARK}${CYAN}]${NC}" 529 | spinning_timer 530 | echo && echo 531 | daemon_version=$($COIN_CLI $1 getinfo | jq -r '.version') 532 | string_limit_check_mark "Flux daemon v$daemon_version installed................................." "Flux daemon ${GREEN}v$daemon_version${CYAN} installed................................." 533 | bench_version=$($BENCH_CLI $1 getinfo | jq -r '.version') 534 | string_limit_check_mark "Flux benchmark v$bench_version installed................................." "Flux benchmark ${GREEN}v$bench_version${CYAN} installed................................." 535 | echo 536 | pm2_install 537 | else 538 | echo -e "" 539 | echo -e "${WORNING} ${RED}Something is not right the daemon did not start or still loading...${NC}" 540 | if [[ -f /home/$USER/$CONFIG_DIR/debug.log ]]; then 541 | 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\}.//') 542 | if [[ "$error_line" != "" ]]; then 543 | echo -e "${WORNING} ${CYAN}Last error from ~/$CONFIG_DIR/debug.log: ${NC}" 544 | echo -e "${WORNING} ${CYAN}$error_line${NC}" 545 | echo -e "" 546 | exit 547 | fi 548 | fi 549 | 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 550 | echo -e "${ARROW} ${CYAN}Problem with daemon noticed but user want continue installation... ${NC}" 551 | echo -n "" 552 | else 553 | echo -e "${WORNING} ${RED}Installation stopped by user...${NC}" 554 | echo -n "" 555 | exit 556 | fi 557 | fi 558 | } 559 | function install_process() { 560 | echo -e "${ARROW} ${YELLOW}Configuring firewall...${NC}" 561 | sudo ufw allow $ZELFRONTPORT/tcp > /dev/null 2>&1 562 | sudo ufw allow $LOCPORT/tcp > /dev/null 2>&1 563 | sudo ufw allow $ZELNODEPORT/tcp > /dev/null 2>&1 564 | if ! sysbench --version > /dev/null 2>&1; then 565 | echo -e "" 566 | echo -e "${ARROW} ${YELLOW}Sysbench installing...${NC}" 567 | #curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh 2> /dev/null | sudo bash > /dev/null 2>&1 568 | 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 569 | sudo apt -y install sysbench > /dev/null 2>&1 570 | if sysbench --version > /dev/null 2>&1; then 571 | string_limit_check_mark "Sysbench $(sysbench --version | awk '{print $2}') installed................................." "Sysbench ${GREEN}$(sysbench --version | awk '{print $2}')${CYAN} installed................................." 572 | fi 573 | 574 | fi 575 | install_mongod 576 | install_nodejs 577 | install_flux 578 | sleep 2 579 | } 580 | function install_flux() { 581 | echo -e "${ARROW} ${YELLOW}FluxOS installing...${NC}" 582 | docker_check=$(docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l) 583 | resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l) 584 | mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1) 585 | 586 | if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then 587 | #echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1 588 | echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1 589 | echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1 590 | fi 591 | 592 | if [[ $docker_check != 0 ]]; then 593 | #echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1 594 | echo -e "${ARROW} ${CYAN}Removing containers...${NC}" 595 | sudo service docker restart > /dev/null 2>&1 && sleep 2 596 | docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | 597 | while read line; do 598 | sudo docker stop $line > /dev/null 2>&1 && sleep 2 599 | sudo docker rm $line > /dev/null 2>&1 && sleep 2 600 | done 601 | fi 602 | if [[ $resource_check != 0 ]]; then 603 | #echo -e "${ARROW} ${YELLOW}Detected locked resource${NC}" && sleep 1 604 | echo -e "${ARROW} ${CYAN}Unmounting locked FluxOS resource${NC}" && sleep 1 605 | df | egrep 'flux' | awk '{ print $1}' | 606 | while read line; do 607 | sudo umount -l $line && sleep 1 608 | done 609 | fi 610 | if [ -d "./$FLUX_DIR" ]; then 611 | echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS${NC}" 612 | sudo rm -rf $FLUX_DIR 613 | fi 614 | 615 | git clone https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1 616 | echo -e "${ARROW} ${CYAN}Creating FluxOS configuration file...${NC}" 617 | fluxos_conf_create 618 | if [ -d ~/$FLUX_DIR ]; then 619 | current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json) 620 | string_limit_check_mark "FluxOS v$current_ver installed................................." "FluxOS ${GREEN}v$current_ver${CYAN} installed................................." 621 | echo -e "" 622 | else 623 | string_limit_x_mark "FluxOS was not installed................................." 624 | echo -e "" 625 | fi 626 | } 627 | 628 | #end of functions 629 | start_install 630 | wipe_clean 631 | ssh_port 632 | get_ip "install" 633 | create_swap 634 | install_packages 635 | create_conf 636 | install_daemon 637 | zk_params 638 | if [[ "$BOOTSTRAP_SKIP" == "0" ]]; then 639 | bootstrap_new "install" 640 | fi 641 | create_service_scripts 642 | create_service "install" 643 | selfhosting "install" 644 | install_process 645 | start_daemon 646 | log_rotate "Flux benchmark" "bench_debug_log" "/home/$USER/$BENCH_DIR_LOG/debug.log" "monthly" "2" 647 | log_rotate "Flux daemon" "daemon_debug_log" "/home/$USER/$CONFIG_DIR/debug.log" "daily" "7" 648 | log_rotate "MongoDB" "mongod_debug_log" "/var/log/mongodb/*.log" "daily" "14" 649 | #log_rotate "Docker" "docker_debug_log" "/var/lib/docker/containers/*/*.log" "daily" "7" 650 | basic_security 651 | status_loop 652 | install_watchdog 653 | if [[ "$thunder" == "1" ]]; then 654 | echo -e "" 655 | echo -e "${ARROW} ${YELLOW}Thunder Mode configuration...${NC}" 656 | thunder_mode "install" 657 | fi 658 | if [[ "$gateway_ip" != "" && "$upnp_port" != "" ]] && [[ "$upnp_port" != "null" ]] && [[ "$upnp_enabled" == "true" ]] ; then 659 | upnp_enable "install" 660 | fi 661 | finalizing 662 | display_banner 663 | -------------------------------------------------------------------------------- /log_viewer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set +o history 3 | 4 | export NEWT_COLORS=' 5 | title=black, 6 | ' 7 | 8 | TMUX=$(command -v tmux) || { echo "This script requires tmux. Please install it."; exit 1; } 9 | SESSION="FLUX-$$" 10 | LAYOUT="tiled" 11 | 12 | # Log files and their titles 13 | declare -A FILES 14 | FILES+=( 15 | [Flux-Watchdog]="/dat/usr/lib/fluxwatchdog/watchdog_error.log" 16 | [Flux-Daemon]="/dat/var/lib/fluxd/debug.log" 17 | [Flux-Benchmark]="/dat/usr/lib/fluxbenchd/debug.log" 18 | [FluxOS]="/dat/usr/lib/fluxos/debug.log" 19 | [SAS]="/var/log/sas.log" 20 | [MongoDB]="/dat/var/log/mongodb/mongod.log" 21 | [Syncthing]="/dat/var/log/syncthing.log" 22 | ) 23 | 24 | # Cleanup function to kill the tmux session and its panes 25 | function at_exit() { 26 | $TMUX kill-session -t "$SESSION" >/dev/null 2>&1 27 | set -o history 28 | } 29 | 30 | # Trap SIGINT (Ctrl+C) and SIGTERM to cleanup 31 | trap at_exit SIGINT SIGTERM EXIT 32 | 33 | # Verify if all files exist and prepare the whiptail menu options 34 | MENU_OPTIONS=() 35 | for title in "${!FILES[@]}"; do 36 | LOG_FILE="${FILES[$title]}" 37 | if [ -f "$LOG_FILE" ]; then 38 | MENU_OPTIONS+=("$title" " " ON) 39 | fi 40 | done 41 | 42 | # Exit if no valid log files are found 43 | if [ "${#MENU_OPTIONS[@]}" -eq 0 ]; then 44 | echo -e "No valid log files found. Exiting." 45 | echo -e "" 46 | exit 1 47 | fi 48 | 49 | # Display whiptail menu 50 | SELECTED_FILES=$(whiptail --title "Select Log Files" --checklist \ 51 | "\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 \ 52 | "${MENU_OPTIONS[@]}" 3>&1 1>&2 2>&3) 53 | 54 | # Handle user cancel or no selection 55 | if [ $? -ne 0 ] || [ -z "$SELECTED_FILES" ]; then 56 | exit 1 57 | fi 58 | 59 | # Parse selected files into an array 60 | SELECTED_FILES=($(echo "$SELECTED_FILES" | tr -d '"')) 61 | 62 | # Start tmux session if it doesn't already exist 63 | if ! $TMUX has-session -t "$SESSION" 2>/dev/null; then 64 | $TMUX new-session -d -s "$SESSION" -n Main "printf '\033]2;Main\033\\' ; bash" 65 | else 66 | echo "Session $SESSION already exists. Attaching to it." 67 | $TMUX attach -t "$SESSION" 68 | exit 0 69 | fi 70 | 71 | # Enable mouse and adjust terminal overrides 72 | $TMUX set-option -t "$SESSION" -q mouse on 73 | $TMUX set-option -t "$SESSION" -ga terminal-overrides ',xterm*:smcup@:rmcup@' 74 | 75 | # Create panes for each selected file dynamically 76 | PANE_COUNT=0 77 | for title in "${SELECTED_FILES[@]}"; do 78 | LOG_FILE="${FILES[$title]}" 79 | echo "Opening pane for: $title ($LOG_FILE)" 80 | if sudo jq empty "$LOG_FILE" > /dev/null 2>&1; then 81 | $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'" 82 | else 83 | $TMUX split-window -t "$SESSION" "printf '\033]2;%s\033\\' '${title}' ; sudo tail -F '${LOG_FILE}'" 84 | fi 85 | PANE_COUNT=$((PANE_COUNT + 1)) 86 | $TMUX select-layout -t "$SESSION" "$LAYOUT" 87 | done 88 | 89 | # Remove the initial empty pane 90 | $TMUX kill-pane -t "${SESSION}.0" 91 | 92 | # Final tmux layout adjustments 93 | $TMUX select-layout -t "$SESSION" "$LAYOUT" 94 | 95 | # Customize tmux appearance 96 | $TMUX set-option -t "$SESSION" -g status-style bg=colour235,fg=yellow,dim 97 | $TMUX set-window-option -t "$SESSION" -g window-status-style fg=brightblue,bg=colour236,dim 98 | $TMUX set-window-option -t "$SESSION" -g window-status-current-style fg=brightred,bg=colour236,bright 99 | 100 | # Synchronize panes for uniform control 101 | $TMUX set-window-option -t "$SESSION" synchronize-panes on 102 | $TMUX set-option -t "$SESSION" pane-border-status top 103 | 104 | # Attach to the tmux session 105 | $TMUX attach -t "$SESSION" >/dev/null 2>&1 106 | -------------------------------------------------------------------------------- /multinode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ -f "/usr/lib/multitoolbox/flux_common.sh" ]]; then 3 | source "/usr/lib/multitoolbox/flux_common.sh" 4 | else 5 | source /dev/stdin <<< "$(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh")" 6 | fi 7 | 8 | function upnp_disable() { 9 | if [[ ! -f $FLUXOS_PATH/config/userconfig.js ]]; then 10 | echo -e "${WORNING} ${CYAN}Missing FluxOS configuration file - install/re-install Flux Node...${NC}" 11 | echo -e "" 12 | exit 13 | fi 14 | 15 | if [[ -f $FLUX_BENCH_PATH/fluxbench.conf ]]; then 16 | if [[ $(grep -e "fluxport" $FLUX_BENCH_PATH/fluxbench.conf) != "" ]]; then 17 | echo -e "" 18 | echo -e "${ARROW} ${YELLOW}Removing FluxOS UPnP configuration.....${NC}" 19 | if [[ -n $FLUXOS_VERSION ]]; then 20 | SUDO_CMD="sudo" 21 | fi 22 | $SUDO_CMD sed -i "/$(grep -e "fluxport" $FLUX_BENCH_PATH/fluxbench.conf)/d" $FLUX_BENCH_PATH/fluxbench.conf > /dev/null 2>&1 23 | else 24 | echo -e "${ARROW} ${CYAN}UPnP Mode is already disabled...${NC}" 25 | echo -e "" 26 | exit 27 | fi 28 | else 29 | echo -e "${ARROW} ${CYAN}UPnP Mode is already disabled...${NC}" 30 | echo -e "" 31 | exit 32 | fi 33 | if [[ $(cat $FLUXOS_PATH/config/userconfig.js | grep 'apiport' | wc -l) == "1" ]]; then 34 | RemoveLine "routerIP" 35 | RemoveLine "apiport" 36 | fi 37 | echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark.....${NC}" 38 | echo -e "" 39 | if [[ -z $FLUXOS_VERSION ]]; then 40 | sudo systemctl restart zelcash > /dev/null 2>&1 41 | pm2 restart flux > /dev/null 2>&1 42 | else 43 | sudo systemctl restart fluxbenchd > /dev/null 2>&1 44 | sudo systemctl restart fluxos > /dev/null 2>&1 45 | fi 46 | sleep 10 47 | } 48 | 49 | CHOICE=$( 50 | whiptail --title "UPnP Configuration" --menu "Make your choice" 16 30 9 \ 51 | "1)" "Enable UPnP Mode" \ 52 | "2)" "Disable UPnP Mode" 3>&2 2>&1 1>&3 53 | ) 54 | case $CHOICE in 55 | "1)") 56 | upnp_enable 57 | ;; 58 | "2)") 59 | upnp_disable 60 | ;; 61 | esac 62 | 63 | -------------------------------------------------------------------------------- /multitoolbox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #disable bash history 3 | set +o history 4 | 5 | if ! [[ -z $1 ]]; then 6 | if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then 7 | export ROOT_BRANCH="$1" 8 | export BRANCH_ALREADY_REFERENCED='1' 9 | if [[ -f "/usr/lib/multitoolbox/multitoolbox.sh" ]]; then 10 | bash -i "/usr/lib/multitoolbox/multitoolbox.sh" 11 | else 12 | bash -i <(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/multitoolbox.sh") $ROOT_BRANCH $2 13 | fi 14 | unset ROOT_BRANCH 15 | unset BRANCH_ALREADY_REFERENCED 16 | set -o history 17 | exit 18 | fi 19 | else 20 | export ROOT_BRANCH='master' 21 | fi 22 | 23 | if [[ -f "/usr/lib/multitoolbox/flux_common.sh" ]]; then 24 | source "/usr/lib/multitoolbox/flux_common.sh" 25 | else 26 | source /dev/stdin <<< "$(curl -s "https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh")" 27 | fi 28 | 29 | if [[ -d /home/$USER/.zelcash ]]; then 30 | CONFIG_DIR='.zelcash' 31 | CONFIG_FILE='zelcash.conf' 32 | else 33 | CONFIG_DIR='.flux' 34 | CONFIG_FILE='flux.conf' 35 | fi 36 | 37 | FLUX_DIR='zelflux' 38 | FLUX_APPS_DIR='ZelApps' 39 | COIN_NAME='zelcash' 40 | dversion="v8.0" 41 | PM2_INSTALL="0" 42 | zelflux_setting_import="0" 43 | OS_FLAGE="$2" 44 | 45 | function config_veryfity(){ 46 | if [[ -f $FLUX_DAEMON_PATH/flux.conf ]]; then 47 | echo -e "${ARROW} ${YELLOW}Checking config file...${NC}" 48 | insightexplorer=$(cat $FLUX_DAEMON_PATH/flux.conf | grep 'insightexplorer=1' | wc -l) 49 | if [[ "$insightexplorer" == "1" ]]; then 50 | echo -e "${ARROW} ${CYAN}Insightexplorer enabled..............[${CHECK_MARK}${CYAN}]${NC}" 51 | echo "" 52 | else 53 | echo -e "${WORNING} ${CYAN}Insightexplorer disabled.............[${X_MARK}${CYAN}]${NC}" 54 | echo -e "${WORNING} ${CYAN}Use option 2 for node re-install${NC}" 55 | echo -e "" 56 | exit 57 | fi 58 | fi 59 | } 60 | 61 | function config_file() { 62 | if [[ -f $DATA_PATH/install_conf.json ]]; then 63 | import_settings=$(cat $DATA_PATH/install_conf.json | jq -r '.import_settings') 64 | bootstrap_url=$(cat $DATA_PATH/install_conf.json | jq -r '.bootstrap_url') 65 | bootstrap_zip_del=$(cat $DATA_PATH/install_conf.json | jq -r '.bootstrap_zip_del') 66 | use_old_chain=$(cat $DATA_PATH/install_conf.json | jq -r '.use_old_chain') 67 | prvkey=$(cat $DATA_PATH/install_conf.json | jq -r '.prvkey') 68 | outpoint=$(cat $DATA_PATH/install_conf.json | jq -r '.outpoint') 69 | index=$(cat $DATA_PATH/install_conf.json | jq -r '.index') 70 | zel_id=$(cat $DATA_PATH/install_conf.json | jq -r '.zelid') 71 | kda_address=$(cat $DATA_PATH/install_conf.json | jq -r '.kda_address') 72 | upnp_port=$(cat $DATA_PATH/install_conf.json | jq -r '.upnp_port') 73 | gateway_ip=$(cat $DATA_PATH/install_conf.json | jq -r '.gateway_ip') 74 | upnp_enabled=$(cat $DATA_PATH/install_conf.json | jq -r '.upnp_enabled') 75 | thunder=$(cat $DATA_PATH/install_conf.json | jq -r '.thunder') 76 | echo -e "${ARROW} ${YELLOW}Install config summary:" 77 | if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then 78 | echo -e "${PIN}${CYAN}Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}" 79 | else 80 | if [[ "$import_settings" == "1" ]]; then 81 | echo -e "${PIN}${CYAN}Import settings from exist config files..........................[${CHECK_MARK}${CYAN}]${NC}" 82 | fi 83 | fi 84 | if [[ "$use_old_chain" == "1" ]]; then 85 | echo -e "${PIN}${CYAN}During re-installation old chain will be used....................[${CHECK_MARK}${CYAN}]${NC}" 86 | else 87 | if [[ "$bootstrap_url" == "" || "$bootstrap_url" == "0" ]]; then 88 | echo -e "${PIN}${CYAN}Use Flux Bootstrap from source build in scripts..................[${CHECK_MARK}${CYAN}]${NC}" 89 | else 90 | echo -e "${PIN}${CYAN}Use Flux Bootstrap from own source...............................[${CHECK_MARK}${CYAN}]${NC}" 91 | fi 92 | if [[ "$bootstrap_zip_del" == "1" ]]; then 93 | echo -e "${PIN}${CYAN}Remove Flux Bootstrap archive file...............................[${CHECK_MARK}${CYAN}]${NC}" 94 | else 95 | echo -e "${PIN}${CYAN}Leave Flux Bootstrap archive file................................[${CHECK_MARK}${CYAN}]${NC}" 96 | fi 97 | fi 98 | if [[ ( "$discord" != "" && "$discord" != "0" ) || "$telegram_alert" == '1' ]]; then 99 | echo -e "${PIN}${CYAN}Enable watchdog notification.....................................[${CHECK_MARK}${CYAN}]${NC}" 100 | else 101 | echo -e "${PIN}${CYAN}Disable watchdog notification....................................[${CHECK_MARK}${CYAN}]${NC}" 102 | fi 103 | 104 | if [[ ! -z $gateway_ip && ! -z $upnp_port ]] && [[ "$upnp_enabled" == "true" ]] ; then 105 | echo -e "${PIN}${CYAN}Enable UPnP configuration........................................[${CHECK_MARK}${CYAN}]${NC}" 106 | fi 107 | fi 108 | } 109 | function install_flux() { 110 | echo -e "${GREEN}Module: Re-install FluxOS${NC}" 111 | echo -e "${YELLOW}================================================================${NC}" 112 | if [[ -z $FLUXOS_VERSION ]]; then 113 | if [[ "$USER" == "root" || "$USER" == "ubuntu" ]]; then 114 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 115 | echo -e "${CYAN}Please switch to the user account.${NC}" 116 | echo -e "${YELLOW}================================================================${NC}" 117 | echo -e "${NC}" 118 | exit 119 | fi 120 | fi 121 | if [[ -z $FLUXOS_VERSION ]]; then 122 | if pm2 -v > /dev/null 2>&1; then 123 | pm2 del zelflux > /dev/null 2>&1 124 | pm2 del flux > /dev/null 2>&1 125 | pm2 save > /dev/null 2>&1 126 | fi 127 | else 128 | echo -e "${ARROW} ${CYAN}Stopping FluxOS....${NC}" 129 | sudo systemctl stop flux-watchdog > /dev/null 2>&1 130 | sudo systemctl stop fluxos > /dev/null 2>&1 131 | sudo systemctl stop syncthing > /dev/null 2>&1 132 | fi 133 | fluxos_clean 134 | if [[ -f $FLUXOS_PATH/config/userconfig.js ]]; then 135 | echo -e "${ARROW} ${CYAN}Import settings...${NC}" 136 | ZELID=$(grep -w zelid $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//') 137 | WANIP=$(grep -w ipaddress $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*ipaddress: .//' | sed -e 's/.\{2\}$//') 138 | echo -e "${PIN}${CYAN}Flux/SSP ID = ${GREEN}$ZELID${NC}" 139 | #KDA_A=$(grep -w kadena $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//') 140 | #if [[ "$KDA_A" != "" ]]; then 141 | #echo -e "${PIN}${CYAN}Kadena address = ${GREEN}$KDA_A${NC}" 142 | #fi 143 | echo -e "${PIN}${CYAN}IP = ${GREEN}$WANIP${NC}" 144 | upnp_port=$(grep -w apiport $FLUXOS_PATH/config/userconfig.js | egrep -o '[0-9]+') 145 | if [[ "$upnp_port" != "" ]]; then 146 | echo -e "${PIN}${CYAN}API port = ${GREEN}$upnp_port${NC}" 147 | fi 148 | router_ip=$(grep -w routerIP $FLUXOS_PATH/config/userconfig.js | sed -e 's/.*routerIP: .//' | sed -e 's/.\{2\}$//') 149 | if [[ "$router_ip" != "" ]]; then 150 | echo -e "${PIN}${CYAN}Router IP = ${GREEN}$router_ip${NC}" 151 | fi 152 | ImportBlockedPorts 153 | if [[ "$blockedPortsList" != "" ]]; then 154 | echo -e "${PIN}${CYAN}BlockedPorts: [$display]${NC}" 155 | fi 156 | ImportBlockedRepository 157 | if [[ "$blockedRepositoryList" != "" ]]; then 158 | echo -e "${PIN}${CYAN}BlockedRepositories: [$display]${NC}" 159 | fi 160 | echo -e "" 161 | echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS....${NC}" 162 | sudo rm -rf $FLUXOS_PATH > /dev/null 2>&1 && sleep 1 163 | if [[ "$ZELID" != "" && "$WANIP" != "" ]]; then 164 | zelflux_setting_import="1" 165 | fi 166 | fi 167 | if [ -d $FLUXOS_PATH ]; then 168 | echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS....${NC}" 169 | sudo rm -rf $FLUXOS_PATH > /dev/null 2>&1 && sleep 1 170 | fi 171 | if [[ ! -z $FLUXOS_VERSION ]]; then 172 | cd $DATA_PATH/usr/lib 173 | FLUXOS_HOME_DIR="fluxos" 174 | fi 175 | if [[ -z $FLUXOS_VERSION ]]; then 176 | FLUXOS_HOME_DIR="zelflux" 177 | fi 178 | echo -e "${ARROW} ${CYAN}FluxOS downloading...${NC}" 179 | if [[ -n $FLUXOS_VERSION ]]; then 180 | SUDO_CMD="sudo" 181 | fi 182 | $SUDO_CMD git clone https://github.com/RunOnFlux/flux.git $FLUXOS_HOME_DIR > /dev/null 2>&1 && sleep 1 183 | if [[ -d $FLUXOS_PATH ]]; then 184 | if [[ -f $FLUXOS_PATH/package.json ]]; then 185 | current_ver=$(jq -r '.version' $FLUXOS_PATH/package.json) 186 | else 187 | string_limit_x_mark "FluxOS was not downloaded, run script again..........................................." 188 | echo 189 | exit 190 | fi 191 | string_limit_check_mark "FluxOS v$current_ver downloaded..........................................." "FluxOS ${GREEN}v$current_ver${CYAN} downloaded..........................................." 192 | else 193 | string_limit_x_mark "FluxOS was not downloaded, run script again..........................................." 194 | echo 195 | exit 196 | fi 197 | if [[ "$zelflux_setting_import" == "0" ]]; then 198 | get_ip "install" 199 | while true 200 | do 201 | 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)" 202 | 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 203 | string_limit_check_mark "Flux/SSP ID is valid..........................................." 204 | break 205 | else 206 | string_limit_x_mark "Flux/SSP ID is not valid try again..........................................." 207 | sleep 2 208 | fi 209 | done 210 | #if [[ -z $FLUXOS_VERSION ]]; then 211 | #while true 212 | #do 213 | #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) 214 | #if [[ "$KDA_A" != "" && "$KDA_A" != *kadena* && "$KDA_A" = *k:* ]]; then 215 | #echo -e "${ARROW} ${CYAN}Kadena address is valid.................[${CHECK_MARK}${CYAN}]${NC}" 216 | #KDA_A="kadena:$KDA_A?chainid=0" 217 | #sleep 2 218 | #break 219 | #else 220 | #echo -e "${ARROW} ${CYAN}Kadena address is not valid.............[${X_MARK}${CYAN}]${NC}" 221 | #sleep 2 222 | #fi 223 | #done 224 | #fi 225 | fi 226 | fluxos_conf_create 227 | if [[ -f $FLUXOS_PATH/config/userconfig.js ]]; then 228 | if [[ "$upnp_port" != "" ]]; then 229 | config_builder "apiport" "$upnp_port" "API Port" "fluxos" 230 | fi 231 | if [[ "$router_ip" != "" ]]; then 232 | config_builder "routerIP" "$router_ip" "Router IP" "fluxos" 233 | fi 234 | if [[ "$blockedPortsList" != "" ]]; then 235 | RemoveLine "blockedPorts" 236 | buildBlockedPortsList " blockedPorts" "$blockedPortsList" "Blocked ports list created successfully!" "fluxos" 237 | fi 238 | if [[ "$blockedRepositoryList" != "" ]]; then 239 | RemoveLine "blockedRepositories" 240 | buildBlockedRepositoryList " blockedRepositories" "$blockedRepositoryList" "Blocked repositories list created successfully!" "fluxos" 241 | fi 242 | string_limit_check_mark "FluxOS configuration successfull..........................................." 243 | else 244 | string_limit_x_mark "FluxOS installation failed, missing config file..........................................." 245 | echo 246 | exit 247 | fi 248 | if [[ -z $FLUXOS_VERSION ]]; then 249 | if pm2 -v > /dev/null 2>&1; then 250 | rm restart_zelflux.sh > /dev/null 2>&1 251 | pm2 del flux > /dev/null 2>&1 252 | pm2 del zelflux > /dev/null 2>&1 253 | pm2 save > /dev/null 2>&1 254 | echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}" 255 | echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}" 256 | echo -e "" 257 | 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 258 | pm2 save > /dev/null 2>&1 259 | pm2 list 260 | else 261 | pm2_install 262 | if [[ "$PM2_INSTALL" == "1" ]]; then 263 | echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}" 264 | echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}" 265 | echo 266 | pm2 list 267 | fi 268 | fi 269 | else 270 | echo -e "${ARROW} ${CYAN}Installing FluxOS dependencies will take 5min....${NC}" 271 | cd $FLUXOS_PATH 272 | sudo npm install --omit=dev --cache /dat/usr/lib/npm > /dev/null 2>&1 273 | echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}" 274 | echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}" 275 | echo 276 | sudo systemctl start syncthing > /dev/null 2>&1 277 | sudo systemctl start flux-watchdog > /dev/null 2>&1 278 | sudo systemctl restart fluxbenchd > /dev/null 2>&1 279 | sudo systemctl start fluxos > /dev/null 2>&1 280 | fi 281 | } 282 | function create_config() { 283 | echo -e "${GREEN}Module: Create FluxNode installation config file...${NC}" 284 | echo -e "${YELLOW}================================================================${NC}" 285 | if [[ -z $FLUXOS_VERSION ]]; then 286 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 287 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 288 | echo -e "${CYAN}Please switch to the user account.${NC}" 289 | echo -e "${YELLOW}================================================================${NC}" 290 | echo -e "${NC}" 291 | exit 292 | fi 293 | fi 294 | if jq --version > /dev/null 2>&1; then 295 | sleep 0.2 296 | else 297 | echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}" 298 | sudo apt install jq -y > /dev/null 2>&1 299 | if jq --version > /dev/null 2>&1; then 300 | string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................." 301 | echo 302 | else 303 | string_limit_x_mark "JQ was not installed................................." 304 | echo 305 | exit 306 | fi 307 | fi 308 | 309 | CHOICE=$(whiptail --title "Create FluxNode installation config" --menu "Make your choice" 15 65 8 \ 310 | "1)" "Manualy - fill questions list" \ 311 | "2)" "Auto - import exists settings" 3>&2 2>&1 1>&3 ) 312 | case $CHOICE in 313 | "1)") 314 | manual_build 315 | ;; 316 | "2)") 317 | config_smart_create 318 | ;; 319 | esac 320 | } 321 | function install_watchdog() { 322 | if [[ -z $FLUXOS_VERSION ]]; then 323 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 324 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 325 | echo -e "${CYAN}Please switch to the user account.${NC}" 326 | echo -e "${YELLOW}================================================================${NC}" 327 | echo -e "${NC}" 328 | exit 329 | fi 330 | fi 331 | echo -e "${GREEN}Module: Install watchdog for FluxNode${NC}" 332 | echo -e "${YELLOW}================================================================${NC}" 333 | echo -e "${ARROW} ${CYAN}Cleaning...${NC}" 334 | if [[ -z $FLUXOS_VERSION ]]; then 335 | if ! pm2 -v > /dev/null 2>&1; then 336 | pm2_install 337 | if [[ "$PM2_INSTALL" == "0" ]]; then 338 | exit 339 | fi 340 | echo -e "" 341 | fi 342 | pm2 del watchdog > /dev/null 2>&1 343 | pm2 save > /dev/null 2>&1 344 | sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1 345 | echo -e "${ARROW} ${CYAN}Downloading...${NC}" 346 | cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1 347 | echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}" 348 | wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1 349 | mv post-merge /home/$USER/watchdog/.git/hooks/post-merge 350 | sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge 351 | echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}" 352 | cd watchdog && npm install > /dev/null 2>&1 353 | else 354 | sudo systemctl stop flux-watchdog 355 | cd $FLUX_WATCHDOG_PATH 356 | cd .. 357 | sudo rm -rf $FLUX_WATCHDOG_PATH > /dev/null 2>&1 358 | echo -e "${ARROW} ${CYAN}Downloading...${NC}" 359 | git clone https://github.com/RunOnFlux/fluxnode-watchdog.git flux-watchdog > /dev/null 2>&1 360 | echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}" 361 | wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1 362 | mv post-merge $FLUX_WATCHDOG_PATH/.git/hooks/post-merge 363 | sudo chmod +x $FLUX_WATCHDOG_PATH/.git/hooks/post-merge 364 | echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}" 365 | cd flux-watchdog && npm install > /dev/null 2>&1 366 | fi 367 | echo -e "${ARROW} ${CYAN}Creating config file....${NC}" 368 | if whiptail --yesno "Would you like enable FluxOS auto update?" 8 60; then 369 | flux_update='1' 370 | sleep 1 371 | else 372 | flux_update='0' 373 | sleep 1 374 | fi 375 | if whiptail --yesno "Would you like enable Flux daemon auto update?" 8 60; then 376 | daemon_update='1' 377 | sleep 1 378 | else 379 | daemon_update='0' 380 | sleep 1 381 | fi 382 | if whiptail --yesno "Would you like enable Flux benchmark auto update?" 8 60; then 383 | bench_update='1' 384 | sleep 1 385 | else 386 | bench_update='0' 387 | sleep 1 388 | fi 389 | fix_action='1' 390 | telegram_alert=0; 391 | discord=0; 392 | if whiptail --yesno "Would you like enable alert notification?" 8 60; then 393 | sleep 1 394 | whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60 395 | sleep 1 396 | CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \ 397 | "1" "Discord notification " ON \ 398 | "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 ) 399 | if [[ -z "$CHOICES" ]]; then 400 | echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}" 401 | sleep 1 402 | discord=0; 403 | ping=0; 404 | telegram_alert=0; 405 | telegram_bot_token=0; 406 | telegram_chat_id=0; 407 | node_label=0; 408 | else 409 | for CHOICE in $CHOICES; do 410 | case "$CHOICE" in 411 | "1") 412 | discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3) 413 | sleep 1 414 | if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then 415 | while true 416 | do 417 | ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3) 418 | if [[ $ping == ?(-)+([0-9]) ]]; then 419 | string_limit_check_mark "UserID is valid..........................................." 420 | break 421 | else 422 | string_limit_x_mark "UserID is not valid try again............................." 423 | sleep 1 424 | fi 425 | done 426 | sleep 1 427 | else 428 | ping=0; 429 | sleep 1 430 | fi 431 | ;; 432 | "2") 433 | telegram_alert=1; 434 | while true 435 | do 436 | telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3) 437 | if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then 438 | string_limit_check_mark "Bot token is valid..........................................." 439 | break 440 | else 441 | string_limit_x_mark "Bot token is not valid try again............................." 442 | sleep 1 443 | fi 444 | done 445 | sleep 1 446 | while true 447 | do 448 | telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3) 449 | if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then 450 | string_limit_check_mark "Chat ID is valid..........................................." 451 | break 452 | else 453 | string_limit_x_mark "Chat ID is not valid try again............................." 454 | sleep 1 455 | fi 456 | done 457 | sleep 1 458 | ;; 459 | esac 460 | done 461 | fi 462 | while true 463 | do 464 | node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3) 465 | if [[ "$node_label" != "" && "$node_label" != "0" ]]; then 466 | string_limit_check_mark "Node name is valid..........................................." 467 | break 468 | else 469 | string_limit_x_mark "Node name is not valid try again............................." 470 | sleep 1 471 | fi 472 | done 473 | sleep 1 474 | else 475 | node_label=0; 476 | discord=0; 477 | ping=0; 478 | telegram_alert=0; 479 | telegram_bot_token=0; 480 | telegram_chat_id=0; 481 | sleep 1 482 | fi 483 | if [[ $discord == 0 ]]; then 484 | ping=0; 485 | fi 486 | if [[ $telegram_alert == 0 ]]; then 487 | telegram_bot_token=0; 488 | telegram_chat_id=0; 489 | fi 490 | if [[ -f $FLUX_BENCH_PATH/$CONFIG_FILE ]]; then 491 | index_from_file=$(grep -w zelnodeindex $FLUX_BENCH_PATH/$CONFIG_FILE | sed -e 's/zelnodeindex=//') 492 | tx_from_file=$(grep -w zelnodeoutpoint $FLUX_BENCH_PATH/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//') 493 | 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') 494 | if [[ "$stak_info" == "" ]]; then 495 | 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') 496 | fi 497 | fi 498 | if [[ $stak_info == ?(-)+([0-9]) ]]; then 499 | case $stak_info in 500 | "1000") eps_limit=240 ;; 501 | "12500") eps_limit=640 ;; 502 | "40000") eps_limit=1520 ;; 503 | esac 504 | else 505 | eps_limit=0; 506 | fi 507 | watchdog_conf_create 508 | echo -e "${ARROW} ${CYAN}Starting watchdog...${NC}" 509 | if [[ -z $FLUXOS_VERSION ]]; then 510 | 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 511 | pm2 save > /dev/null 2>&1 512 | else 513 | sudo systemctl start flux-watchdog > /dev/null 2>&1 514 | fi 515 | if [[ -f $FLUX_WATCHDOG_PATH/watchdog.js ]]; then 516 | current_ver=$(jq -r '.version' $FLUX_WATCHDOG_PATH/package.json) 517 | string_limit_check_mark "Watchdog v$current_ver installed..........................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed..........................................." 518 | else 519 | string_limit_x_mark "Watchdog was not installed..........................................." 520 | fi 521 | echo -e "" 522 | } 523 | function flux_daemon_bootstrap() { 524 | echo -e "${GREEN}Module: Restore Flux blockchain from bootstrap${NC}" 525 | echo -e "${YELLOW}================================================================${NC}" 526 | if [[ -z $FLUXOS_VERSION ]]; then 527 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 528 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 529 | echo -e "${CYAN}Please switch to the user account.${NC}" 530 | echo -e "${YELLOW}================================================================${NC}" 531 | echo -e "${NC}" 532 | exit 533 | fi 534 | fi 535 | cd 536 | echo -e "${NC}" 537 | #config_veryfity 538 | bootstrap_new 539 | } 540 | function install_node(){ 541 | echo -e "${GREEN}Module: Install FluxNode${NC}" 542 | echo -e "${YELLOW}================================================================${NC}" 543 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 544 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 545 | echo -e "${CYAN}Please switch to the user account.${NC}" 546 | echo -e "${YELLOW}================================================================${NC}" 547 | echo -e "${NC}" 548 | exit 549 | fi 550 | 551 | if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then 552 | echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}" 553 | echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation" 554 | echo -e "${WORNING} ${CYAN}Installation stopped...${NC}" 555 | echo 556 | exit 557 | fi 558 | 559 | if [[ "$OS_FLAGE" == "" ]]; then 560 | os_check 561 | fi 562 | 563 | if sudo docker run hello-world > /dev/null 2>&1; then 564 | echo -e "" 565 | else 566 | echo -e "${WORNING}${CYAN}Docker is not working correct or is not installed.${NC}" 567 | exit 568 | fi 569 | bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro.sh) 570 | } 571 | function install_docker(){ 572 | echo -e "${GREEN}Module: Install Docker${NC}" 573 | echo -e "${YELLOW}================================================================${NC}" 574 | if [[ "$USER" != "root" ]]; then 575 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 576 | echo -e "${CYAN}Please switch to the root account use command 'sudo su -'.${NC}" 577 | echo -e "${YELLOW}================================================================${NC}" 578 | echo -e "${NC}" 579 | exit 580 | fi 581 | if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then 582 | echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}" 583 | echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation" 584 | echo -e "${WORNING} ${CYAN}Installation stopped...${NC}" 585 | echo 586 | exit 587 | fi 588 | 589 | if [[ "$OS_FLAGE" == "" ]]; then 590 | os_check 591 | fi 592 | 593 | if [[ -z "$usernew" ]]; then 594 | usernew="$(whiptail --title "MULTITOOLBOX $dversion" --inputbox "Enter your username" 8 72 3>&1 1>&2 2>&3)" 595 | usernew=$(awk '{print tolower($0)}' <<< "$usernew") 596 | else 597 | echo -e "${PIN}${CYAN} Import docker user '$usernew' from environment variable............[${CHECK_MARK}${CYAN}]${NC}" 598 | fi 599 | echo -e "${ARROW} ${CYAN}New User: ${GREEN}${usernew}${NC}" 600 | adduser --gecos "" "$usernew" 601 | usermod -aG sudo "$usernew" > /dev/null 2>&1 602 | echo -e "${ARROW} ${YELLOW}Update and upgrade system...${NC}" 603 | apt update -y && apt upgrade -y 604 | if ! ufw version > /dev/null 2>&1; then 605 | echo -e "${ARROW} ${YELLOW}Installing ufw firewall..${NC}" 606 | sudo apt-get install -y ufw > /dev/null 2>&1 607 | fi 608 | cron_check=$(systemctl status cron 2> /dev/null | grep 'active' | wc -l) 609 | if [[ "$cron_check" == "0" ]]; then 610 | echo -e "${ARROW} ${YELLOW}Installing crontab...${NC}" 611 | sudo apt-get install -y cron > /dev/null 2>&1 612 | fi 613 | echo -e "${ARROW} ${YELLOW}Installing docker...${NC}" 614 | echo -e "${ARROW} ${CYAN}Architecture: ${GREEN}$(dpkg --print-architecture)${NC}" 615 | if [[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then 616 | sudo rm /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1 617 | fi 618 | if [[ -f /etc/apt/sources.list.d/docker.list ]]; then 619 | sudo rm /etc/apt/sources.list.d/docker.list > /dev/null 2>&1 620 | fi 621 | if [[ $(lsb_release -d) = *Debian* ]]; then 622 | sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1 623 | sudo apt-get update -y > /dev/null 2>&1 624 | sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1 625 | sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1 626 | #curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - > /dev/null 2>&1 627 | #sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /dev/null 2>&1 628 | curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1 629 | 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 630 | sudo apt-get update -y > /dev/null 2>&1 631 | sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1 632 | else 633 | sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1 634 | sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1 635 | sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1 636 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1 637 | 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 638 | #curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - > /dev/null 2>&1 639 | #sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /dev/null 2>&1 640 | sudo apt-get update -y > /dev/null 2>&1 641 | sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1 642 | fi 643 | echo -e "${ARROW} ${YELLOW}Adding $usernew to docker group...${NC}" 644 | adduser "$usernew" docker 645 | echo -e "${NC}" 646 | echo -e "${YELLOW}=====================================================${NC}" 647 | echo -e "${YELLOW}Running through some checks...${NC}" 648 | echo -e "${YELLOW}=====================================================${NC}" 649 | if sudo docker run hello-world > /dev/null 2>&1; then 650 | echo -e "${CHECK_MARK} ${CYAN}Docker is installed${NC}" 651 | else 652 | echo -e "${X_MARK} ${CYAN}Docker did not installed${NC}" 653 | fi 654 | if [[ $(getent group docker | grep "$usernew") ]]; then 655 | echo -e "${CHECK_MARK} ${CYAN}User $usernew is member of 'docker'${NC}" 656 | else 657 | echo -e "${X_MARK} ${CYAN}User $usernew is not member of 'docker'${NC}" 658 | fi 659 | echo -e "${YELLOW}=====================================================${NC}" 660 | echo -e "${NC}" 661 | read -p "Would you like switch to user account Y/N?" -n 1 -r 662 | echo -e "${NC}" 663 | if [[ $REPLY =~ ^[Yy]$ ]]; then 664 | su - $usernew 665 | fi 666 | } 667 | function mongod_db_fix() { 668 | echo -e "${GREEN}Module: MongoDB Repair Assistant${NC}" 669 | echo -e "${YELLOW}================================================================${NC}" 670 | if [[ -z $FLUXOS_VERSION ]]; then 671 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 672 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 673 | echo -e "${CYAN}Please switch to the user account.${NC}" 674 | echo -e "${YELLOW}================================================================${NC}" 675 | echo -e "${NC}" 676 | exit 677 | fi 678 | fi 679 | if [[ -z $FLUXOS_VERSION ]]; then 680 | CHOICE=$( 681 | whiptail --title "MongoDB Repair Assistant" --menu "Make your choice" 15 65 8 \ 682 | "1)" "Soft repair - MongoDB database repair" \ 683 | "2)" "Hard repair - MongoDB re-install" 3>&2 2>&1 1>&3 684 | ) 685 | else 686 | CHOICE=$( 687 | whiptail --title "MongoDB FiX action" --menu "Make your choice" 15 65 8 \ 688 | "1)" "Soft repair - MongoDB database repair" \ 689 | "2)" "Hard repair - MongoDB database wipe" 3>&2 2>&1 1>&3 690 | ) 691 | fi 692 | case $CHOICE in 693 | "1)") 694 | echo -e "" 695 | echo -e "${ARROW} ${YELLOW}Soft repair starting... ${NC}" 696 | echo -e "${ARROW} ${CYAN}Stopping MongoDB service ${NC}" 697 | sudo systemctl stop mongod 698 | echo -e "${ARROW} ${CYAN}Fixing corrupted DB ${NC}" 699 | sudo rm $MONGODB_DATA_PATH/journal/* > /dev/null 2>&1 700 | sudo rm $MONGODB_DATA_PATH/mongod.lock > /dev/null 2>&1 701 | sudo -u mongodb mongod --dbpath $MONGODB_DATA_PATH --repair > /dev/null 2>&1 702 | echo -e "${ARROW} ${CYAN}Setting privilege ${NC}" 703 | sudo chown -R mongodb:mongodb $MONGODB_DATA_PATH > /dev/null 2>&1 704 | sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1 705 | echo -e "${ARROW} ${CYAN}Starting MongoDB service ${NC}" 706 | sudo systemctl start mongod 707 | if mongod --version > /dev/null 2>&1; then 708 | 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................................." 709 | echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}" 710 | fi 711 | echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}" 712 | if [[ -z $FLUXOS_VERSION ]]; then 713 | sudo systemctl restart zelcash > /dev/null 2>&1 714 | pm2 restart flux > /dev/null 2>&1 715 | else 716 | sudo systemctl restart fluxd > /dev/null 2>&1 717 | sudo systemctl restart fluxbenchd > /dev/null 2>&1 718 | sudo systemctl restart fluxos > /dev/null 2>&1 719 | fi 720 | sleep 5 721 | echo -e "" 722 | ;; 723 | "2)") 724 | echo -e "" 725 | echo -e "${ARROW} ${YELLOW}Hard repair starting... ${NC}" 726 | echo -e "${ARROW} ${CYAN}Stopping MongoDB service...${NC}" 727 | sudo systemctl stop mongod 728 | if [[ -z $FLUXOS_VERSION ]]; then 729 | echo -e "${ARROW} ${CYAN}Removing MongoDB... ${NC}" 730 | sudo apt-get remove -f mongodb-org* -y > /dev/null 2>&1 731 | sudo apt-get purge --allow-change-held-packages mongodb-org* -y > /dev/null 2>&1 732 | sudo apt autoremove -y > /dev/null 2>&1 733 | echo -e "${ARROW} ${CYAN}Removing Database... ${NC}" 734 | sudo rm -r /var/log/mongodb > /dev/null 2>&1 735 | sudo rm -r /var/lib/mongodb > /dev/null 2>&1 736 | echo -e "${ARROW} ${CYAN}Installing MongoDB... ${NC}" 737 | avx_check=$(cat /proc/cpuinfo | grep -o avx | head -n1) 738 | os_version=$(lsb_release -rs | tr -d '.') 739 | architecture=$(dpkg --print-architecture) 740 | if [[ $(lsb_release -d) = *Debian* ]]; then 741 | os_name="Debian" 742 | fi 743 | if [[ $(lsb_release -d) = *Ubuntu* ]]; then 744 | os_name="Ubuntu" 745 | fi 746 | #Ubuntu MongoDB 4.4 747 | if [[ "$avx_check" == "" && "$os_name" == "Ubuntu" && "$architecture" == "amd64" && "$os_version" -le "2010" ]] || [[ "$os_name" == "Ubuntu" && "$architecture" == "arm64" && "$os_version" -le "2010" ]]; then 748 | install_mongod="4.4" 749 | fi 750 | #Debian MongoDB 4.4 751 | if [[ "$avx_check" == "" && "$os_name" == "Debian" && "$architecture" == "amd64" && "$os_version" -le "9" ]] || [[ "$os_name" == "Debian" && "$architecture" == "arm64" && "$os_version" -le "9" ]]; then 752 | install_mongod="4.4" 753 | fi 754 | if [[ "$install_mongod" == "4.4" ]]; then 755 | sudo apt update -y > /dev/null 2>&1 756 | 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 757 | echo "mongodb-org hold" | sudo dpkg --set-selections > /dev/null 2>&1 && sleep 2 758 | echo "mongodb-org-server hold" | sudo dpkg --set-selections > /dev/null 2>&1 759 | echo "mongodb-org-shell hold" | sudo dpkg --set-selections > /dev/null 2>&1 760 | echo "mongodb-org-mongos hold" | sudo dpkg --set-selections > /dev/null 2>&1 761 | echo "mongodb-org-tools hold" | sudo dpkg --set-selections > /dev/null 2>&1 762 | else 763 | sudo apt update -y > /dev/null 2>&1 764 | DEBIAN_FRONTEND=noninteractive sudo apt-get --yes install mongodb-org > /dev/null 2>&1 765 | fi 766 | sudo mkdir -p /var/log/mongodb > /dev/null 2>&1 767 | sudo mkdir -p /var/lib/mongodb > /dev/null 2>&1 768 | echo -e "${ARROW} ${CYAN}Settings privilege... ${NC}" 769 | sudo chown -R mongodb:mongodb /var/log/mongodb > /dev/null 2>&1 770 | sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1 771 | sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1 772 | fluxos_clean 773 | #echo -e "${ARROW} ${CYAN}Restoring Database... ${NC}" 774 | #mongorestore --drop --archive=/home/$USER/mongoDB_backup.gz > /dev/null 2>&1 775 | echo -e "${ARROW} ${CYAN}Starting mongod service... ${NC}" 776 | sudo systemctl enable mongod 777 | sudo systemctl start mongod 778 | if mongod --version > /dev/null 2>&1; then 779 | 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................................." 780 | echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}" 781 | else 782 | string_limit_x_mark "MongoDB was not installed................................." 783 | fi 784 | echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}" 785 | sudo systemctl restart zelcash > /dev/null 2>&1 786 | pm2 restart flux > /dev/null 2>&1 787 | sleep 5 788 | echo -e "" 789 | else 790 | echo -e "${ARROW} ${CYAN}Stopping Flux Watchdog service... ${NC}" 791 | sudo systemctl stop flux-watchdog > /dev/null 2>&1 792 | echo -e "${ARROW} ${CYAN}Stopping Fluxd service... ${NC}" 793 | sudo systemctl stop fluxd > /dev/null 2>&1 794 | echo -e "${ARROW} ${CYAN}Stopping Fluxbench service... ${NC}" 795 | sudo systemctl stop fluxbenchd > /dev/null 2>&1 796 | echo -e "${ARROW} ${CYAN}Stopping FluxOS service... ${NC}" 797 | sudo systemctl stop fluxos > /dev/null 2>&1 798 | sudo rm -rf /var/lib/mongodb/* 799 | fluxos_clean 800 | echo -e "${ARROW} ${CYAN}Starting MongoDB service... ${NC}" 801 | sudo systemctl start mongod > /dev/null 2>&1 802 | echo -e "${ARROW} ${CYAN}Starting Syncthing service... ${NC}" 803 | sudo systemctl start syncthing > /dev/null 2>&1 804 | echo -e "${ARROW} ${CYAN}Starting FluxOS service... ${NC}" 805 | sudo systemctl start fluxos > /dev/null 2>&1 806 | echo -e "${ARROW} ${CYAN}Starting Fluxd service... ${NC}" 807 | sudo systemctl start fluxd > /dev/null 2>&1 808 | echo -e "${ARROW} ${CYAN}Starting Fluxbench service... ${NC}" 809 | sudo systemctl start fluxbenchd > /dev/null 2>&1 810 | echo -e "${ARROW} ${CYAN}Starting Flux Watchdog service... ${NC}" 811 | sudo systemctl start flux-watchdog > /dev/null 2>&1 812 | if mongod --version > /dev/null 2>&1; then 813 | 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................................." 814 | echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}" 815 | else 816 | string_limit_x_mark "MongoDB was not installed................................." 817 | fi 818 | echo -e "" 819 | fi 820 | ;; 821 | esac 822 | } 823 | function node_reconfiguration() { 824 | reset="" 825 | if [[ -f $DATA_PATH/install_conf.json ]]; then 826 | import_config_file "silent" 827 | get_ip 828 | if [[ -d $FLUXOS_PATH ]]; then 829 | if [[ "$KDA_A" != "" && "$ZELID" != "" ]]; then 830 | echo -e "${ARROW} ${CYAN}Creating FluxOS config file...${NC}" 831 | sudo rm -rf $FLUXOS_PATH/config/userconfig.js > /dev/null 2>&1 832 | fluxos_conf_create 833 | reset=0 834 | fi 835 | fi 836 | if [[ -d $FLUX_DAEMON_PATH ]]; then 837 | if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]]; then 838 | zelnodeprivkey="$prvkey" 839 | zelnodeoutpoint="$outpoint" 840 | zelnodeindex="$index" 841 | echo -e "${ARROW} ${CYAN}Creating Daemon config file...${NC}" 842 | sudo rm -rf $FLUX_DAEMON_PATH/flux.conf > /dev/null 2>&1 843 | flux_daemon_conf_create 844 | reset=0 845 | fi 846 | fi 847 | if [[ -d $FLUX_WATCHDOG_PATH ]]; then 848 | echo -e "${ARROW} ${CYAN}Creating Watchdog config file...${NC}" 849 | sudo rm -rf $FLUX_WATCHDOG_PATH/config.js > /dev/null 2>&1 850 | fix_action='1' 851 | watchdog_conf_create 852 | reset=0 853 | fi 854 | if [[ -d $FLUX_DAEMON_PATH ]]; then 855 | if [[ ! -z "$upnp_port" && ! -z "$gateway_ip" ]]; then 856 | reset=1 857 | upnp_enable 858 | fi 859 | fi 860 | if [[ "$reset" == "0" ]]; then 861 | if [[ -z $FLUXOS_VERSION ]]; then 862 | echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}" 863 | sudo systemctl restart zelcash > /dev/null 2>&1 864 | pm2 restart flux > /dev/null 2>&1 865 | else 866 | sudo systemctl restart fluxd > /dev/null 2>&1 867 | sudo systemctl restart fluxbenchd > /dev/null 2>&1 868 | sudo systemctl restart fluxos > /dev/null 2>&1 869 | sudo systemctl restart flux-watchdog > /dev/null 2>&1 870 | fi 871 | sleep 10 872 | fi 873 | else 874 | echo -e "${ARROW} ${CYAN}Install config file not exist, operation aborted...${NC}" 875 | echo -e "" 876 | fi 877 | } 878 | 879 | if ! figlet -v > /dev/null 2>&1; then 880 | sudo apt-get update -y > /dev/null 2>&1 881 | sudo apt-get install -y figlet > /dev/null 2>&1 882 | fi 883 | 884 | if ! pv -V > /dev/null 2>&1; then 885 | sudo apt-get install -y pv > /dev/null 2>&1 886 | fi 887 | 888 | if ! gzip -V > /dev/null 2>&1; then 889 | sudo apt-get install -y gzip > /dev/null 2>&1 890 | fi 891 | 892 | if ! whiptail -v > /dev/null 2>&1; then 893 | sudo apt-get install -y whiptail > /dev/null 2>&1 894 | fi 895 | 896 | if ! upnpc -h > /dev/null 2>&1 ; then 897 | sudo apt install -y miniupnpc > /dev/null 2>&1 && sleep 2 898 | fi 899 | 900 | if [[ $(cat /etc/bash.bashrc | grep 'multitoolbox' | wc -l) == "0" && $FLUXOS_VERSION == "" ]]; then 901 | echo "alias multitoolbox='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)'" | sudo tee -a /etc/bash.bashrc 902 | 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 903 | alias multitoolbox='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)' 904 | alias multitoolbox_testnet='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox_testnet.sh)' 905 | source /etc/bash.bashrc 906 | fi 907 | 908 | if [[ -d /usr/lib/multitoolbox ]]; then 909 | cd /usr/lib/multitoolbox 910 | commit_hash=$(sudo git rev-parse --short HEAD) 911 | commit_date=$(sudo git log -1 --date=format:'%Y-%m-%d %H:%M:%S' --format=%cd) 912 | ROOT_BRANCH=$(sudo git rev-parse --abbrev-ref HEAD) 913 | cd 914 | fi 915 | 916 | if ! wget --version > /dev/null 2>&1 ; then 917 | sudo apt install -y wget > /dev/null 2>&1 && sleep 2 918 | fi 919 | clear 920 | sleep 1 921 | echo -e "${BLUE}" 922 | figlet -f slant "Multitoolbox" 923 | echo -e "${YELLOW}================================================================${NC}" 924 | if [[ -n $FLUXOS_VERSION ]]; then 925 | echo -e "${GREEN}Version: $dversion${NC}" 926 | echo -e "${GREEN}Commit: $commit_hash${NC}" 927 | echo -e "${GREEN}Data: $commit_date${NC}" 928 | fi 929 | echo -e "${GREEN}Branch: $ROOT_BRANCH${NC}" 930 | if [[ ! -z $FLUXOS_VERSION ]]; then 931 | echo -e "${GREEN}FluxOS version: $FLUXOS_VERSION${NC}" 932 | else 933 | echo -e "${GREEN}OS: Ubuntu 20/22/23, Debian 10/11/12 (if hardware requirements are met)${NC}" 934 | fi 935 | echo -e "${YELLOW}================================================================${NC}" 936 | if [[ -z $FLUXOS_VERSION ]]; then 937 | echo -e "${CYAN}1 - Install Docker${NC}" 938 | echo -e "${CYAN}2 - Install FluxNode${NC}" 939 | echo -e "${CYAN}3 - FluxNode analyzer and fixer${NC}" 940 | echo -e "${CYAN}4 - Install watchdog for FluxNode${NC}" 941 | echo -e "${CYAN}5 - Restore Flux blockchain from bootstrap${NC}" 942 | echo -e "${CYAN}6 - Create FluxNode installation config file${NC}" 943 | echo -e "${CYAN}7 - Re-install FluxOS${NC}" 944 | echo -e "${CYAN}8 - Flux Daemon Reconfiguration${NC}" 945 | echo -e "${CYAN}9 - Create Flux daemon service${NC}" 946 | echo -e "${CYAN}10 - Create Self-hosting cron ip service ${NC}" 947 | echo -e "${CYAN}11 - FluxOS config management ${NC}" 948 | echo -e "${CYAN}12 - MongoDB Repair Assistant${NC}" 949 | echo -e "${CYAN}13 - Multinode configuration with UPNP communication (Needs Router with UPNP support)${NC}" 950 | echo -e "${CYAN}14 - Node reconfiguration from install config${NC}" 951 | echo -e "${CYAN}15 - Hardware benchmark${NC}" 952 | echo -e "${YELLOW}================================================================${NC}" 953 | else 954 | echo -e "${CYAN}1 - Re-install FluxOS${NC}" 955 | echo -e "${CYAN}2 - Flux Daemon Reconfiguration${NC}" 956 | echo -e "${CYAN}3 - FluxOS Config Management${NC}" 957 | echo -e "${CYAN}4 - Restore Flux blockchain from bootstrap${NC}" 958 | echo -e "${CYAN}5 - MongoDB Repair Assistant${NC}" 959 | echo -e "${CYAN}6 - FluxNode Diagnostics${NC}" 960 | echo -e "${CYAN}7 - Log Viewer${NC}" 961 | echo -e "${CYAN}8 - Hardware benchmark${NC}" 962 | echo -e "${YELLOW}================================================================${NC}" 963 | fi 964 | read -rp "Pick an option and hit ENTER: " 965 | case "$REPLY" in 966 | 1) 967 | clear 968 | sleep 1 969 | if [[ -z $FLUXOS_VERSION ]]; then 970 | install_docker 971 | else 972 | install_flux 973 | fi 974 | ;; 975 | 2) 976 | clear 977 | sleep 1 978 | if [[ -z $FLUXOS_VERSION ]]; then 979 | install_node 980 | else 981 | daemon_reconfiguration 982 | fi 983 | ;; 984 | 3) 985 | clear 986 | sleep 1 987 | if [[ -z $FLUXOS_VERSION ]]; then 988 | analyzer_and_fixer 989 | else 990 | fluxos_reconfiguration 991 | fi 992 | ;; 993 | 4) 994 | clear 995 | sleep 1 996 | if [[ -z $FLUXOS_VERSION ]]; then 997 | install_watchdog 998 | else 999 | flux_daemon_bootstrap 1000 | fi 1001 | ;; 1002 | 5) 1003 | clear 1004 | sleep 1 1005 | if [[ -z $FLUXOS_VERSION ]]; then 1006 | flux_daemon_bootstrap 1007 | else 1008 | mongod_db_fix 1009 | fi 1010 | ;; 1011 | 6) 1012 | clear 1013 | sleep 1 1014 | if [[ -z $FLUXOS_VERSION ]]; then 1015 | create_config 1016 | else 1017 | analyzer_and_fixer 1018 | fi 1019 | ;; 1020 | 7) 1021 | clear 1022 | sleep 1 1023 | if [[ -z $FLUXOS_VERSION ]]; then 1024 | install_flux 1025 | else 1026 | bash -i "/usr/lib/multitoolbox/log_viewer.sh" 1027 | fi 1028 | ;; 1029 | 8) 1030 | clear 1031 | sleep 1 1032 | if [[ -z $FLUXOS_VERSION ]]; then 1033 | daemon_reconfiguration 1034 | else 1035 | echo -e "${GREEN}Module: Hardware benchmark${NC}" 1036 | echo -e "${YELLOW}================================================================${NC}" 1037 | bash -i "/usr/lib/multitoolbox/hardwarebench.sh" 1038 | fi 1039 | ;; 1040 | 9) 1041 | if [[ ! -z $FLUXOS_VERSION ]]; then 1042 | exit 1043 | fi 1044 | clear 1045 | sleep 1 1046 | echo -e "${GREEN}Module: Flux Daemon service creator${NC}" 1047 | echo -e "${YELLOW}================================================================${NC}" 1048 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 1049 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 1050 | echo -e "${CYAN}Please switch to the user account.${NC}" 1051 | echo -e "${YELLOW}================================================================${NC}" 1052 | echo -e "${NC}" 1053 | exit 1054 | fi 1055 | create_service_scripts 1056 | create_service "install" 1057 | echo -e "" 1058 | ;; 1059 | 10) 1060 | if [[ ! -z $FLUXOS_VERSION ]]; then 1061 | exit 1062 | fi 1063 | clear 1064 | sleep 1 1065 | selfhosting_creator 1066 | ;; 1067 | 11) 1068 | if [[ ! -z $FLUXOS_VERSION ]]; then 1069 | exit 1070 | fi 1071 | clear 1072 | sleep 1 1073 | fluxos_reconfiguration 1074 | echo -e "" 1075 | ;; 1076 | 12) 1077 | if [[ ! -z $FLUXOS_VERSION ]]; then 1078 | exit 1079 | fi 1080 | clear 1081 | sleep 1 1082 | mongod_db_fix 1083 | echo -e "" 1084 | ;; 1085 | 13) 1086 | if [[ ! -z $FLUXOS_VERSION ]]; then 1087 | exit 1088 | fi 1089 | clear 1090 | sleep 1 1091 | multinode 1092 | echo -e "" 1093 | ;; 1094 | 14) 1095 | if [[ ! -z $FLUXOS_VERSION ]]; then 1096 | exit 1097 | fi 1098 | clear 1099 | sleep 1 1100 | echo -e "${GREEN}Module: Node reconfiguration from install config${NC}" 1101 | echo -e "${YELLOW}================================================================${NC}" 1102 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 1103 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 1104 | echo -e "${CYAN}Please switch to the user account.${NC}" 1105 | echo -e "${YELLOW}================================================================${NC}" 1106 | echo -e "${NC}" 1107 | exit 1108 | fi 1109 | node_reconfiguration 1110 | echo -e "" 1111 | ;; 1112 | 15) 1113 | if [[ ! -z $FLUXOS_VERSION ]]; then 1114 | exit 1115 | fi 1116 | clear 1117 | sleep 1 1118 | echo -e "${GREEN}Module: Hardware benchmark${NC}" 1119 | echo -e "${YELLOW}================================================================${NC}" 1120 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 1121 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 1122 | echo -e "${CYAN}Please switch to the user account.${NC}" 1123 | echo -e "${YELLOW}================================================================${NC}" 1124 | echo -e "${NC}" 1125 | exit 1126 | fi 1127 | bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/hardwarebench.sh) 1128 | ;; 1129 | esac 1130 | # USED FOR CLEANUP AT END OF SCRIPT 1131 | unset ROOT_BRANCH 1132 | unset BRANCH_ALREADY_REFERENCED 1133 | -------------------------------------------------------------------------------- /multitoolbox_testnet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ -z $1 ]]; then 4 | if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then 5 | export ROOT_BRANCH="$1" 6 | export BRANCH_ALREADY_REFERENCED='1' 7 | bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/multitoolbox_testnet.sh) $ROOT_BRANCH 8 | unset ROOT_BRANCH 9 | unset BRANCH_ALREADY_REFERENCED 10 | exit 11 | fi 12 | else 13 | export ROOT_BRANCH='master' 14 | fi 15 | 16 | source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh)" 17 | 18 | 19 | BOOTSTRAP_ZIP='https://fluxnodeservice.com/daemon_bootstrap.tar.gz' 20 | BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz' 21 | BOOTSTRAP_URL_MONGOD='https://fluxnodeservice.com/mongod_bootstrap.tar.gz' 22 | BOOTSTRAP_ZIPFILE_MONGOD='mongod_bootstrap.tar.gz' 23 | KDA_BOOTSTRAP_ZIPFILE='kda_bootstrap.tar.gz' 24 | KDA_BOOTSTRAP_ZIP='http://202.61.207.10:16127/apps/fluxshare/getfile/kda_bootstrap.tar.gz?token=a705701758411b28ea20325ef9654e31e3d8f5f03a24b4e4e662e601a1250859' 25 | 26 | if [[ -d /home/$USER/.zelcash ]]; then 27 | CONFIG_DIR='.zelcash' 28 | CONFIG_FILE='zelcash.conf' 29 | 30 | else 31 | CONFIG_DIR='.flux' 32 | CONFIG_FILE='flux.conf' 33 | fi 34 | 35 | FLUX_DIR='zelflux' 36 | FLUX_APPS_DIR='ZelApps' 37 | COIN_NAME='zelcash' 38 | 39 | dversion="v6.1" 40 | 41 | PM2_INSTALL="0" 42 | zelflux_setting_import="0" 43 | 44 | 45 | 46 | function config_file() { 47 | 48 | if [[ -f /home/$USER/install_conf.json ]]; then 49 | import_settings=$(cat /home/$USER/install_conf.json | jq -r '.import_settings') 50 | ssh_port=$(cat /home/$USER/install_conf.json | jq -r '.ssh_port') 51 | firewall_disable=$(cat /home/$USER/install_conf.json | jq -r '.firewall_disable') 52 | bootstrap_url=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_url') 53 | bootstrap_zip_del=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_zip_del') 54 | swapon=$(cat /home/$USER/install_conf.json | jq -r '.swapon') 55 | mongo_bootstrap=$(cat /home/$USER/install_conf.json | jq -r '.mongo_bootstrap') 56 | watchdog=$(cat /home/$USER/install_conf.json | jq -r '.watchdog') 57 | use_old_chain=$(cat /home/$USER/install_conf.json | jq -r '.use_old_chain') 58 | prvkey=$(cat /home/$USER/install_conf.json | jq -r '.prvkey') 59 | outpoint=$(cat /home/$USER/install_conf.json | jq -r '.outpoint') 60 | index=$(cat /home/$USER/install_conf.json | jq -r '.index') 61 | zel_id=$(cat /home/$USER/install_conf.json | jq -r '.zelid') 62 | kda_address=$(cat /home/$USER/install_conf.json | jq -r '.kda_address') 63 | 64 | echo -e "${ARROW} ${YELLOW}Install config summary:" 65 | 66 | if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then 67 | echo -e "${PIN}${CYAN}Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 68 | else 69 | 70 | if [[ "$import_settings" == "1" ]]; then 71 | echo -e "${PIN}${CYAN}Import settings from exist config files..........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 72 | fi 73 | 74 | fi 75 | 76 | if [[ "$ssh_port" != "" ]]; then 77 | string_limit_check_mark_port "SSH port: $ssh_port ...................................................................." "SSH port: ${GREEN}$ssh_port ${CYAN}...................................................................." 78 | sleep 1 79 | fi 80 | 81 | if [[ "$firewall_disable" == "1" ]]; then 82 | echo -e "${PIN}${CYAN}Firewall disabled diuring installation...........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 83 | else 84 | echo -e "${PIN}${CYAN}Firewall enabled diuring installation............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 85 | fi 86 | 87 | if [[ "$use_old_chain" == "1" ]]; then 88 | echo -e "${PIN}${CYAN}During re-installation old chain will be use....................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 89 | 90 | else 91 | 92 | if [[ "$bootstrap_url" == "" ]]; then 93 | echo -e "${PIN}${CYAN}Use Flux Bootstrap from source build in scripts..................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 94 | else 95 | echo -e "${PIN}${CYAN}Use Flux Bootstrap from own source...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 96 | fi 97 | 98 | if [[ "$bootstrap_zip_del" == "1" ]]; then 99 | echo -e "${PIN}${CYAN}Remove Flux Bootstrap archive file...............................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 100 | else 101 | echo -e "${PIN}${CYAN}Leave Flux Bootstrap archive file................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 102 | fi 103 | 104 | fi 105 | 106 | if [[ "$swapon" == "1" ]]; then 107 | echo -e "${PIN}${CYAN}Create a file that will be used for swap.........................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 108 | fi 109 | 110 | #if [[ "$mongo_bootstrap" == "1" ]]; then 111 | #echo -e "${PIN}${CYAN}Use Bootstrap for MongoDB........................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 112 | #fi 113 | 114 | if [[ "$watchdog" == "1" ]]; then 115 | echo -e "${PIN}${CYAN}Install watchdog.................................................[${CHECK_MARK}${CYAN}]${NC}" && sleep 1 116 | fi 117 | fi 118 | } 119 | 120 | 121 | function install_flux() { 122 | 123 | echo -e "${GREEN}Module: Re-install FluxOS${NC}" 124 | echo -e "${YELLOW}================================================================${NC}" 125 | 126 | if [[ "$USER" == "root" || "$USER" == "ubuntu" ]]; then 127 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 128 | echo -e "${CYAN}Please switch to the user account.${NC}" 129 | echo -e "${YELLOW}================================================================${NC}" 130 | echo -e "${NC}" 131 | exit 132 | fi 133 | 134 | if pm2 -v > /dev/null 2>&1; then 135 | pm2 del zelflux > /dev/null 2>&1 136 | pm2 del flux > /dev/null 2>&1 137 | pm2 save > /dev/null 2>&1 138 | fi 139 | 140 | docker_check=$(docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l) 141 | resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l) 142 | mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1) 143 | 144 | if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then 145 | echo -e "${ARROW} ${YELLOW}Detected Flux MongoDB local apps collection ...${NC}" && sleep 1 146 | echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}" && sleep 1 147 | echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1 148 | fi 149 | 150 | if [[ $docker_check != 0 ]]; then 151 | echo -e "${ARROW} ${YELLOW}Detected running docker container...${NC}" && sleep 1 152 | echo -e "${ARROW} ${CYAN}Removing containers...${NC}" 153 | sudo aa-remove-unknown && sudo service docker restart > /dev/null 2>&1 && sleep 2 154 | sleep 5 155 | #docker ps | grep -Eo "^[0-9a-z]{8,}\b" | 156 | docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | 157 | while read line; do 158 | sudo docker stop $line > /dev/null 2>&1 && sleep 2 159 | sudo docker rm $line > /dev/null 2>&1 && sleep 2 160 | done 161 | fi 162 | 163 | if [[ $resource_check != 0 ]]; then 164 | echo -e "${ARROW} ${YELLOW}Detected locked resource...${NC}" && sleep 1 165 | echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}" && sleep 1 166 | df | egrep 'flux' | awk '{ print $1}' | 167 | while read line; do 168 | sudo umount -l $line && sleep 1 169 | done 170 | fi 171 | 172 | if [ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]; then 173 | 174 | echo -e "${ARROW} ${CYAN}Importing setting...${NC}" 175 | zel_id=$(grep -w zelid /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//') 176 | WANIP=$(grep -w ipaddress /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*ipaddress: .//' | sed -e 's/.\{2\}$//') 177 | 178 | echo -e "${PIN}${CYAN}Zel ID = ${GREEN}$zel_id${NC}" && sleep 1 179 | 180 | KDA_A=$(grep -w kadena /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//') 181 | 182 | if [[ "$KDA_A" != "" ]]; then 183 | 184 | echo -e "${PIN}${CYAN}Kadena address = ${GREEN}$KDA_A${NC}" && sleep 1 185 | 186 | fi 187 | 188 | 189 | echo -e "${PIN}${CYAN}IP = ${GREEN}$WANIP${NC}" && sleep 1 190 | echo 191 | echo -e "${ARROW} ${CYAN}Removing any instances of Flux....${NC}" 192 | sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 2 193 | #sudo rm -rf zelflux > /dev/null 2>&1 && sleep 2 194 | zelflux_setting_import="1" 195 | 196 | fi 197 | 198 | if [ -d /home/$USER/$FLUX_DIR ]; then 199 | 200 | echo -e "${ARROW} ${CYAN}Removing any instances of Flux....${NC}" 201 | #sudo rm -rf zelflux > /dev/null 2>&1 && sleep 2 202 | sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 2 203 | 204 | fi 205 | 206 | echo -e "${ARROW} ${CYAN}Flux downloading...${NC}" 207 | git clone https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1 && sleep 2 208 | cd zelflux 209 | echo -e "${ARROW} ${YELLOW}Changing to test branch...${NC}" 210 | git checkout testnet > /dev/null 2>&1 211 | #git clone --single-branch --branch development https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1 && sleep 2 212 | 213 | if [ -d /home/$USER/$FLUX_DIR ] 214 | then 215 | 216 | if [[ -f /home/$USER/$FLUX_DIR/package.json ]]; then 217 | current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json) 218 | else 219 | string_limit_x_mark "Flux was not downloaded, run script again..........................................." 220 | echo 221 | exit 222 | fi 223 | 224 | string_limit_check_mark "Flux v$current_ver downloaded..........................................." "Flux ${GREEN}v$current_ver${CYAN} downloaded..........................................." 225 | else 226 | string_limit_x_mark "Flux was not downloaded, run script again..........................................." 227 | echo 228 | exit 229 | fi 230 | 231 | 232 | if [[ "$zelflux_setting_import" == "0" ]]; then 233 | 234 | ip_confirm 235 | 236 | while true 237 | do 238 | 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)" 239 | 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 240 | string_limit_check_mark "Zel ID is valid..........................................." 241 | break 242 | else 243 | string_limit_x_mark "Zel ID is not valid try again..........................................." 244 | sleep 2 245 | fi 246 | 247 | done 248 | 249 | 250 | touch ~/$FLUX_DIR/config/userconfig.js 251 | cat << EOF > ~/$FLUX_DIR/config/userconfig.js 252 | module.exports = { 253 | initial: { 254 | ipaddress: '${WANIP}', 255 | zelid: '${zel_id}', 256 | testnet: true 257 | } 258 | } 259 | EOF 260 | 261 | else 262 | 263 | if [[ "$KDA_A" != "" ]]; then 264 | 265 | touch ~/$FLUX_DIR/config/userconfig.js 266 | cat << EOF > ~/$FLUX_DIR/config/userconfig.js 267 | module.exports = { 268 | initial: { 269 | ipaddress: '${WANIP}', 270 | zelid: '${zel_id}', 271 | kadena: '${KDA_A}', 272 | testnet: true, 273 | } 274 | } 275 | EOF 276 | 277 | else 278 | 279 | touch ~/$FLUX_DIR/config/userconfig.js 280 | cat << EOF > ~/$FLUX_DIR/config/userconfig.js 281 | module.exports = { 282 | initial: { 283 | ipaddress: '${WANIP}', 284 | zelid: '${zel_id}', 285 | testnet: true 286 | } 287 | } 288 | EOF 289 | 290 | fi 291 | 292 | fi 293 | 294 | if [[ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]]; then 295 | string_limit_check_mark "Flux configuration successfull..........................................." 296 | else 297 | string_limit_x_mark "Flux installation failed, missing config file..........................................." 298 | echo 299 | exit 300 | fi 301 | 302 | if pm2 -v > /dev/null 2>&1; then 303 | 304 | rm restart_zelflux.sh > /dev/null 2>&1 305 | pm2 del flux > /dev/null 2>&1 306 | pm2 del zelflux > /dev/null 2>&1 307 | pm2 save > /dev/null 2>&1 308 | echo -e "${ARROW} ${CYAN}Starting Flux....${NC}" 309 | echo -e "${ARROW} ${CYAN}Flux loading will take 2-3min....${NC}" 310 | echo 311 | pm2 start /home/$USER/$FLUX_DIR/start.sh --restart-delay=60000 --max-restarts=40 --name flux --time > /dev/null 2>&1 312 | pm2 save > /dev/null 2>&1 313 | pm2 list 314 | 315 | else 316 | 317 | pm2_install() 318 | if [[ "$PM2_INSTALL" == "1" ]]; then 319 | echo -e "${ARROW} ${CYAN}Starting Flux....${NC}" 320 | echo -e "${ARROW} ${CYAN}Flux loading will take 2-3min....${NC}" 321 | echo 322 | pm2 list 323 | fi 324 | fi 325 | 326 | } 327 | 328 | function create_config() { 329 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 330 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 331 | echo -e "${CYAN}Please switch to the user account.${NC}" 332 | echo -e "${YELLOW}================================================================${NC}" 333 | echo -e "${NC}" 334 | exit 335 | fi 336 | 337 | echo -e "${GREEN}Module: Create FluxNode installation config file${NC}" 338 | echo -e "${YELLOW}================================================================${NC}" 339 | 340 | 341 | if jq --version > /dev/null 2>&1; then 342 | sleep 0.2 343 | else 344 | echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}" 345 | sudo apt install jq -y > /dev/null 2>&1 346 | 347 | if jq --version > /dev/null 2>&1 348 | then 349 | #echo -e "${ARROW} ${CYAN}Nodejs version: ${GREEN}$(node -v)${CYAN} installed${NC}" 350 | string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................." 351 | echo 352 | else 353 | #echo -e "${ARROW} ${CYAN}Nodejs was not installed${NC}" 354 | string_limit_x_mark "JQ was not installed................................." 355 | echo 356 | exit 357 | fi 358 | fi 359 | 360 | skip_zelcash_config='0' 361 | skip_bootstrap='0' 362 | 363 | if [[ -d /home/$USER/$CONFIG_DIR ]]; then 364 | 365 | if whiptail --yesno "Would you like import old settings from daemon and Flux?" 8 65; then 366 | import_settings='1' 367 | skip_zelcash_config='1' 368 | sleep 1 369 | else 370 | import_settings='0' 371 | sleep 1 372 | fi 373 | 374 | if whiptail --yesno "Would you like use exist Flux chain?" 8 65; then 375 | use_old_chain='1' 376 | skip_bootstrap='1' 377 | sleep 1 378 | else 379 | use_old_chain='0' 380 | sleep 1 381 | fi 382 | 383 | 384 | fi 385 | 386 | if [[ "$skip_zelcash_config" == "1" ]]; then 387 | prvkey="" 388 | outpoint="" 389 | index="" 390 | zelid="" 391 | kda_address="" 392 | else 393 | 394 | prvkey=$(whiptail --inputbox "Enter your FluxNode Identity Key from Zelcore" 8 65 3>&1 1>&2 2>&3) 395 | sleep 1 396 | outpoint=$(whiptail --inputbox "Enter your FluxNode Collateral Output TX ID from Zelcore" 8 72 3>&1 1>&2 2>&3) 397 | sleep 1 398 | index=$(whiptail --inputbox "Enter your FluxNode Output Index from Zelcore" 8 65 3>&1 1>&2 2>&3) 399 | sleep 1 400 | zel_id=$(whiptail --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3) 401 | sleep 1 402 | KDA_A=$(whiptail --inputbox "Please enter your Kadena address from Zelcore" 8 85 3>&1 1>&2 2>&3) 403 | sleep 1 404 | KDA_C=$(whiptail --inputbox "Please enter your kadena chainid (0-19)" 8 85 3>&1 1>&2 2>&3) 405 | 406 | if [[ "$KDA_A" == "" ]]; then 407 | kda_address="" 408 | else 409 | kda_address="kadena:$KDA_A?chainid=$KDA_C" 410 | fi 411 | 412 | fi 413 | 414 | ssh_port=$(whiptail --inputbox "Enter port you are using for SSH (default 22)" 8 65 3>&1 1>&2 2>&3) 415 | sleep 1 416 | 417 | 418 | pettern='^[0-9]+$' 419 | if [[ $ssh_port =~ $pettern ]] ; then 420 | sleep 1 421 | else 422 | echo -e "${ARROW} ${CYAN}SSH port must be integer.................................[${X_MARK}${CYAN}]${NC}" 423 | echo 424 | exit 425 | fi 426 | 427 | 428 | if whiptail --yesno "Would you like disable firewall diuring installation?" 8 65; then 429 | firewall_disable='1' 430 | sleep 1 431 | else 432 | firewall_disable='0' 433 | sleep 1 434 | fi 435 | 436 | 437 | if [[ "$skip_bootstrap" == "0" ]]; then 438 | 439 | if whiptail --yesno "Would you like use Flux bootstrap from script source?" 8 65; then 440 | bootstrap_url="$BOOTSTRAP_ZIP" 441 | sleep 1 442 | else 443 | bootstrap_url=$(whiptail --inputbox "Enter your Flux bootstrap URL" 8 65 3>&1 1>&2 2>&3) 444 | sleep 1 445 | fi 446 | 447 | if whiptail --yesno "Would you like keep bootstrap archive file localy?" 8 65; then 448 | bootstrap_zip_del='0' 449 | sleep 1 450 | else 451 | bootstrap_zip_del='1' 452 | sleep 1 453 | fi 454 | fi 455 | 456 | if whiptail --yesno "Would you like create swapfile?" 8 65; then 457 | swapon='1' 458 | sleep 1 459 | else 460 | swapon='0' 461 | sleep 1 462 | fi 463 | 464 | 465 | if whiptail --yesno "Would you like use mongod bootstrap file?" 8 65; then 466 | mongo_bootstrap='1' 467 | sleep 1 468 | else 469 | mongo_bootstrap='0' 470 | sleep 1 471 | fi 472 | 473 | 474 | if whiptail --yesno "Would you like install FluxNode watchdog?" 8 65; then 475 | watchdog='1' 476 | sleep 1 477 | else 478 | watchdog='0' 479 | sleep 1 480 | fi 481 | 482 | rm /home/$USER/install_conf.json > /dev/null 2>&1 483 | sudo touch /home/$USER/install_conf.json 484 | sudo chown $USER:$USER /home/$USER/install_conf.json 485 | cat << EOF > /home/$USER/install_conf.json 486 | { 487 | "import_settings": "${import_settings}", 488 | "prvkey": "${prvkey}", 489 | "outpoint": "${outpoint}", 490 | "index": "${index}", 491 | "zelid": "${zel_id}", 492 | "kda_address": "${kda_address}", 493 | "ssh_port": "${ssh_port}", 494 | "firewall_disable": "${firewall_disable}", 495 | "bootstrap_url": "${bootstrap_url}", 496 | "bootstrap_zip_del": "${bootstrap_zip_del}", 497 | "swapon": "${swapon}", 498 | "mongo_bootstrap": "${mongo_bootstrap}", 499 | "use_old_chain": "${use_old_chain}", 500 | "watchdog": "${watchdog}" 501 | } 502 | EOF 503 | config_file 504 | echo 505 | 506 | 507 | 508 | } 509 | 510 | 511 | function install_watchdog() { 512 | 513 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 514 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 515 | echo -e "${CYAN}Please switch to the user account.${NC}" 516 | echo -e "${YELLOW}================================================================${NC}" 517 | echo -e "${NC}" 518 | exit 519 | fi 520 | 521 | echo -e "${GREEN}Module: Install watchdog for FluxNode${NC}" 522 | echo -e "${YELLOW}================================================================${NC}" 523 | 524 | if ! pm2 -v > /dev/null 2>&1 525 | then 526 | pm2_install 527 | if [[ "$PM2_INSTALL" == "0" ]]; then 528 | exit 529 | fi 530 | echo -e "" 531 | fi 532 | 533 | echo -e "${ARROW} ${CYAN}Cleaning...${NC}" 534 | pm2 del watchdog > /dev/null 2>&1 535 | pm2 save > /dev/null 2>&1 536 | sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1 537 | 538 | echo -e "${ARROW} ${CYAN}Downloading...${NC}" 539 | cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1 540 | echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}" 541 | wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1 542 | mv post-merge /home/$USER/watchdog/.git/hooks/post-merge 543 | sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge 544 | echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}" 545 | cd watchdog && npm install > /dev/null 2>&1 546 | echo -e "${ARROW} ${CYAN}Creating config file....${NC}" 547 | 548 | 549 | #if whiptail --yesno "Would you like enable FluxOS auto update?" 8 60; then 550 | flux_update='1' 551 | #sleep 1 552 | #else 553 | ##flux_update='0' 554 | #sleep 1 555 | #fi 556 | 557 | #if whiptail --yesno "Would you like enable Flux daemon auto update?" 8 60; then 558 | daemon_update='1' 559 | ##sleep 1 560 | #else 561 | #daemon_update='0' 562 | ##sleep 1 563 | #fi 564 | 565 | #if whiptail --yesno "Would you like enable Flux benchmark auto update?" 8 60; then 566 | bench_update='1' 567 | #sleep 1 568 | #else 569 | ##bench_update='0' 570 | ##sleep 1 571 | #fi 572 | 573 | #if whiptail --yesno "Would you like enable fix action (restart daemon, benchmark, mongodb)?" 8 75; then 574 | fix_action='1' 575 | #sleep 1 576 | #else 577 | #fix_action='0' 578 | ##sleep 1 579 | #fi 580 | 581 | telegram_alert=0; 582 | discord=0; 583 | 584 | if whiptail --yesno "Would you like enable alert notification?" 8 60; then 585 | 586 | sleep 1 587 | 588 | whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60 589 | 590 | sleep 1 591 | 592 | CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \ 593 | "1" "Discord notification " ON \ 594 | "2" "Telegram notification " OFF 3>&1 1>&2 2>&3 ) 595 | 596 | if [ -z "$CHOICES" ]; then 597 | 598 | echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}" 599 | sleep 1 600 | discord=0; 601 | ping=0; 602 | telegram_alert=0; 603 | telegram_bot_token=0; 604 | telegram_chat_id=0; 605 | node_label=0; 606 | 607 | else 608 | for CHOICE in $CHOICES; do 609 | case "$CHOICE" in 610 | "1") 611 | 612 | discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3) 613 | sleep 1 614 | 615 | if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then 616 | 617 | while true 618 | do 619 | ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3) 620 | if [[ $ping == ?(-)+([0-9]) ]]; then 621 | string_limit_check_mark "UserID is valid..........................................." 622 | break 623 | else 624 | string_limit_x_mark "UserID is not valid try again............................." 625 | sleep 1 626 | fi 627 | done 628 | 629 | sleep 1 630 | 631 | else 632 | ping=0; 633 | sleep 1 634 | fi 635 | 636 | ;; 637 | "2") 638 | 639 | telegram_alert=1; 640 | 641 | while true 642 | do 643 | telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3) 644 | if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then 645 | string_limit_check_mark "Bot token is valid..........................................." 646 | break 647 | else 648 | string_limit_x_mark "Bot token is not valid try again............................." 649 | sleep 1 650 | fi 651 | done 652 | 653 | sleep 1 654 | 655 | while true 656 | do 657 | telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3) 658 | if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then 659 | string_limit_check_mark "Chat ID is valid..........................................." 660 | break 661 | else 662 | string_limit_x_mark "Chat ID is not valid try again............................." 663 | sleep 1 664 | fi 665 | done 666 | 667 | sleep 1 668 | 669 | ;; 670 | esac 671 | done 672 | fi 673 | 674 | while true 675 | do 676 | node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3) 677 | if [[ "$node_label" != "" && "$node_label" != "0" ]]; then 678 | string_limit_check_mark "Node name is valid..........................................." 679 | break 680 | else 681 | string_limit_x_mark "Node name is not valid try again............................." 682 | sleep 1 683 | fi 684 | done 685 | 686 | sleep 1 687 | 688 | 689 | else 690 | 691 | node_label=0; 692 | discord=0; 693 | ping=0; 694 | telegram_alert=0; 695 | telegram_bot_token=0; 696 | telegram_chat_id=0; 697 | sleep 1 698 | fi 699 | 700 | 701 | if [[ $discord == 0 ]]; then 702 | ping=0; 703 | fi 704 | 705 | 706 | if [[ $telegram_alert == 0 ]]; then 707 | telegram_bot_token=0; 708 | telegram_chat_id=0; 709 | fi 710 | 711 | 712 | if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then 713 | index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//') 714 | tx_from_file=$(grep -w zelnodeoutpoint /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//') 715 | 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') 716 | 717 | if [[ "$stak_info" == "" ]]; then 718 | 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') 719 | fi 720 | fi 721 | 722 | if [[ $stak_info == ?(-)+([0-9]) ]]; then 723 | 724 | case $stak_info in 725 | "10000") eps_limit=90 ;; 726 | "25000") eps_limit=180 ;; 727 | "100000") eps_limit=300 ;; 728 | esac 729 | 730 | else 731 | eps_limit=0; 732 | fi 733 | 734 | 735 | sudo touch /home/$USER/watchdog/config.js 736 | sudo chown $USER:$USER /home/$USER/watchdog/config.js 737 | cat << EOF > /home/$USER/watchdog/config.js 738 | module.exports = { 739 | label: '${node_label}', 740 | tier_eps_min: '${eps_limit}', 741 | zelflux_update: '${flux_update}', 742 | zelcash_update: '${daemon_update}', 743 | zelbench_update: '${bench_update}', 744 | action: '${fix_action}', 745 | ping: '${ping}', 746 | web_hook_url: '${discord}', 747 | telegram_alert: '${telegram_alert}', 748 | telegram_bot_token: '${telegram_bot_token}', 749 | telegram_chat_id: '${telegram_chat_id}' 750 | } 751 | EOF 752 | 753 | echo -e "${ARROW} ${CYAN}Starting watchdog...${NC}" 754 | 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 755 | pm2 save > /dev/null 2>&1 756 | if [[ -f /home/$USER/watchdog/watchdog.js ]] 757 | then 758 | current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json) 759 | #echo -e "${ARROW} ${CYAN}Watchdog ${GREEN}v$current_ver${CYAN} installed successful.${NC}" 760 | string_limit_check_mark "Watchdog v$current_ver installed..........................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed..........................................." 761 | else 762 | #echo -e "${ARROW} ${CYAN}Watchdog installion failed.${NC}" 763 | string_limit_x_mark "Watchdog was not installed..........................................." 764 | fi 765 | echo 766 | } 767 | 768 | 769 | 770 | function flux_daemon_bootstrap() { 771 | 772 | echo -e "${GREEN}Module: Restore Flux blockchain from bootstrap${NC}" 773 | echo -e "${YELLOW}================================================================${NC}" 774 | 775 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 776 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 777 | echo -e "${CYAN}Please switch to the user account.${NC}" 778 | echo -e "${YELLOW}================================================================${NC}" 779 | echo -e "${NC}" 780 | exit 781 | fi 782 | 783 | cd 784 | echo -e "${NC}" 785 | pm2 stop watchdog > /dev/null 2>&1 && sleep 2 786 | echo -e "${ARROW} ${CYAN}Stopping Flux daemon service${NC}" 787 | sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2 788 | sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1 789 | 790 | if [[ -e /home/$USER/$CONFIG_DIR/blocks ]] && [[ -e /home/$USER/$CONFIG_DIR/chainstate ]]; then 791 | echo -e "${ARROW} ${CYAN}Cleaning...${NC}" 792 | rm -rf /home/$USER/$CONFIG_DIR/blocks /home/$USER/$CONFIG_DIR/chainstate /home/$USER/$CONFIG_DIR/determ_zelnodes 793 | fi 794 | 795 | BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}" 796 | 797 | if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then 798 | 799 | echo -e "${ARROW} ${YELLOW}Local bootstrap file detected...${NC}" 800 | 801 | if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then 802 | 803 | echo -e "${ARROW} ${YELLOW}Checking if zip file is corrupted...${NC}" 804 | 805 | if unzip -t $BOOTSTRAP_ZIPFILE | grep 'No errors' > /dev/null 2>&1 806 | then 807 | echo -e "${ARROW} ${CYAN}Bootstrap zip file is valid.............[${CHECK_MARK}${CYAN}]${NC}" 808 | else 809 | printf '\e[A\e[K' 810 | printf '\e[A\e[K' 811 | printf '\e[A\e[K' 812 | printf '\e[A\e[K' 813 | printf '\e[A\e[K' 814 | printf '\e[A\e[K' 815 | echo -e "${ARROW} ${CYAN}Bootstrap file is corrupted.............[${X_MARK}${CYAN}]${NC}" 816 | rm -rf $BOOTSTRAP_ZIPFILE 817 | fi 818 | 819 | else 820 | check_tar "/home/$USER/$BOOTSTRAP_ZIPFILE" 821 | fi 822 | 823 | fi 824 | 825 | 826 | if [ -f "/home/$USER/$BOOTSTRAP_ZIPFILE" ]; then 827 | 828 | 829 | if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then 830 | echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}" 831 | unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1 832 | else 833 | tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR" 834 | sleep 2 835 | fi 836 | 837 | else 838 | 839 | CHOICE=$( 840 | whiptail --title "FLUXNODE INSTALLATION" --menu "Choose a method how to get bootstrap file" 10 47 2 \ 841 | "1)" "Download from source build in script" \ 842 | "2)" "Download from own source" 3>&2 2>&1 1>&3 843 | ) 844 | 845 | 846 | case $CHOICE in 847 | "1)") 848 | 849 | DB_HIGHT=$(curl -s -m 3 https://fluxnodeservice.com/daemon_bootstrap.json | jq -r '.block_height') 850 | echo -e "${ARROW} ${CYAN}Flux daemon bootstrap height: ${GREEN}$DB_HIGHT${NC}" 851 | echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}" 852 | wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress 853 | tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR" 854 | sleep 2 855 | 856 | 857 | 858 | ;; 859 | "2)") 860 | BOOTSTRAP_ZIP="$(whiptail --title "Flux daemon bootstrap setup" --inputbox "Enter your URL (zip, tar.gz)" 8 72 3>&1 1>&2 2>&3)" 861 | echo -e "${ARROW} ${YELLOW}Downloading File: ${GREEN}$BOOTSTRAP_ZIP ${NC}" 862 | BOOTSTRAP_ZIPFILE="${BOOTSTRAP_ZIP##*/}" 863 | 864 | if [[ "$BOOTSTRAP_ZIPFILE" != *".zip"* ]]; then 865 | BOOTSTRAP_ZIPFILE='daemon_bootstrap.tar.gz' 866 | fi 867 | 868 | wget -O $BOOTSTRAP_ZIPFILE $BOOTSTRAP_ZIP -q --show-progress 869 | 870 | if [[ "$BOOTSTRAP_ZIPFILE" == *".zip"* ]]; then 871 | echo -e "${ARROW} ${YELLOW}Unpacking wallet bootstrap please be patient...${NC}" 872 | unzip -o $BOOTSTRAP_ZIPFILE -d /home/$USER/$CONFIG_DIR > /dev/null 2>&1 873 | else 874 | tar_file_unpack "/home/$USER/$BOOTSTRAP_ZIPFILE" "/home/$USER/$CONFIG_DIR" 875 | sleep 2 876 | fi 877 | ;; 878 | esac 879 | 880 | fi 881 | 882 | 883 | if whiptail --yesno "Would you like remove bootstrap archive file?" 8 60; then 884 | rm -rf $BOOTSTRAP_ZIPFILE 885 | fi 886 | 887 | sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2 888 | NUM='35' 889 | MSG1='Starting Flux daemon service...' 890 | MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}" 891 | spinning_timer 892 | echo -e "" && echo -e "" 893 | pm2 start watchdog --watch > /dev/null 2>&1 && sleep 2 894 | } 895 | 896 | 897 | function install_node(){ 898 | 899 | echo -e "${GREEN}Module: Install FluxNode${NC}" 900 | echo -e "${YELLOW}================================================================${NC}" 901 | 902 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 903 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 904 | echo -e "${CYAN}Please switch to the user account.${NC}" 905 | echo -e "${YELLOW}================================================================${NC}" 906 | echo -e "${NC}" 907 | exit 908 | fi 909 | 910 | if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then 911 | 912 | echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}" 913 | echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation" 914 | echo -e "${WORNING} ${CYAN}Installation stopped...${NC}" 915 | echo 916 | exit 917 | fi 918 | 919 | 920 | if docker run hello-world > /dev/null 2>&1 921 | then 922 | echo -e "" 923 | else 924 | echo -e "${WORNING}${CYAN}Docker is not working correct or is not installed.${NC}" 925 | exit 926 | fi 927 | 928 | 929 | # bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro.sh) 930 | bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro_testnet.sh) 931 | 932 | 933 | } 934 | 935 | 936 | function install_docker(){ 937 | 938 | echo -e "${GREEN}Module: Install Docker${NC}" 939 | echo -e "${YELLOW}================================================================${NC}" 940 | 941 | if [[ "$USER" != "root" ]]; then 942 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 943 | echo -e "${CYAN}Please switch to the root account use command 'su -'.${NC}" 944 | echo -e "${YELLOW}================================================================${NC}" 945 | echo -e "${NC}" 946 | exit 947 | fi 948 | 949 | 950 | 951 | if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then 952 | 953 | echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}" 954 | echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation" 955 | echo -e "${WORNING} ${CYAN}Installation stopped...${NC}" 956 | echo 957 | exit 958 | 959 | fi 960 | 961 | if [[ -z "$usernew" ]]; then 962 | usernew="$(whiptail --title "MULTITOOLBOX $dversion" --inputbox "Enter your username" 8 72 3>&1 1>&2 2>&3)" 963 | usernew=$(awk '{print tolower($0)}' <<< "$usernew") 964 | else 965 | echo -e "${PIN}${CYAN} Import docker user '$usernew' from environment variable............[${CHECK_MARK}${CYAN}]${NC}" 966 | fi 967 | echo -e "${ARROW} ${CYAN}New User: ${GREEN}${usernew}${NC}" 968 | adduser --gecos "" "$usernew" 969 | usermod -aG sudo "$usernew" > /dev/null 2>&1 970 | echo -e "${ARROW} ${YELLOW}Update and upgrade system...${NC}" 971 | apt update -y && apt upgrade -y 972 | if ! ufw version > /dev/null 2>&1 973 | then 974 | echo -e "${ARROW} ${YELLOW}Installing ufw firewall..${NC}" 975 | sudo apt-get install -y ufw > /dev/null 2>&1 976 | fi 977 | echo -e "${ARROW} ${YELLOW}Installing docker...${NC}" 978 | echo -e "${ARROW} ${CYAN}Architecture: ${GREEN}$(dpkg --print-architecture)${NC}" 979 | 980 | if [[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then 981 | sudo rm /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1 982 | fi 983 | 984 | if [[ -f /etc/apt/sources.list.d/docker.list ]]; then 985 | sudo rm /etc/apt/sources.list.d/docker.list > /dev/null 2>&1 986 | fi 987 | 988 | 989 | if [[ $(lsb_release -d) = *Debian* ]] 990 | then 991 | 992 | sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1 993 | sudo apt-get update -y > /dev/null 2>&1 994 | sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1 995 | sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1 996 | #curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - > /dev/null 2>&1 997 | #sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /dev/null 2>&1 998 | curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1 999 | 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 1000 | sudo apt-get update -y > /dev/null 2>&1 1001 | sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1 1002 | 1003 | else 1004 | 1005 | sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1 1006 | sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1 1007 | sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1 1008 | 1009 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1 1010 | 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 1011 | #curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - > /dev/null 2>&1 1012 | #sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /dev/null 2>&1 1013 | sudo apt-get update -y > /dev/null 2>&1 1014 | sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1 1015 | 1016 | fi 1017 | 1018 | # echo -e "${YELLOW}Creating docker group..${NC}" 1019 | # groupadd docker 1020 | echo -e "${ARROW} ${YELLOW}Adding $usernew to docker group...${NC}" 1021 | adduser "$usernew" docker 1022 | echo -e "${NC}" 1023 | echo -e "${YELLOW}=====================================================${NC}" 1024 | echo -e "${YELLOW}Running through some checks...${NC}" 1025 | echo -e "${YELLOW}=====================================================${NC}" 1026 | 1027 | if sudo docker run hello-world > /dev/null 2>&1 1028 | then 1029 | echo -e "${CHECK_MARK} ${CYAN}Docker is installed${NC}" 1030 | else 1031 | echo -e "${X_MARK} ${CYAN}Docker did not installed${NC}" 1032 | fi 1033 | 1034 | if [[ $(getent group docker | grep "$usernew") ]] 1035 | then 1036 | echo -e "${CHECK_MARK} ${CYAN}User $usernew is member of 'docker'${NC}" 1037 | else 1038 | echo -e "${X_MARK} ${CYAN}User $usernew is not member of 'docker'${NC}" 1039 | fi 1040 | 1041 | echo -e "${YELLOW}=====================================================${NC}" 1042 | echo -e "${NC}" 1043 | read -p "Would you like switch to user account Y/N?" -n 1 -r 1044 | echo -e "${NC}" 1045 | if [[ $REPLY =~ ^[Yy]$ ]] 1046 | then 1047 | su - $usernew 1048 | fi 1049 | 1050 | } 1051 | 1052 | function daemon_reconfiguration() 1053 | { 1054 | 1055 | echo -e "${GREEN}Module: Flux Daemon Reconfiguration${NC}" 1056 | echo -e "${YELLOW}================================================================${NC}" 1057 | 1058 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 1059 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 1060 | echo -e "${CYAN}Please switch to the user account.${NC}" 1061 | echo -e "${YELLOW}================================================================${NC}" 1062 | echo -e "${NC}" 1063 | exit 1064 | fi 1065 | 1066 | echo 1067 | echo -e "${ARROW} ${YELLOW}Fill in all the fields that you want to replace${NC}" 1068 | sleep 4 1069 | skip_change='3' 1070 | zelnodeprivkey="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Identity Key generated by your Zelcore" 8 72 3>&1 1>&2 2>&3)" 1071 | sleep 1 1072 | zelnodeoutpoint="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Collateral TX ID" 8 72 3>&1 1>&2 2>&3)" 1073 | sleep 1 1074 | zelnodeindex="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode Output Index usually a 0/1" 8 60 3>&1 1>&2 2>&3)" 1075 | sleep 1 1076 | #externalip="$(whiptail --title "Flux daemon reconfiguration" --inputbox "Enter your FluxNode IP" 8 60 3>&1 1>&2 2>&3)" 1077 | #sleep 1 1078 | 1079 | if [[ "$zelnodeprivkey" == "" ]]; then 1080 | skip_change=$((skip_change-1)) 1081 | echo -e "${ARROW} ${CYAN}Replace FluxNode Identity skipped....................[${CHECK_MARK}${CYAN}]${NC}" 1082 | fi 1083 | 1084 | if [[ "$zelnodeoutpoint" == "" ]]; then 1085 | skip_change=$((skip_change-1)) 1086 | echo -e "${ARROW} ${CYAN}Replace FluxNode Collateral TX ID skipped ..................[${CHECK_MARK}${CYAN}]${NC}" 1087 | fi 1088 | 1089 | if [[ "$zelnodeindex" == "" ]]; then 1090 | skip_change=$((skip_change-1)) 1091 | echo -e "${ARROW} ${CYAN}Replace FluxNode Output Index skipped......................[${CHECK_MARK}${CYAN}]${NC}" 1092 | fi 1093 | 1094 | #if [[ "$externalip" == "" ]]; then 1095 | #skip_change=$((skip_change-1)) 1096 | #echo -e "${ARROW} ${CYAN}Replace FluxNode IP skipped.........................[${CHECK_MARK}${CYAN}]${NC}" 1097 | #fi 1098 | 1099 | 1100 | if [[ "$skip_change" == "0" ]]; then 1101 | echo -e "${ARROW} ${YELLOW}All fields are empty changes skipped...${NC}" 1102 | echo 1103 | exit 1104 | fi 1105 | 1106 | echo -e "${ARROW} ${CYAN}Stopping Flux daemon service...${NC}" 1107 | sudo systemctl stop $COIN_NAME > /dev/null 2>&1 && sleep 2 1108 | sudo fuser -k 16125/tcp > /dev/null 2>&1 1109 | 1110 | 1111 | if [[ "$zelnodeprivkey" != "" ]]; then 1112 | 1113 | if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1114 | echo -e "${ARROW} ${CYAN}Replace FluxNode privkey skipped....................[${CHECK_MARK}${CYAN}]${NC}" 1115 | else 1116 | sed -i "s/$(grep -e zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeprivkey=$zelnodeprivkey/" ~/$CONFIG_DIR/$CONFIG_FILE 1117 | if [[ "zelnodeprivkey=$zelnodeprivkey" == $(grep -w zelnodeprivkey ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1118 | echo -e "${ARROW} ${CYAN}FluxNode privkey replaced successful................[${CHECK_MARK}${CYAN}]${NC}" 1119 | fi 1120 | fi 1121 | 1122 | fi 1123 | 1124 | if [[ "$zelnodeoutpoint" != "" ]]; then 1125 | 1126 | if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1127 | echo -e "${ARROW} ${CYAN}Replace FluxNode outpoint skipped ..................[${CHECK_MARK}${CYAN}]${NC}" 1128 | else 1129 | sed -i "s/$(grep -e zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeoutpoint=$zelnodeoutpoint/" ~/$CONFIG_DIR/$CONFIG_FILE 1130 | if [[ "zelnodeoutpoint=$zelnodeoutpoint" == $(grep -w zelnodeoutpoint ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1131 | echo -e "${ARROW} ${CYAN}FluxNode outpoint replaced successful...............[${CHECK_MARK}${CYAN}]${NC}" 1132 | fi 1133 | fi 1134 | 1135 | fi 1136 | 1137 | if [[ "$zelnodeindex" != "" ]]; then 1138 | 1139 | if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1140 | echo -e "${ARROW} ${CYAN}Replace FluxNode index skipped......................[${CHECK_MARK}${CYAN}]${NC}" 1141 | else 1142 | sed -i "s/$(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE)/zelnodeindex=$zelnodeindex/" ~/$CONFIG_DIR/$CONFIG_FILE 1143 | if [[ "zelnodeindex=$zelnodeindex" == $(grep -w zelnodeindex ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1144 | echo -e "${ARROW} ${CYAN}FluxNode index replaced successful..................[${CHECK_MARK}${CYAN}]${NC}" 1145 | 1146 | fi 1147 | fi 1148 | 1149 | fi 1150 | 1151 | #if [[ "$externalip" != "" ]]; then 1152 | 1153 | #if [[ "externalip=$externalip" == $(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1154 | #echo -e "${ARROW} ${CYAN}Replace FluxNode IP skipped.........................[${CHECK_MARK}${CYAN}]${NC}" 1155 | # else 1156 | # sed -i "s/$(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE)/externalip=$externalip/" ~/$CONFIG_DIR/$CONFIG_FILE 1157 | #if [[ "externalip=$externalip" == $(grep -w externalip ~/$CONFIG_DIR/$CONFIG_FILE) ]]; then 1158 | # echo -e "${ARROW} ${CYAN}FluxNode IP replaced successful.....................[${CHECK_MARK}${CYAN}]${NC}" 1159 | 1160 | # fi 1161 | #fi 1162 | #fi 1163 | 1164 | pm2 restart flux > /dev/null 2>&1 1165 | sudo systemctl start $COIN_NAME > /dev/null 2>&1 && sleep 2 1166 | NUM='35' 1167 | MSG1='Restarting daemon service...' 1168 | MSG2="${CYAN}........................[${CHECK_MARK}${CYAN}]${NC}" 1169 | spinning_timer 1170 | echo -e "" && echo -e "" 1171 | 1172 | } 1173 | 1174 | 1175 | function update_binary(){ 1176 | 1177 | echo -e "${GREEN}Module: Update flux daemon and benchmark binary${NC}" 1178 | echo -e "${YELLOW}================================================================${NC}" 1179 | 1180 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 1181 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 1182 | echo -e "${CYAN}Please switch to the user account.${NC}" 1183 | echo -e "${YELLOW}================================================================${NC}" 1184 | echo -e "${NC}" 1185 | exit 1186 | fi 1187 | 1188 | 1189 | echo -e "${ARROW} ${CYAN}Stopping flux daemon..${NC}" 1190 | sudo systemctl stop zelcash > /dev/null 2>&1 1191 | 1192 | 1193 | if [[ $(dpkg --print-architecture) = *amd* ]]; then 1194 | 1195 | echo -e "${ARROW} ${CYAN}Downloading file...${NC}" 1196 | sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Flux-amd64-v6.2.0.tar.gz -P /tmp > /dev/null 2>&1 1197 | sudo tar xzvf /tmp/Flux-amd64-v6.2.0.tar.gz -C /tmp > /dev/null 2>&1 1198 | sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1 1199 | sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1 1200 | 1201 | sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Fluxbench-Linux-v3.9.0.tar.gz -P /tmp > /dev/null 2>&1 1202 | sudo tar xzvf /tmp/Fluxbench-Linux-v3.9.0.tar.gz -C /tmp > /dev/null 2>&1 1203 | sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1 1204 | sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1 1205 | sudo rm -rf /tmp/flux* 2>&1 && sleep 2 1206 | sudo rm -rf /tmp/Flux* 2>&1 && sleep 2 1207 | 1208 | else 1209 | 1210 | echo -e "${ARROW} ${CYAN}Downloading file...${NC}" 1211 | sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Flux-arm-6.2.0.tar.gz -P /tmp > /dev/null 2>&1 1212 | sudo tar xzvf /tmp/Flux-arm-6.2.0.tar.gz -C /tmp > /dev/null 2>&1 1213 | sudo mv /tmp/fluxd /usr/local/bin > /dev/null 2>&1 1214 | sudo mv /tmp/flux-cli /usr/local/bin > /dev/null 2>&1 1215 | 1216 | sudo wget https://github.com/RunOnFlux/fluxd/releases/download/Testnet/Fluxbench-arm-v3.9.0.tar.gz -P /tmp > /dev/null 2>&1 1217 | sudo tar xzvf /tmp/Fluxbench-arm-v3.9.0.tar.gz -C /tmp > /dev/null 2>&1 1218 | sudo mv /tmp/fluxbenchd /usr/local/bin > /dev/null 2>&1 1219 | sudo mv /tmp/fluxbench-cli /usr/local/bin > /dev/null 2>&1 1220 | sudo rm -rf /tmp/flux* 2>&1 && sleep 2 1221 | sudo rm -rf /tmp/Flux* 2>&1 && sleep 2 1222 | 1223 | 1224 | fi 1225 | 1226 | sudo chmod 755 $COIN_PATH/* > /dev/null 2>&1 && sleep 2 1227 | echo -e "${ARROW} ${CYAN}Starting flux daemon..${NC}" 1228 | echo "" 1229 | sudo systemctl start zelcash > /dev/null 2>&1 1230 | 1231 | } 1232 | 1233 | 1234 | function mongod_db_fix() { 1235 | echo -e "${GREEN}Module: Recover corrupted MongoDB database${NC}" 1236 | echo -e "${YELLOW}================================================================${NC}" 1237 | 1238 | if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then 1239 | echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}" 1240 | echo -e "${CYAN}Please switch to the user account.${NC}" 1241 | echo -e "${YELLOW}================================================================${NC}" 1242 | echo -e "${NC}" 1243 | exit 1244 | fi 1245 | 1246 | echo -e "" 1247 | sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair 1248 | 1249 | } 1250 | 1251 | 1252 | if ! figlet -v > /dev/null 2>&1 1253 | then 1254 | sudo apt-get update -y > /dev/null 2>&1 1255 | sudo apt-get install -y figlet > /dev/null 2>&1 1256 | fi 1257 | 1258 | if ! pv -V > /dev/null 2>&1 1259 | then 1260 | sudo apt-get install -y pv > /dev/null 2>&1 1261 | fi 1262 | 1263 | if ! gzip -V > /dev/null 2>&1 1264 | then 1265 | sudo apt-get install -y gzip > /dev/null 2>&1 1266 | fi 1267 | 1268 | if ! zip -v > /dev/null 2>&1 1269 | then 1270 | sudo apt-get install -y zip > /dev/null 2>&1 1271 | fi 1272 | 1273 | if ! whiptail -v > /dev/null 2>&1 1274 | then 1275 | sudo apt-get install -y whiptail > /dev/null 2>&1 1276 | fi 1277 | 1278 | 1279 | 1280 | clear 1281 | sleep 1 1282 | echo -e "${BLUE}" 1283 | figlet -f slant "Multitoolbox TESTNET" 1284 | echo -e "${YELLOW}================================================================${NC}" 1285 | echo -e "${GREEN}Version: $dversion${NC}" 1286 | echo -e "${GREEN}Branch: ${ROOT_BRANCH}${NC}" 1287 | echo -e "${GREEN}OS: Ubuntu 16/18/19/20, Debian 9/10 ${NC}" 1288 | echo -e "${GREEN}Created by: X4MiLX from Flux's team${NC}" 1289 | echo -e "${GREEN}Special thanks to dk808, CryptoWrench && jriggs28${NC}" 1290 | echo -e "${YELLOW}================================================================${NC}" 1291 | echo -e "${CYAN}1 - Install Docker${NC}" 1292 | echo -e "${CYAN}2 - Install FluxNode${NC}" 1293 | echo -e "${CYAN}3 - Update flux daemon and benchmark binary${NC}" 1294 | echo -e "${CYAN}4 - Install/Re-install FluxOS${NC}" 1295 | echo -e "${CYAN}5 - Multinode configuration with UPNP communication (Needs Router with UPNP support) ${NC}" 1296 | echo -e "${YELLOW}================================================================${NC}" 1297 | 1298 | read -rp "Pick an option and hit ENTER: " 1299 | 1300 | case "$REPLY" in 1301 | 1302 | 1) 1303 | clear 1304 | sleep 1 1305 | install_docker 1306 | ;; 1307 | 2) 1308 | clear 1309 | sleep 1 1310 | install_node 1311 | ;; 1312 | 3) 1313 | clear 1314 | sleep 1 1315 | update_binary 1316 | ;; 1317 | 4) 1318 | clear 1319 | sleep 1 1320 | install_flux 1321 | ;; 1322 | 5) 1323 | clear 1324 | sleep 1 1325 | multinode 1326 | ;; 1327 | esac 1328 | 1329 | # USED FOR CLEANUP AT END OF SCRIPT 1330 | unset ROOT_BRANCH 1331 | unset BRANCH_ALREADY_REFERENCED 1332 | -------------------------------------------------------------------------------- /post-merge: -------------------------------------------------------------------------------- 1 | #/usr/bin/env bash 2 | # MIT © Sindre Sorhus - sindresorhus.com 3 | 4 | # git hook to run a command after `git pull` if a specified file was changed 5 | # Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. 6 | 7 | changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" 8 | 9 | check_run() { 10 | echo "$changed_files" | grep --quiet "$1" && eval "$2" 11 | } 12 | 13 | # Example usage 14 | # In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. 15 | check_run package.json "npm install" 16 | -------------------------------------------------------------------------------- /scripts/ip_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | url_array=( 3 | "https://api4.my-ip.io/ip" 4 | "https://checkip.amazonaws.com" 5 | "https://api.ipify.org" 6 | ) 7 | 8 | function get_ip() { 9 | for url in "$@"; do 10 | WANIP=$(curl --silent -m 15 "$url" | tr -dc '[:alnum:].') 11 | # Remove dots from the IP address 12 | IP_NO_DOTS=$(echo "$WANIP" | tr -d '.') 13 | # Check if the result is a valid number 14 | if [[ "$IP_NO_DOTS" != "" && "$IP_NO_DOTS" =~ ^[0-9]+$ ]]; then 15 | break 16 | fi 17 | done 18 | } 19 | 20 | function get_device_name(){ 21 | if [[ -f /home/$USER/device_conf.json ]]; then 22 | device_name=$(jq -r .device_name /home/$USER/device_conf.json) 23 | else 24 | device_name=$(ip addr | grep 'BROADCAST,MULTICAST,UP,LOWER_UP' | head -n1 | awk '{print $2}' | sed 's/://' | sed 's/@/ /' | awk '{print $1}') 25 | fi 26 | } 27 | 28 | if [[ $1 == "restart" ]]; then 29 | #give 3min to connect with internet 30 | sleep 180 31 | get_ip "${url_array[@]}" 32 | get_device_name 33 | if [[ "$device_name" != "" && "$WANIP" != "" ]]; then 34 | date_timestamp=$(date '+%Y-%m-%d %H:%M:%S') 35 | echo -e "New IP detected during $1, IP: $WANIP was added to $device_name at $date_timestamp" >> /home/$USER/ip_history.log 36 | sudo ip addr add $WANIP dev $device_name && sleep 2 37 | fi 38 | fi 39 | if [[ $1 == "ip_check" ]]; then 40 | get_ip "${url_array[@]}" 41 | get_device_name 42 | api_port=$(grep -w apiport /home/$USER/zelflux/config/userconfig.js | grep -o '[[:digit:]]*') 43 | if [[ "$api_port" == "" ]]; then 44 | api_port="16127" 45 | fi 46 | confirmed_ip=$(curl -SsL -m 10 http://localhost:$api_port/flux/info 2>/dev/null | jq -r .data.node.status.ip | sed -r 's/:.+//') 47 | if [[ "$WANIP" != "" && "$confirmed_ip" != "" && "$confirmed_ip" != "null" ]]; then 48 | if [[ "$WANIP" != "$confirmed_ip" ]]; then 49 | date_timestamp=$(date '+%Y-%m-%d %H:%M:%S') 50 | echo -e "New IP detected during $1, IP: $WANIP was added to $device_name at $date_timestamp" >> /home/$USER/ip_history.log 51 | sudo ip addr add $WANIP dev $device_name && sleep 2 52 | fi 53 | fi 54 | fi 55 | -------------------------------------------------------------------------------- /scripts/start_daemon_service.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #color codes 3 | RED='\033[1;31m' 4 | CYAN='\033[1;36m' 5 | NC='\033[0m' 6 | #emoji codes 7 | BOOK="${RED}\xF0\x9F\x93\x8B${NC}" 8 | WORNING="${RED}\xF0\x9F\x9A\xA8${NC}" 9 | directory="/usr/local/bin" 10 | current_user="$USER" 11 | sleep 2 12 | # Check if the directory exists 13 | if [ -d "$directory" ]; then 14 | echo "Checking for files in $directory..." 15 | # Use find to search for all files in the directory 16 | all_files=$(find "$directory" -maxdepth 1) 17 | if [ -n "$all_files" ]; then 18 | # Identify files not owned by the current user 19 | non_user_files=$(find "$directory" -maxdepth 1 ! -user "$current_user") 20 | if [ -n "$non_user_files" ]; then 21 | echo "Files not owned by $current_user found:" 22 | echo "$non_user_files" 23 | # Change ownership of non-user files to the current user 24 | echo "Changing ownership to $current_user..." 25 | sudo chown "$current_user":"$current_user" $non_user_files 26 | echo "Ownership changed successfully." 27 | else 28 | echo "All files are owned by $current_user." 29 | fi 30 | else 31 | echo "No files found in $directory." 32 | fi 33 | else 34 | echo "Directory $directory does not exist." 35 | fi 36 | echo -e "${BOOK} ${CYAN}Pre-start process starting...${NC}" 37 | echo -e "${BOOK} ${CYAN}Checking if benchmark or daemon is running${NC}" 38 | bench_status_pind=$(pgrep fluxbenchd) 39 | daemon_status_pind=$(pgrep fluxd) 40 | if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then 41 | echo -e "${BOOK} ${CYAN}No running instance detected...${NC}" 42 | else 43 | if [[ "$bench_status_pind" != "" ]]; then 44 | echo -e "${WORNING} Running benchmark process detected${NC}" 45 | echo -e "${WORNING} Killing benchmark...${NC}" 46 | sudo killall -9 fluxbenchd > /dev/null 2>&1 && sleep 2 47 | fi 48 | if [[ "$daemon_status_pind" != "" ]]; then 49 | echo -e "${WORNING} Running daemon process detected${NC}" 50 | echo -e "${WORNING} Killing daemon...${NC}" 51 | sudo killall -9 fluxd > /dev/null 2>&1 && sleep 2 52 | fi 53 | sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1 54 | fi 55 | bench_status_pind=$(pgrep zelbenchd) 56 | daemon_status_pind=$(pgrep zelcashd) 57 | if [[ "$bench_status_pind" == "" && "$daemon_status_pind" == "" ]]; then 58 | echo -e "${BOOK} ${CYAN}No running instance detected...${NC}" 59 | else 60 | if [[ "$bench_status_pind" != "" ]]; then 61 | echo -e "${WORNING} Running benchmark process detected${NC}" 62 | echo -e "${WORNING} Killing benchmark...${NC}" 63 | sudo killall -9 zelbenchd > /dev/null 2>&1 && sleep 2 64 | fi 65 | if [[ "$daemon_status_pind" != "" ]]; then 66 | echo -e "${WORNING} Running daemon process detected${NC}" 67 | echo -e "${WORNING} Killing daemon...${NC}" 68 | sudo killall -9 zelcashd > /dev/null 2>&1 && sleep 2 69 | fi 70 | sudo fuser -k 16125/tcp > /dev/null 2>&1 && sleep 1 71 | fi 72 | if [[ -f /usr/local/bin/fluxd ]]; then 73 | bash -c "fluxd" 74 | exit 75 | else 76 | bash -c "zelcashd" 77 | exit 78 | fi 79 | -------------------------------------------------------------------------------- /scripts/stop_daemon_service.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ -f /usr/local/bin/flux-cli ]]; then 3 | bash -c "flux-cli stop" 4 | else 5 | bash -c "zelcash-cli stop" 6 | fi 7 | exit 8 | --------------------------------------------------------------------------------