This commit is contained in:
0xOzgur 2024-05-20 19:46:15 +03:00
parent 8977fb4c93
commit 92a8c81863
5 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#!/bin/bash
# Navigate to the directory
cd /root/ceremonyclient/client || exit
# Run the command and extract the token balance
balance=$(./qclient token balance | grep -oP '\b\d+(?=\.\d+\s+QUIL)')
# Check if balance is not empty
if [ -n "$balance" ]; then
# Get the current date in the required format
current_date=$(date +"%d/%m/%Y")
# Log the balance value in CSV format
echo "$current_date,$balance" >> /root/scripts/log/quil_balance.csv
else
# Get the current date in the required format
current_date=$(date +"%d/%m/%Y")
# Log "error" in CSV format
echo "$current_date,error" >> /root/scripts/log/quil_balance.csv
fi

View File

@ -0,0 +1,75 @@
#!/bin/bash
# Step 1: Ensure /root/scripts and /root/scripts/log directories exist
echo "Checking if /root/scripts and /root/scripts/log directories exist..."
if mkdir -p /root/scripts/log; then
echo "Directories ensured successfully."
else
echo "Failed to ensure directories." >&2
exit 1
fi
# Step 2: Create or overwrite quil_balance_checker.sh
echo "Creating or overwriting /root/scripts/quil_balance_checker.sh..."
if echo '#!/bin/bash' > /root/scripts/quil_balance_checker.sh; then
echo "File /root/scripts/quil_balance_checker.sh created successfully."
else
echo "Failed to create /root/scripts/quil_balance_checker.sh." >&2
exit 1
fi
# Step 3: Paste the script content into quil_balance_checker.sh
echo "Adding script content to /root/scripts/quil_balance_checker.sh..."
if echo "#!/bin/bash
# Navigate to the directory
cd /root/ceremonyclient/client || exit
# Run the command and extract the token balance
balance=\$(./qclient token balance | grep -oP '\\b\\d+(?=\\.\\d+\\s+QUIL)')
# Check if balance is not empty
if [ -n \"\$balance\" ]; then
# Get the current date in the required format
current_date=\$(date +\"%d/%m/%Y\")
# Log the balance value in CSV format
echo \"\$current_date,\$balance\" >> /root/scripts/log/quil_balance.csv
else
# Get the current date in the required format
current_date=\$(date +\"%d/%m/%Y\")
# Log \"error\" in CSV format
echo \"\$current_date,error\" >> /root/scripts/log/quil_balance.csv
fi
" > /root/scripts/quil_balance_checker.sh; then
echo "Script content added successfully."
else
echo "Failed to add script content." >&2
exit 1
fi
# Step 4: Grant execute permissions
echo "Setting execute permissions for /root/scripts/quil_balance_checker.sh..."
if chmod +x /root/scripts/quil_balance_checker.sh; then
echo "Execute permissions set successfully."
else
echo "Failed to set execute permissions." >&2
exit 1
fi
# Step 5: Create cronjob if not already existing
echo "Checking for existing cronjob..."
if crontab -l | grep -q 'quil_balance_checker.sh'; then
echo "Cronjob already exists."
else
echo "Creating new cronjob..."
if { crontab -l; echo '0 10 * * * export TZ="Europe/Rome" && /root/scripts/quil_balance_checker.sh'; } | crontab -; then
echo "Cronjob created successfully."
else
echo "Failed to create cronjob." >&2
exit 1
fi
fi
echo "Installer script executed successfully!"

View File

@ -1,5 +1,6 @@
#!/bin/bash
cd ~
# Step 0: Welcome
echo "This script is prepared by 0xOzgur.eth"

View File

@ -1,5 +1,6 @@
#!/bin/bash
cd ~
# Step 0: Welcome
echo "This script is prepared by 0xOzgur.eth"

View File

@ -1,5 +1,7 @@
#!/bin/bash -i
cd ~
# Step 0: Welcome
echo "This script is prepared by 0xOzgur.eth"
echo "Enjoy and sit back while you are building your Quilibrium Node!"