Loading...
More Shell Posts
#!/bin/bashgit statusecho "Do you want to add all changed files?"select yn in "Yes" "No"; docase $yn inYes ) break;;No ) exit 1;;esacdonegit add -ugit statusecho "Does this look right?"select yn in "Yes" "No"; docase $yn inYes ) break;;No ) exit 2;;esacdonegit commitecho "Do you want to push?"select yn in "Yes" "No"; docase $yn inYes ) break;;No ) exit 2;;esacdonegit push
#!/bin/shBAT_LOW=15BAT_CRITICAL=5if [ "$1" = "--help" ]thenprintf "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%."exitfiif [[ -n "$1" && -n "$2" && $1 -gt $2 ]]thenBAT_LOW=$1BAT_CRITICAL=$2fiacpi -b | awk -F'[,:%]' '{print $2, $3}' | {read -r status capacityecho Low threshold: $BAT_LOW, Hibernate threshold: $BAT_CRITICALecho Status: $status, Capacity: $capacityif [ "$status" = Discharging -a "$capacity" -le $BAT_CRITICAL ]; thenecho Battery critical threshold.dunstify -u critical "Critical battery threshold, hibernating..."logger "Critical battery threshold, hibernating..."sleep .5systemctl hibernateexitfiif [ "$status" = Discharging -a "$capacity" -le $BAT_LOW ]; thenecho Battery low threshold.dunstify -u critical 'Battery low! System will hibernate at 5%.'logger 'Battery low! System will hibernate at 5%.'sleep .5light -S 15exitfi}
#!/bin/bash# Recursively find all .svelte files in the current directory and its subdirectoriesfind . -type f -name "*.svelte" -o -name "*.html" -o -name "*.htm" | while read file; do# Replace all h1 tags with the specified formatsed -i 's/<h1>\(.*\)<\/h1>/<h1 id="\1">\1<\/h1>/g' "$file"# Replace all h2 tags with the specified formatsed -i 's/<h2>\(.*\)<\/h2>/<h2 id="\1">\1<\/h2>/g' "$file"# Remove whitespace from the id attribute valuefor i in {0..10} ; dosed -i 's/\(id="[^"]*\)\W\([^"]*"\)/\1\2/g' "$file"donedone
#Leif Messinger#For when you want to search a lot of words in a file fast#Arg 1 is the argument the list of words you want to search#Arg 2 is the file you want to search#-z means that it looks at the file as a whole, just treating newlines a characters.#-r is regex. Needed for $, even tho the documentation says you don't need it. They are liars.#First command replaces all . with \. and all - with \-#Second command takes all newlines and replaces them with )|(#Third command takes the trailing |( and deletes it#Forth command puts a /( at the start#Fith command puts /!d at the end. This tells it to not delete any lines that match the pattern.#The second sed takes the output of the first sed as a command that searches any of the combined words#-f - takes a command from the inputsed -z -r -e 's/\./\\\./g ; s/\-/\\\-/g' -e 's/\n/\)\|\(/g' -e 's/\|\($//' -e 'i/\(' -e 'a/!d' $1 | sed -r -f - $2
#!/bin/bash#Originally made by Isaac Cook https://gist.github.com/icook/5400173#Modified by Leif Messinger#upload_key.sh [server_ip [server2_ip [...]]]#To be run locally on a linux computerif [ -e ~/.ssh/id_rsa.pub ];thenecho "SSH Key already exists on local machine"elseecho "Generating SSH key on local machine"ssh-keygen -t rsa #generates id_rsa and id_rsa.pubchmod -R 700 ~/.ssh #Sets permissions of ssh folderssh-add #Adds keys (and passwords?) to ssh_agent. (hopefully doesn't require password)fiecho "Loading client public key into memory"pubKey=$(<~/.ssh/id_rsa.pub)for serverdoecho "Adding client public key to $server remote server authorized keys"#Idiot Isaac Cook didn't know about ssh-copy-id#ssh-copy-id even checks if your key already exists#In fairness, I didn't either until researching ssh-addssh-copy-id -i ~/.ssh/id_rsa.pub $server #In theory, this should prompt for a username#ssh $server "mkdir -p ~/.ssh; #Make the folder if not already made# echo \"$pubKey\" >> ~/.ssh/authorized_keys; #Append your public key to the server's authorized_keys# chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys" #Set the correct permissions of those files#echo "Adding server public key to local authorized keys"#ssh $server "ssh-copy-id -i ~/.ssh/id_rsa.pub \$SSH_CLIENT" #this might need some awk, as $SSH_CLIENT spits out clientip portnumberecho "Displaying server public key"ssh $server "cat ~/.ssh/id_rsa.pub"#Though, he did give me a good ideaecho "Displaying keys authorized on $server (you can paste them in your authorized_keys file)"ssh $server "cat ~/.ssh/authorized_keys"#echo "Appending keys authorized on $server to your local authorized_keys"#ssh $server "cat ~/.ssh/authorized_keys" >> ~/.ssh/authorized_keysdoneecho "SSH keys schronized successfully!"
#for ssh abuse attemptsaction = %(action_)s%(action_abuseipdb)s[abuseipdb_apikey="", abuseipdb_category="18,22"]actionban = curl --fail --ciphers ecdhe_ecdsa_aes_256_sha --data 'key=<abuseipdb_apikey>' --data-urlencode 'comment=<matches>' --data 'ip=<ip>' --data 'category=<abuseipdb_category>' "https://www.abuseipdb.com/report/json"