• Apr 3, 2025 •LeifMessinger
0 likes • 4 views
#!/usr/bin/env bash #Splits a command across a number of CELL machines user=$(whoami) if [[ -z $user ]]; then echo "whoami failed. Exiting..." exit 1 fi command="$1" if [[ -z $command ]]; then echo "Need to put in a command." exit 1 fi shift array=("$@") let start=8 let stop=18 for ((i = $start; i <= $stop; i++)); do extraZero=$(if [[ "$i" -lt 10 ]]; then echo "0"; fi) domain="CELL${extraZero}${i}-CSE.ENG.UNT.EDU" let "index = i - start" echo ${#array[@]} if [[ ${#array[@]} != 0 ]] && [[ $index -ge ${#array[@]} ]]; then echo "$index > ${#array[@]}" break fi ssh -o StrictHostKeyChecking=accept-new "${user}@${domain}" -t "$command ${array[$index]}" & done
• Apr 21, 2021 •LeifMessinger
0 likes • 6 views
#diskRipper.sh by Leif Messinger #For use on debian, where your cds aren't immediately mounted wall "CD inserted boss" set -x #echo on cdDrivePath=$(ls -l /dev/cdrom | awk '{print $NF}') #CD could have no label, so that's why I need awk cdLabel=$(lsblk -n "/dev/$cdDrivePath" -o label) if [[ ! -z "$cdLabel" ]]; then #CD has label folderName=$cdLabel echo "The cd label is ${folderName}" if mkdir ./cds/"${folderName}"; then #Folder didn't exist before sudo mount /dev/cdrom ./.cdmountpoint sudo cp -r ./.cdmountpoint/* "./cds/${folderName}" sudo chmod -R 777 "./cds/${folderName}" sudo umount ./.cdmountpoint eject wall "CD done and ejecting" else wall "Already read that cd, skipped" fi else wall "CD had no label, skipped" fi
• Sep 23, 2024 •AustinLeath
CLIENT_VPN_ID="cvpn-endpoint-xxxxxxxxxxxx" for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do echo "Searching in region: $region" aws ec2 describe-client-vpn-endpoints --region $region --query "ClientVpnEndpoints[?ClientVpnEndpointId=='$CLIENT_VPN_ID']" --output table done
• May 20, 2024 •AustinLeath
0 likes • 13 views
#!/bin/sh BAT_LOW=15 BAT_CRITICAL=5 if [ "$1" = "--help" ] then printf " Usage: \tbattery_check.sh warning%% hibernate%% Description: \tA script for notifying the user via dunst and logging when \tthe battery is low and the system is going to hibernate. \tCan be supplied arguments for the battery low warning and \thibernation percentage thresholds as the first and second arguments. \t Default behavior is to warn at 15% and hibernate at 5%." exit fi if [[ -n "$1" && -n "$2" && $1 -gt $2 ]] then BAT_LOW=$1 BAT_CRITICAL=$2 fi acpi -b | awk -F'[,:%]' '{print $2, $3}' | { read -r status capacity echo Low threshold: $BAT_LOW, Hibernate threshold: $BAT_CRITICAL echo Status: $status, Capacity: $capacity if [ "$status" = Discharging -a "$capacity" -le $BAT_CRITICAL ]; then echo Battery critical threshold. dunstify -u critical "Critical battery threshold, hibernating..." logger "Critical battery threshold, hibernating..." sleep .5 systemctl hibernate exit fi if [ "$status" = Discharging -a "$capacity" -le $BAT_LOW ]; then echo Battery low threshold. dunstify -u critical 'Battery low! System will hibernate at 5%.' logger 'Battery low! System will hibernate at 5%.' sleep .5 light -S 15 exit fi }
• Oct 26, 2021 •LeifMessinger
0 likes • 3 views
#!/bin/bash #Leif Messinger lsm0147 #credit.sh FILES cred="Leif Messinger lsm0147" for bruh; do if [[ $bruh =~ \.cpp|\.c|\.java|\.js ]]; then comment="//$cred" else #Basically everything else gets a pound sign comment #Pound signs are standard across linux. bash, sed, gawk, python etc #Speaking of which, I need to escape it because of that. comment="\#$cred" fi if [ -s $bruh ]; then #If the file has a shebang if egrep -q '^#!/' $bruh; then sed -i "/^\#!\//a$comment" $bruh else sed -i "1i$comment" $bruh fi else echo "$comment" > $bruh fi done
• Aug 16, 2023 •C S
# Run "test" script on all packages npm run test --workspaces # Tip - this also works: npm run test -ws ---------------------------------------------------- # Runs "test" only on package-a npm run test --workspace package-a # Tip - this also works: npm run test -w package-a ---------------------------------------------------- # Install `lodash` on `package-a` npm install lodash --workspace package-a # Install `tap` on `package-b` as a dev dependency npm install tap --workspace package-b --save-dev # Install `package-a` on `package-b` npm install package-a --workspace package-b # Install `eslint` in all packages npm install eslint --workspaces