#!/bin/bash

### Colors ##
ESC=$(printf '\033')
RESET="${ESC}[0m"
BLACK="${ESC}[30m"
RED="${ESC}[31m"
GREEN="${ESC}[32m"
YELLOW="${ESC}[33m"
BLUE="${ESC}[34m"
MAGENTA="${ESC}[35m"
CYAN="${ESC}[36m"
WHITE="${ESC}[37m"
DEFAULT="${ESC}[39m"

### Color Functions ##

greenprint() { printf "${GREEN}%s${RESET}\n" "$1"; }
blueprint() { printf "${BLUE}%s${RESET}\n" "$1"; }
redprint() { printf "${RED}%s${RESET}\n" "$1"; }
yellowprint() { printf "${YELLOW}%s${RESET}\n" "$1"; }
magentaprint() { printf "${MAGENTA}%s${RESET}\n" "$1"; }
cyanprint() { printf "${CYAN}%s${RESET}\n" "$1"; }
fn_bye() { exit 0; }
fn_fail() { echo "Wrong Option" exit 1; }
fn_hash() { echo $(redprint 'File hash mismatch. Script will exit. Please check your internet connection and rerun this script...'); }


echo '
 ██╗███╗░░██╗░█████╗░░█████╗░░██████╗░███╗░░██╗██╗████████╗░█████╗░░░░░█████╗░██████╗░░██████╗░
 ██║████╗░██║██╔══██╗██╔══██╗██╔════╝░████╗░██║██║╚══██╔══╝██╔══██╗░░░██╔══██╗██╔══██╗██╔════╝░
 ██║██╔██╗██║██║░░╚═╝██║░░██║██║░░██╗░██╔██╗██║██║░░░██║░░░██║░░██║░░░██║░░██║██████╔╝██║░░██╗░
 ██║██║╚████║██║░░██╗██║░░██║██║░░╚██╗██║╚████║██║░░░██║░░░██║░░██║░░░██║░░██║██╔══██╗██║░░╚██╗
 ██║██║░╚███║╚█████╔╝╚█████╔╝╚██████╔╝██║░╚███║██║░░░██║░░░╚█████╔╝██╗╚█████╔╝██║░░██║╚██████╔╝
 ╚═╝╚═╝░░╚══╝░╚════╝░░╚════╝░░╚═════╝░╚═╝░░╚══╝╚═╝░░░╚═╝░░░░╚════╝░╚═╝░╚════╝░╚═╝░░╚═╝░╚═════╝░


      ░█▀▀█ █▀▀█ █▀▀█ ▀▀█▀▀ █▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ █▀▀█ 　 ░█▀▀▀█ █▀▀ █▀▀█ ─▀─ █▀▀█ ▀▀█▀▀
      ░█▀▀▄ █──█ █──█ ──█── ▀▀█ ──█── █▄▄▀ █▄▄█ █──█ 　 ─▀▀▀▄▄ █── █▄▄▀ ▀█▀ █──█ ──█──
      ░█▄▄█ ▀▀▀▀ ▀▀▀▀ ──▀── ▀▀▀ ──▀── ▀─▀▀ ▀──▀ █▀▀▀ 　 ░█▄▄▄█ ▀▀▀ ▀─▀▀ ▀▀▀ █▀▀▀ ──▀──
																					
                                                                          version 2.0



Welcome to the Incognito Bootstrap Script. This script has been coded to do the following:
1.) Stop the Docker container from running
2.) Remove stalled/corrupt data from the node
3.) Download and extract the required bootstrap data
4.) Verify beacon/shard file hash, will exit if corrupted
5.) Start the Docker container


CHANGE LOG:
v2.1 - 
- Stopping IncognitoUpdater.service for vNodes (helps ensure script runs on slower servers/connections)

v2.0 - 
- Automatic downloading of dependencies. Will only run once per server.
- Automatic removal of other directories/files that occasionally get corrupted.
	- bnbrelayingv3  btcrelayingv8  __coins__  consensus  incognito  listenerpeer.json  mempool

v1.5 - 
- Added fullnode support with option 55 for vNodes.
- Updated to new bootstrap server.
- Optimized downloading of dependencies and will only check once per node.

v1.0 -
- Download support for Beacon & Shard data.

To use this script follow the on-screen prompts:'

if [[ ! -f .bootstrap.incognito ]]
then
    echo $(yellowprint 'Installing dependencies...')
	sudo apt update --fix-missing && sudo apt install axel zstd -y
	sudo touch .bootstrap.incognito
	sleep 3
fi

