Upload files to "/"

These are the decoration greeting script that shows information and users who are currently logged in 
decorated ascii arts and colors while ssh into mobile server.
This commit is contained in:
arul 2024-06-02 20:46:07 +00:00
parent aa2c1bf57b
commit 969e55ac42
3 changed files with 74 additions and 0 deletions

27
banner.sh Normal file
View File

@ -0,0 +1,27 @@
#greet banner NAS
toilet -f bigascii12 -F metal NAS
# Define greet function
greet() {
# Display the message inside a rectangle box with a smaller font size using toilet
echo -e "\033[1;37m$(echo -e "$status")" | toilet -t -f term -F border -w 120 -W
}
# Count the number of devices connected via ssh on port 8022
netstatcount=$(netstat | grep ':8022' | grep 'ESTABLISHED' | wc -l)
tempcount=$((netstatcount - netstatcount / 2))
actualcount=$((tempcount - 1))
# Use that count to decide the process flow
if [ $tempcount -gt 1 ]; then
status="Welcome to Arul's Android NAS server. \n [$actualcount devices were connected to NAS]"
greet;
else
status="Welcome to Arul's Android NAS server. \n [$actualcount device were connected to NAS]"
greet;
fi

24
print_box.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# Function to print a decorated rectangular box with random bright color
print_box() {
local text="$(cat)"
local text_length=${#text}
local box_width=$((text_length + 4))
# Generate a random number between 0 and 7 for ANSI bright color code
local color_code=$((RANDOM % 8 + 90))
# ANSI escape codes for bright text color
local color="\e[${color_code}m"
local reset_color="\e[0m"
# Top border
echo -e "${color}$(printf '─%.0s' $(seq 1 $box_width))${reset_color}"
# Text with borders
echo -e "${color}$text${reset_color}"
# Bottom border
echo -e "${color}$(printf '─%.0s' $(seq 1 $box_width))${reset_color}"
}

23
print_log_box.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Source the print_box function
source ~/.custmScrpt/print_box.sh
# Array of log file paths or log variables
log_files=(
"$HOME/.cronlog/rvp_navidrome.txt"
"$HOME/.cronlog/rvp_http.txt"
# Add more log file paths or variables as needed
)
# Loop through each log file or variable
for log_file in "${log_files[@]}"; do
# Check if the log file exists
if [ ! -f "$log_file" ]; then
echo "Error: Log file $log_file does not exist."
continue
fi
# Use grep to filter the log file and pass the output to print_box
echo "$(basename $log_file):" && grep -m 1 -oE 'https?://[^/"]+' "$log_file" | sed -e 's/^/│ /' -e 's/$/ │/' | print_box
done