This commit is contained in:
nik
2025-10-15 17:41:27 -07:00
parent 1f6349fdae
commit 5dee92a92a
9 changed files with 16 additions and 0 deletions

1
scripts/README Normal file
View File

@ -0,0 +1 @@
this dir contains less often used or old/deprecated scripts

13
scripts/backup Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
echo "backup starting at $(date)"
echo "backing up music and tank to toshiba_mirror"
rsync -aP /wdraidz/media/music/ /toshiba-mirror/backups/media/music/ >> /var/log/rsync.log
echo "music up to date..."
rsync -aP /wdraidz/tank/ /toshiba-mirror/backups/tank/ >> /var/log/rsync.log
echo "tank up to date..."
echo "backing up wdraidz to seastripe"
rsync -aP /wdraidz/media/ /seastripe/backups/wdraidz/media/ >> /var/log/rsync.log
echo "media to seastripe done"
rsync -aP /wdraidz/tank/ /seastripe/backups/wdraidz/tank/ >> /var/log/rsync.log
echo "tank to seastripe done"
echo "done."

4
scripts/bgshuffle Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
while true; do
feh --no-fehbg --bg-fill ~/.images/$(ls ~/.images | shuf -n 1)
done

8
scripts/displayctl Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
DISPLAY_STATUS=$(xrandr | grep DP-4)
if [[ "$DISPLAY_STATUS" == *"1440x3440"* ]]; then
xrandr --output DP-4 --off
else
init_displays
fi

View File

@ -0,0 +1,10 @@
#!/bin/sh
LOW="xrandr --output eDP-1 --mode 2560x1600 --rate 60"
HIGH="xrandr --output eDP-1 --mode 2560x1600 --rate 165"
CHOICE=$(printf "165Hz\n60Hz" | dmenu -c -i -l 2 -p "choose refresh rate:")
case $CHOICE in
"165Hz")
$HIGH;;
"60Hz")
$LOW;;
esac

77
scripts/nmap Executable file
View File