vnode-menu() {
    echo -ne "
$(yellowprint 'vNode-Menu')
$(greenprint '00)') Delete & Bootstrap Beacon Data
$(greenprint ' 0)') Delete & Bootstrap Shard0 Data
$(greenprint ' 1)') Delete & Bootstrap Shard1 Data
$(greenprint ' 2)') Delete & Bootstrap Shard2 Data
$(greenprint ' 3)') Delete & Bootstrap Shard3 Data
$(greenprint ' 4)') Delete & Bootstrap Shard4 Data
$(greenprint ' 5)') Delete & Bootstrap Shard5 Data
$(greenprint ' 6)') Delete & Bootstrap Shard6 Data
$(greenprint ' 7)') Delete & Bootstrap Shard7 Data
$(greenprint '55)') Fullnode Mode (Beacon & ALL Shards)
$(magentaprint '77)') Go Back to MAIN MENU
$(greenprint '88)') Start Docker Container & Exit Script
$(redprint '99)') Exit Script
Choose an option:  "
    read -r ans
    case $ans in
    00)
        echo $(yellowprint 'Removing Beacon Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/beacon
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/beacon.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/beacon.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/beacon.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		vnode-menu
		;;
    0)
        echo $(yellowprint 'Removing Shard0 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard0
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard0.tar.zst  
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard0.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard0.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    1)
        echo $(yellowprint 'Removing Shard1 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard1
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard1.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard1.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard1.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    2)
        echo $(yellowprint 'Removing Shard2 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard2
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard2.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard2.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard2.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    3)
        echo $(yellowprint 'Removing Shard3 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard3
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard3.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard3.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard3.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    4)
        echo $(yellowprint 'Removing Shard4 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard4
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard4.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard4.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard4.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    5)
        echo $(yellowprint 'Removing Shard5 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard5
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard5.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard5.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard5.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    6)
        echo $(yellowprint 'Removing Shard6 Data...')
        sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard6
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard6.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard6.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard6.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    7)
        echo $(yellowprint 'Removing Shard7 Data...')
		sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard7
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard7.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard7.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard7.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    55)
        echo $(yellowprint 'Removing All Data...')
        sleep 3
		sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sudo rm -rfv ${directory}node_data_${node}/mainnet/block/beacon
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard0
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard1
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard2
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard3
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard4
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard5
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard6
		sudo rm -rfv ${directory}node_data_${node}/mainnet/block/shard7
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		echo $(greenprint 'Downloading Beacon Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/beacon.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/beacon.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/beacon.tar.zst
		echo $(greenprint 'Downloading Shard0 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard0.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard0.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard0.tar.zst
		echo $(greenprint 'Downloading Shard1 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard1.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard1.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard1.tar.zst
		echo $(greenprint 'Downloading Shard2 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard2.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard2.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard2.tar.zst
		echo $(greenprint 'Downloading Shard3 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard3.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard3.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard3.tar.zst
		echo $(greenprint 'Downloading Shard4 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard4.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard4.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard4.tar.zst
		echo $(greenprint 'Downloading Shard5 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard5.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard5.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard5.tar.zst
		echo $(greenprint 'Downloading Shard6 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard6.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard6.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard6.tar.zst
		echo $(greenprint 'Downloading Shard7 Data')
		sleep 3
		sudo axel -a -n 20 -o ${directory}node_data_${node}/mainnet/block/ https://bootstrap.incognito.org/shard7.tar.zst
		sudo tar -I zstd -xvf ${directory}node_data_${node}/mainnet/block/shard7.tar.zst --directory ${directory}node_data_${node}/mainnet/block/
		sudo rm -f ${directory}node_data_${node}/mainnet/block/shard7.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')        
		vnode-menu
		;;
    77)
        mainmenu
        ;;
    88)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
		echo $(greenprint 'Start Docker Container & Exit Script')
		sudo docker container start inc_mainnet_${node}
		sudo systemctl start IncognitoUpdater.service
		sleep 1
		echo $(greenprint 'Complete. Note- The Node Monitor (monitor.incognito.org) can take ~15 minutes to update...')
		fn_bye
		;;
    99)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
		echo $(redprint 'Exiting Script...')
		sleep 0.5
        fn_bye
        ;;
    *)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
        fn_fail
        ;;
    esac
}

pnode-menu() {
    echo -ne "
$(yellowprint 'pNode-Menu')
$(greenprint '00)') Delete & Bootstrap Beacon Data
$(greenprint ' 0)') Delete & Bootstrap Shard0 Data
$(greenprint ' 1)') Delete & Bootstrap Shard1 Data
$(greenprint ' 2)') Delete & Bootstrap Shard2 Data
$(greenprint ' 3)') Delete & Bootstrap Shard3 Data
$(greenprint ' 4)') Delete & Bootstrap Shard4 Data
$(greenprint ' 5)') Delete & Bootstrap Shard5 Data
$(greenprint ' 6)') Delete & Bootstrap Shard6 Data
$(greenprint ' 7)') Delete & Bootstrap Shard7 Data
$(magentaprint '77)') Go Back to Main Menu
$(greenprint '88)') Start Docker Container & Exit Script
$(redprint '99)') Exit Script
Choose an option:  "
    read -r ans
    case $ans in
    00)
        echo $(yellowprint 'Removing Beacon Data...')
        sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/beacon
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 3
		sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/beacon.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/beacon.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/beacon.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;
    0)
        echo $(yellowprint 'Removing Shard0 Data...')
        sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard0
		echo $(greenprint 'Deleted Data Successfully...')
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard0.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard0.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard0.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;
    1)
        echo $(yellowprint 'Removing Shard1 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard1
		echo $(greenprint 'Deleted Data Successfully...')
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard1.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard1.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard1.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;
    2)
        echo $(yellowprint 'Removing Shard2 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard2
		echo $(greenprint 'Deleted Data Successfully...')
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard2.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard2.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard2.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;
    3)
        echo $(yellowprint 'Removing Shard3 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard3
		echo $(greenprint 'Deleted Data Successfully...')
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard3.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard3.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard3.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;	
    4)
        echo $(yellowprint 'Removing Shard4 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard4/*
		echo $(greenprint 'Deleted Data Successfully...')
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard4.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard4.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard4.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;	
    5)
        echo $(yellowprint 'Removing Shard5 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard5
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 4
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard5.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard5.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard5.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;	
    6)
        echo $(yellowprint 'Removing Shard6 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard6
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 4
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard6.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard6.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard6.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;	
    7)
        echo $(yellowprint 'Removing Shard7 Data...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
        sleep 3
        sudo rm -rfv /home/nuc/aos/inco-data/mainnet/block/shard7
		echo $(greenprint 'Deleted Data Successfully...')
		sleep 4
        sleep 3
        sudo axel -a -n 20 -o /home/nuc/aos/inco-data/mainnet/block/ https://bootstrap.incognito.org/shard7.tar.zst
		sleep 3
		echo $(yellowprint 'Populating directory...')
		sudo tar -I zstd -xvf /home/nuc/aos/inco-data/mainnet/block/shard7.tar.zst --directory /home/nuc/aos/inco-data/mainnet/block/
		echo $(greenprint 'Finished. Removing Zipped File...')
		sudo rm -f /home/nuc/aos/inco-data/mainnet/block/shard7.tar.zst
		sleep 3
		echo $(greenprint 'COMPLETE! If you are finished deleting data use menu option 88 to Start Docker Container!')
		pnode-menu
        ;;	
    77)
        menu
        ;;
    88)
        echo $(greenprint 'Start Docker Container & Exit Script')
        sudo docker container start inc_mainnet
		sudo service supervisor start
		echo $(yellowprint 'Cleaning up...')
		sleep 1
		echo $(greenprint 'Complete. Note- The Node Monitor (monitor.incognito.org) can take ~15 minutes to update...')
		fn_bye
		;;
    99)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
		echo $(redprint 'Exiting Script...')
		sleep 0.5
        fn_bye
        ;;
    *)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
        fn_fail
        ;;
    esac
}

