Added a few more scripts and updated tmux-idle.

master
parent 9a34944e30
commit 748bcc2301

@ -15,9 +15,15 @@ This script will convert your HEIC files (a format Apple saves photos with) to J
**cleanupBeatSaberSongs.sh** **cleanupBeatSaberSongs.sh**
I wrote this script because I was tired of using the excuse that the folder names are jibberish (98e299036de1688c3f60cda87728ee3c2969188<wbr>8 for example) to not clean up my custom song library. This script goes through all the folders that are 40 characters long (didn't check for only hexadecimal characters so be warned ye ol 40 character song titles), extracts information from their info.dat files (in 2 ways funny enough), and renames the folders to the actual song names with the artist and mapper separated by hyphens. This way if you happen to have a song mapped by different people they don't get overwritten. I wrote this script because I was tired of using the excuse that the folder names are jibberish (98e299036de1688c3f60cda87728ee3c2969188<wbr>8 for example) to not clean up my custom song library. This script goes through all the folders that are 40 characters long (didn't check for only hexadecimal characters so be warned ye ol 40 character song titles), extracts information from their info.dat files (in 2 ways funny enough), and renames the folders to the actual song names with the artist and mapper separated by hyphens. This way if you happen to have a song mapped by different people they don't get overwritten.
**loading**
This was just something I was playing around with while trying to decide if I should add a new icon for services in tmux-idle that are reloading.
**model** **model**
This simple script shows the hardware model of a raspberry pi. That is all. This simple script shows the hardware model of a raspberry pi. That is all.
**spacecheck**
This was a script that I wrote to test adding a disk space check to the tmux-idle script but then grew a little bit after to have a few bonus features.
**statusPageCheck.sh** **statusPageCheck.sh**
This script is a quick little something to poll my tinystatus page, and if a service is reporting as down, perform an action (such as rebooting the host or restarting the service). This script is a quick little something to poll my tinystatus page, and if a service is reporting as down, perform an action (such as rebooting the host or restarting the service).
@ -25,7 +31,10 @@ This script is a quick little something to poll my tinystatus page, and if a ser
This isn't so much a script as some small quality of life improvements I've made to my WSL Ubuntu 20.04 systems and Ubuntu 20.04 server. Add whichever you like to the end of your .profile and use 'source ~/.profile' to load it immediately. This isn't so much a script as some small quality of life improvements I've made to my WSL Ubuntu 20.04 systems and Ubuntu 20.04 server. Add whichever you like to the end of your .profile and use 'source ~/.profile' to load it immediately.
**tmux-idle** **tmux-idle**
This script just chills in one of my idle tmux windows and shows me the weather. Also added functionality to allow a quick glance at any services that I want to monitor. (All user-configurable options at the top of the file) This script just chills in one of my idle tmux windows and shows me the weather. Also added functionality to allow a quick glance at any services that I want to monitor, the usage of my disk, and whether or not the server is pending a reboot. (All user-configurable options at the top of the file)
**vpsping**
I'm looking into getting a vps with hetzner so I wanted an easy way to compare latencies between their data centers.
### AutoHotKey ### AutoHotKey

@ -0,0 +1,26 @@
#!/bin/bash
# Just having fun with unicode characters
#symbols=("\U25DC" "\U25DD" "\U25DE" "\U25DF") # Circle outlines
symbols=("\U25CB" "\U25D4" "\U25D1" "\U25D5" "\U25CF") # Pie chart
trap ctrl_c INT
function ctrl_c {
tput cub1
tput cnorm
echo
exit
}
tput civis
index=0
while true; do
echo -en ${symbols[$index]}
let index=$index+1
[ $index -eq ${#symbols[@]} ] && index=0
sleep .25
tput cub1
done

@ -0,0 +1,20 @@
#!/bin/bash
[ -z $1 ] && index=0 || index=$1
disks=('/dev/sda1' '/dev/sda15')
[ ${#index} -gt 1 ] && disks=("$index") && index=0
_df=`df -h | tr -s [:blank:] | egrep "^${disks[${index}]} "`
disk=`echo $_df | cut -d' ' -f1` # /dev/sda1
size=`echo $_df | cut -d' ' -f2` # 20G
used=`echo $_df | cut -d' ' -f3` # 16G
left=`echo $_df | cut -d' ' -f4` # 6.1G
perc=`echo $_df | cut -d' ' -f5` # 69%
mntp=`echo $_df | cut -d' ' -f6` # /
rper=`echo $perc | tr -d "%"` # 69
echo "Disk: $disk"
echo "Space: $used/$size"

@ -3,8 +3,11 @@
# Enter your zipcode here for local weather. # Enter your zipcode here for local weather.
zipcode=20001 zipcode=20001
# Add the services you want to monitor here as an array # Add the services you want to monitor here as an array
# e.g. ('apache2' 'gitea' 'postfix')
servicelist=('apache2' 'gitea' 'postfix') servicelist=('apache2' 'gitea' 'postfix')
# Disks to check (pls only do one for now)
disks=('/dev/sda1')
# Colors are nice # Colors are nice
blk=$(tput setaf 0) blk=$(tput setaf 0)
red=$(tput setaf 1) red=$(tput setaf 1)
@ -56,6 +59,67 @@ function dothething() {
tput cup 0 0 tput cup 0 0
} }
# Check to see if we need to reboot the server
function rebootcheck() {
cols=$(tput cols)
reboottext_notneeded=" No reboot required"
reboottext_needed="A reboot is required"
if [ -f /var/run/reboot-required ]; then
# Reboot required
let over="$cols-${#reboottext_needed}"
tput cup 0 $over
echo -en "${rst}${bld}${red}${reboottext_needed}${rst}"
else
# No reboot needed
let over="$cols-${#reboottext_notneeded}-1"
tput cup 0 $over
echo -en "${rst}${grn}${reboottext_notneeded}${rst}"
fi
}
# Disk space check
function checkdisks() {
_df=`df -h | tr -s [:blank:] | egrep "^${disks[0]} "`
disk=`echo $_df | cut -d' ' -f1` # /dev/sda1
size=`echo $_df | cut -d' ' -f2` # 20G
used=`echo $_df | cut -d' ' -f3` # 16G
left=`echo $_df | cut -d' ' -f4` # 6.1G
perc=`echo $_df | cut -d' ' -f5` # 69%
mntp=`echo $_df | cut -d' ' -f6` # /
rper=`echo $perc | tr -d "%"` # 69
capvalues=(85 90 95)
capcolors=("${ylw}" "${bld}${red}" "${red}")
capcolor=""
if [ $rper -lt ${capvalues[0]} ]; then
capcolor="${wht}"
elif [ $rper -ge ${capvalues[0]} ] && [ $rper -lt ${capvalues[1]} ]; then
capcolor="${capcolors[0]}"
elif [ $rper -ge ${capvalues[1]} ] && [ $rper -lt ${capvalues[2]} ]; then
capcolor="${capcolors[1]}"
elif [ $rper -ge ${capvalues[2]} ]; then
capcolor="${capcolors[2]}"
fi
title="Disk usage"
usage="${used}/${size}"
cols=$(tput cols)
let overt="$cols-${#title}-1"
let overd="$cols-${#disk}-1"
let overu="$cols-${#usage}-1"
tput cup 2 $overt
echo -en "${rst}${title}${rst}"
tput cup 3 $overd
echo -en "${rst}${disk}${rst}"
tput cup 4 $overu
echo -en "${rst}${capcolor}${usage}${rst}"
}
# This be where we check the services # This be where we check the services
function servicecheck(){ function servicecheck(){
# If we're not monitoring any services, return # If we're not monitoring any services, return
@ -77,13 +141,22 @@ function servicecheck(){
# Put our cursor where we can print # Put our cursor where we can print
tput cup $echorow $echocol tput cup $echorow $echocol
# Clear the variables we use # Clear the variables we use
unset echocol echorow #unset echocol echorow
# Do the actual service check. is-active returns # Do the actual service check. is-active returns
# active or inactive. Easy peasy # active or inactive. Easy peasy
servicestatus=`systemctl is-active ${servicelist[${index}]}` servicestatus=`systemctl is-active ${servicelist[${index}]}`
# Print out the status, green with a dot (\U25CF) if it's online # Print out the status, green with a dot (\U25CF) if it's online,
# and red with a square (\U25A0) if it's stopped # a red with a square (\U25A0) if it's stopped, or a yellow
[ "${servicestatus}" == "active" ] && echo -en "${grn}\U25CF ${servicelist[${index}]}${rst}" || echo -en "${red}\U25A0 ${servicelist[${index}]}${rst}" # triangle (\U25BA) if it's starting.
case "${servicestatus}" in
active) echo -en "${grn}\U25CF ${servicelist[${index}]}${rst}";;
activating) echo -en "${ylw}\U25BA ${servicelist[${index}]}${rst}";;
inactive) echo -en "${red}\U25A0 ${servicelist[${index}]}${rst}";;
failed) echo -en "${red}\U25A0 ${servicelist[${index}]}${rst}";;
esac
#[ "${servicestatus}" == "active" ] && echo -en "${grn}\U25CF ${servicelist[${index}]}${rst}" || [ "${servicestatus}" == "activating" ] && echo -en "${ylw}\U25BA ${servicelist[${index}]}${rst}" || echo -en "${red}\U25A0 ${servicelist[${index}]}${rst}"
done done
tput cup 0 0 tput cup 0 0
} }
@ -95,6 +168,10 @@ clear
tput civis tput civis
# Programmers are great at naming things # Programmers are great at naming things
dothething dothething
# Check if a reboot is needed
rebootcheck
# Check the disk capacities
checkdisks
# Loop forever. Use ctrl+c to exit. # Loop forever. Use ctrl+c to exit.
while true; do while true; do
# We want to make sure we only check once per hour # We want to make sure we only check once per hour
@ -106,6 +183,9 @@ while true; do
# the command every second of the 0th minute. # the command every second of the 0th minute.
if [ `date +%S` -eq "00" ]; then if [ `date +%S` -eq "00" ]; then
dothething dothething
# Also doing these once per hour because more seems overkill
rebootcheck
checkdisks
fi fi
fi fi
# I don't think checking every second is a problem... yet... # I don't think checking every second is a problem... yet...

@ -0,0 +1,15 @@
#!/bin/bash
servers=('nbg.icmp.hetzner.com' 'fsn.icmp.hetzner.com' 'hel.icmp.hetzner.com' 'ash.icmp.hetzner.com' 'dismyserver.net')
names=('Nuremberg' 'Falkenstein' 'Helsinki' 'Ashburn, VA' 'OVH Canada')
regex="time=[0-9 \.]+ms"
for index in $(seq 0 $((${#servers[@]}-1))); do
domain=${servers[$index]}
name=${names[$index]}
pingdata=`ping -c1 ${domain}`
delay=`echo -e $pingdata | egrep -o "${regex}"`
[ ${#domain} -lt 20 ] && tabs="\t\t" || tabs="\t"
echo -e "${name}\t${domain}${tabs}${delay}"
done
Loading…
Cancel
Save