@ -0,0 +1,77 @@
#!/bin/bash
# (c) CompuMatter, LLC, ServerMatter
# no warranty expressed or implied - use as is.
# purpose of this script:
# Can't use angryipscanner from a command line and haven't been able to find anything else that gives you what you're looking for?
# This nmap based bash script might just be what you're looking for.
if ! which nmap >/dev/null; then
echo "nmap is not installed - this script requires it"
echo "It can be installed with - apt install nmap"
return;
fi
# Check if the script is being run as root (EUID = 0)
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root user or with sudo"
return;
fi
lease_file_location="/var/lib/dhcp/dhcpd.leases"
# will return br0, eth0, eno1 or whatever the default Interface is
default_interface=$(ip route | awk '/default/ {print $5}')
ip_and_cidr=$(ip -o -f inet addr show $default_interface | awk '{print $4}')
ip_range=$(echo $ip_and_cidr | sed 's/\.[0-9]*\//.0\//')
echo -e "\nRunning nmap -sn $ip_range to get a list of all IP addresses\n"
readarray -t ips < <(nmap -sn $ip_range | awk '/Nmap scan report/{gsub(/[()]/,""); print $NF}' | sort -t . -n -k 1,1 -k 2,2 -k 3,3 -k 4,4)
# Set column widths
col1=14
col2=17
col3=17
col4=15
col5=30
echo -e "Checking each IP address for Hostname, MAC, Workgroup or Domain, Manufacturer info\n"
# Format the output
printf "%-${col1}s | %-${col2}s | %-${col3}s | %-${col4}s | %-${col5}s \n" "IP" "MAC" "HOSTNAME" "WG-DOMAIN" "MANUFACTURER"
printf "%-${col1}s | %-${col2}s | %-${col3}s | %-${col4}s | %-${col5}s \n" "$(printf '%.s-' {1..13})" "$(printf '%.s-' {1..17})" "$(printf '%.s-' {1..17})" "$(printf '%.s-' {1..15})" "$(printf '%.s-' {1..30})"
for IP in "${ips[@]}"
do
# Run the nmap command for the current IP
OUTPUT="$(nmap --script nbstat.nse -p 137,139 $IP)"
# Extract the necessary information
MAC=$(echo "$OUTPUT" | grep 'MAC Address' | awk '{print $3}')
HOSTNAME=$(echo "$OUTPUT" | grep '<20>.*<unique>.*<active>' | awk -F'[|<]' '{print $2}' | tr -d '_' | xargs)
WG_DOMAIN=$(echo "$OUTPUT" | grep -v '<permanent>' | grep '<00>.*<group>.*<active>' | awk -F'[|<]' '{print $2}' | tr -d '_' | xargs)
MANUFACTURER=$(echo "$OUTPUT" | grep 'MAC Address' | awk -F'(' '{print $2}' | cut -d ')' -f1)
# if a dhcp server leases file exists on this machine, we will query it for a hostname if not already returned by nmap
if [ -f "$lease_file_location" ]; then
# If HOSTNAME is empty, fetch from dhcpd.leases
if [ -z "$HOSTNAME" ]; then
HOSTNAME=$(awk -v ip="$IP" '$1 == "lease" && $2 == ip {f=1} f && /client-hostname/ {print substr($2, 2, length($2) - 3); exit}' "$lease_file_location" | cut -c 1-15)
# Append an asterisk (*) if HOSTNAME has a value
if [ -n "$HOSTNAME" ]; then
HOSTNAME="$HOSTNAME *"
fi
fi
fi
# Print a row of data for the current IP
printf "%-${col1}s | %-${col2}s | %-${col3}s | %-${col4}s | %-${col5}s \n" "$IP" "$MAC" "$HOSTNAME" "$WG_DOMAIN" "$MANUFACTURER"
done
if [ -f "$lease_file_location" ]; then
echo -e "\n* to the right of hostname indicates the hostname could not be acquired from nmap so was pulled from $lease_file_location\n"
fi
# we are grateful if you would leave our short tagline attached
echo -e "This network scanner script is provided free of charge by ServerMatter\n"
# Disclaimer: This script is provided as-is with no warranty and no responsibility.
# The author and contributors shall not be liable for any direct, indirect, incidental,
# special, exemplary, or consequential damages arising from the use of this script.

15
scripts/record Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
SCREEN="ffmpeg -s 3440x1440 -f x11grab -r 60 -i :0.0+0,0"
SYSTEM_AUDIO="-f pulse -i alsa_output.pci-0000_00_1f.3.iec958-stereo.monitor"
MICROPHONE="-f pulse -i default:monitor"
COMPRESSION="-c:a flac -c:v hevc_nvenc -b:v 12M"
FILENAME="$HOME/wdraidz/media/game-videos/$(date +%m-%d-%Y_%R:%S).mkv"
SIGSEND="kill -n 36 $(pidof dwmblocks)"
if [[ $1 == 1 ]]; then
$SCREEN $SYSTEM_AUDIO $MICROPHONE -filter_complex "[1:0][2:0]amerge=inputs=2[a]" -map 0:v -map "[a]" $COMPRESSION $FILENAME&
else
$SCREEN $SYSTEM_AUDIO $COMPRESSION $FILENAME&
fi
$SIGSEND

9
scripts/run Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
mkdir -p "output"
TRACK=1
for file in *.opus; do
NEW_FILENAME=$(echo $file | sed 's/ - Kirby Super Star OST//')
TITLE=$(echo $file | sed 's/ - Kirby Super Star OST.opus//')
ffmpeg -i "$file" -metadata artist="Nintendo" -metadata album="Kirby Super Star OST" -metadata title="$TITLE" -metadata track="$TRACK" -codec copy "output/$file"
((TRACK++))
done

7
scripts/sync_music Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
rsync -aP $HOME/wdraidz/media/music/ $HOME/music/ > $HOME/.sync_log && SUCCESS=1
if [[ $SUCCESS == 1 ]]; then
notify-send "sync complete; logged to $HOME/.sync_log" -i :
else
notify-send "sync error..." -i :
fi