mainmenu() {
    echo -ne "
$(magentaprint 'MAIN MENU')
$(greenprint '1)') pNode Menu
$(greenprint '2)') vNode Menu
$(redprint '99)') Exit Script
Choose your node type:  "
    read -r ans
    case $ans in
    1)
		echo $(redprint 'Stopping pNode Docker Container...')
		sudo docker container stop inc_mainnet
		echo $(greenprint 'Docker Container Stopped!')
		sleep 1
		echo $(redprint 'Stopping Supervisor Service!')
		sudo service supervisor stop
		echo $(greenprint 'Supervisor Service Stopped!')
		echo $(yellowprint 'Removing problematic files/directories...')
		sudo rm -rf /home/nuc/aos/inco-data/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 1
        pnode-menu
        mainmenu
        ;;
    2)
		read -p "Enter Node Directory Location (hit enter to keep default): " -i /home/incognito/ -e directory
		echo $(redprint 'What node do you want to bootstrap? Couting starts at 0.')
		sudo systemctl stop IncognitoUpdater.service
		echo -ne node_data_
		read node
		echo
		echo ##################################
		echo You have seleceted node_data_${node}
		echo ##################################
		echo
		echo Stopping vNode inc_mainnet_${node}
		sudo docker container stop inc_mainnet_${node}
		echo $(yellowprint 'Removing problematic files/directories...')
		sudo rm -rf ${directory}node_data_${node}/mainnet/{bnbrelayingv3,btcrelayingv8,__coins__,consensus,incognito,listenerpeer.json,mempool}
		sleep 1
		vnode-menu
		mainmenu
		;;
	99)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
		echo $(redprint 'Exiting Script...')
		sleep 0.5
        fn_bye
        ;;
    *)
		echo $(yellowprint 'Cleaning up...')
		sleep 1
        fn_fail
        ;;
    esac
}

mainmenu

