diff --git a/simpleadmin/www/cgi-bin/get_uptime b/simpleadmin/www/cgi-bin/get_uptime new file mode 100644 index 0000000..8e27fec --- /dev/null +++ b/simpleadmin/www/cgi-bin/get_uptime @@ -0,0 +1,26 @@ +#!/bin/bash + +# Execute the uptime command and extract the uptime duration +uptime_output=$(uptime) + +# Extract hours and minutes from the uptime string +hours=$(echo "$uptime_output" | awk -F '[ :]+' '{print $6}') +minutes=$(echo "$uptime_output" | awk -F '[ :]+' '{print $7}') + +# Remove comma to minutes +minutes=$(echo $minutes | tr -d ,) + +# Create a text response with the uptime duration +uptime_text="$hours hours and $minutes minutes" + +# if hours and minutes are 1 or 0, then remove the 's' from the end of the string +if [ $hours -eq 1 ] || [ $hours -eq 0 ]; then + uptime_text=$(echo $uptime_text | sed 's/hours/hour/g') +fi + +# Set header for plain text content +echo "Content-Type: text/plain" +echo "" + +# Output the text response +echo "$uptime_text" \ No newline at end of file diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index bdfce77..7834dcf 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -56,7 +56,7 @@ -