Last active
October 22, 2024 00:05
-
-
Save imacrosid/c6dcfb1b9ae17eee0d442a3e01847606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Automation by LAEY 0xpH | |
# t.me/imacrosid | |
# v1.3.1 | |
# ANSI color codes | |
RED='\e[0;31m' | |
GREEN='\e[0;32m' | |
YELLOW='\e[0;33m' | |
BLUE='\e[0;34m' | |
REDB='\e[1;31m' | |
GREENB='\e[1;32m' | |
YELLOWB='\e[1;33m' | |
BLUEB='\e[1;34m' | |
DC='\e[0m' # Default Color | |
# create directory, download require & install depency create random wallet | |
getCreateWallet() { | |
if [ ! -d "createWallet" ]; then | |
mkdir createWallet | |
fi | |
cd createWallet || exit | |
echo -e "\n${YELLOWB}Download all requirements for creating random wallet${DC}" | |
sleep 1 | |
downloadFile() { | |
local file_url="$1" | |
local file_name="$2" | |
echo -e "\nDownloading ${file_name}..." | |
wget --header="Authorization: token $github_token" --show-progress -q -O "$file_name" "$file_url" | |
if [[ $? -eq 0 ]]; then | |
echo "${file_name} downloaded successfully." | |
else | |
echo "Failed to download ${file_name}" | |
fi | |
} | |
declare -A files_to_download=( | |
["index.js"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/createWallet/index.js" | |
["package.json"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/createWallet/package.json" | |
) | |
for file in "${!files_to_download[@]}"; do | |
downloadFile "${files_to_download[$file]}" "$file" | |
done | |
echo -e "\n${YELLOW}Installing dependencies...${DC}" | |
sleep 1 | |
npm install --silent | |
echo "Complete". | |
# Back to main directory | |
cd .. && sleep 1 | |
} | |
# create directory, download require & install depency telegram notifier | |
getNotifierTelegramTools() { | |
if [ ! -d "eligibility-status-notifier" ]; then | |
mkdir eligibility-status-notifier | |
fi | |
cd eligibility-status-notifier || exit | |
echo -e "\n${YELLOWB}Download all requirements for telegram notifier tools${DC}" | |
sleep 1 | |
downloadFile() { | |
local file_url="$1" | |
local file_name="$2" | |
echo -e "\nDownloading ${file_name}..." | |
wget --header="Authorization: token $github_token" --show-progress -q -O "$file_name" "$file_url" | |
if [[ $? -eq 0 ]]; then | |
echo "${file_name} downloaded successfully." | |
else | |
echo "Failed to download ${file_name}" | |
fi | |
} | |
declare -A files_to_download=( | |
["index.js"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/eligibility-status-notifier/index.js" | |
["package.json"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/eligibility-status-notifier/package.json" | |
[".env"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/eligibility-status-notifier/.env.example" | |
["data-nodes.txt"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/eligibility-status-notifier/src/example-data-nodes.txt" | |
["oceanApi.js"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/eligibility-status-notifier/src/oceanApi.js" | |
["telegramApi.js"]="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/eligibility-status-notifier/src/telegramApi.js" | |
) | |
for file in "${!files_to_download[@]}"; do | |
downloadFile "${files_to_download[$file]}" "$file" | |
done | |
if [ ! -d "src" ]; then | |
mkdir src | |
fi | |
sudo mv data-nodes.txt ./src/data-nodes.txt | |
sudo mv oceanApi.js ./src/oceanApi.js | |
sudo mv telegramApi.js ./src/telegramApi.js | |
echo -e "\n${YELLOW}Installing dependencies...${DC}" | |
sleep 1 | |
npm install --silent | |
echo "Complete". | |
# Back to main directory | |
cd .. && sleep 1 | |
} | |
# option for download version check eligibility script | |
getCheckEligibleScript() { | |
echo -e "\n${YELLOWB}Download check eligibility script${DC}\n" | |
echo -e "1. Bash check-eligible.sh - ${GREEN}STABLE${DC}" | |
echo -e "2. NodeJS check-eligible.js - ${YELLOW}EXPERIMENTAL${DC}" | |
echo "" | |
read -p "Choose (1/2) ? " CHOOSE_SCRIPT | |
echo "" | |
case "$CHOOSE_SCRIPT" in | |
1) | |
echo "You have chosen Bash script - STABLE" | |
FILE_NAME="check-eligible.sh" | |
;; | |
2) | |
echo "You have chosen NodeJS script - EXPERIMENTAL" | |
FILE_NAME="check-eligible.js" | |
;; | |
*) | |
echo "Invalid choice, please select 1 or 2." | |
return | |
;; | |
esac | |
sleep 1 | |
URL="https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/$FILE_NAME" | |
wget --header="Authorization: token $github_token" --show-progress -q -O "$FILE_NAME" "$URL" | |
if [[ $? -eq 0 ]]; then | |
echo "$FILE_NAME downloaded successfully." | |
chmod +x "$FILE_NAME" | |
else | |
echo "Failed to download $FILE_NAME" | |
fi | |
} | |
echo -e "\n# # # ${GREENB}Auto Config Docker Ocean Node${DC} # # #\n" | |
sleep 1 | |
read -p "Download custom private file, Please provide your github token: " github_token | |
sleep 1 | |
echo -e "\n${YELLOW}Installing Docker...${DC}" | |
if command -v docker >/dev/null 2>&1; then | |
echo -e "${RED}Skipped, Docker is already installed.${DC}" | |
else | |
curl -fsSL https://get.docker.com | sh > /dev/null 2>&1 | |
docker_version=$(docker --version) | |
echo "$docker_version has been installed." | |
fi | |
sleep 1 | |
echo -e "\n${YELLOW}Installing Npm and Node.js...${DC}" | |
wget -q --show-progress https://nodejs.org/dist/v20.18.0/node-v20.18.0-linux-x64.tar.xz | |
echo "Extracting files..." | |
tar -xvf node-v20.18.0-linux-x64.tar.xz >/dev/null 2>&1 | |
if [ -d "/usr/local/node-v20.18.0/node-v20.18.0-linux-x64" ]; then | |
rm -r "/usr/local/node-v20.18.0/node-v20.18.0-linux-x64" | |
fi | |
sudo mv node-v20.18.0-linux-x64 /usr/local/node-v20.18.0 | |
sudo ln -s /usr/local/node-v20.18.0/bin/node /usr/local/bin/node >/dev/null 2>&1 | |
sudo ln -s /usr/local/node-v20.18.0/bin/npm /usr/local/bin/npm >/dev/null 2>&1 | |
sudo ln -s /usr/local/node-v20.18.0/bin/npx /usr/local/bin/npx >/dev/null 2>&1 | |
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc | |
source ~/.bashrc | |
sudo rm -r node-v20.18.0-linux-x64.tar.xz | |
echo "Complete." | |
npm_version=$(npm -v) | |
node_version=$(node -v) | |
echo "Npm $npm_version has been installed." | |
echo "NodeJS $node_version has been installed." | |
sleep 1 | |
echo -e "\n${YELLOW}Installing JQ Tools...${DC}" | |
if command -v jq >/dev/null 2>&1; then | |
echo -e "${RED}Skipped, JQ is already installed.${DC}" | |
else | |
sudo apt install jq -qy >/dev/null 2>&1 | |
jq_version=$(jq --version) | |
echo "$jq_version has been installed." | |
fi | |
sleep 1 | |
echo -e "\n${YELLOWB}Download bash auto config ocean node${DC}" | |
sleep 1 | |
echo -e "\nDownloading auto.sh" | |
wget --header="Authorization: token $github_token" --show-progress -q -O auto.sh https://raw.githubusercontent.com/0xpH/auto-config-ocean-node/refs/heads/main/custom-install.sh | |
if [[ $? -eq 0 ]]; then | |
echo "auto.sh downloaded successfully." | |
chmod +x auto.sh | |
else | |
echo "Failed to download auto.sh" | |
fi | |
sleep 1 | |
getCreateWallet | |
sleep 1 | |
getCheckEligibleScript | |
echo -e "\n${REDB}IMPORTANT! To use the check eligibility script, you must read the README.md!${DC}" | |
sleep 10 | |
echo "" | |
read -p "Get Telegram Notifier Tools (y/n)? " INCLUDED_NOTIFIER | |
if [[ "$INCLUDED_NOTIFIER" == "y" || "$INCLUDED_NOTIFIER" == "Y" ]]; then | |
echo "You have chosen to include the Telegram Notifier Tools." | |
sleep 1 | |
getNotifierTelegramTools | |
elif [[ "$INCLUDED_NOTIFIER" == "n" || "$INCLUDED_NOTIFIER" == "N" ]]; then | |
echo "You have chosen not to include the Telegram Notifier Tools." | |
else | |
echo "Invalid input. Please enter 'y' or 'n'." | |
fi | |
sleep 1 | |
sudo killall -9 apt apt-get dpkg | |
sudo dpkg --configure -a >/dev/null 2>&1 | |
echo -e "\n${YELLOW}Updating packages...${DC}" | |
sudo apt update -qy 2>>error.log | |
echo "Process complete." | |
sleep 1 | |
echo -e "\n${YELLOW}Upgrading packages...${DC}" | |
sudo apt upgrade -qy 2>>error.log | |
echo "Process complete." | |
sleep 1 | |
echo -e "\n${YELLOW}Removing unused packages...${DC}" | |
sudo apt autoremove -qy 2>>error.log | |
echo "Process complete." | |
sleep 1 | |
echo -e "\nStarting auto config..." | |
sleep 5 | |
./auto.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment