Loading...
More Shell Posts
#!/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!"
#!/bin/bash#makefileMaker.sh by Leif Messinger#Needs getDependencies.shCC="gcc"#I have no idea why it's called CXX when it's a c++ compiler#I know that cpp is c pre processor, but still, why X?CXX="g++"CXXFLAGS="-std=c++17 -O2"#CFLAGS="-std=c17"LIBRARIES="$@"#Vulkan Flags for me#LIBRARIES="-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi"function compileAllFiles(){#output: bruh.o yeet.o# CXX $CXXFLAGS bruh.o yeet.o -o output $LIBRARIESecho -n "output:"if compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n " ${f%.cpp}.o"donefiif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n " ${f%.c}.o"donefiecho ""if compgen -G "*.cpp" &> /dev/null; thenecho -e -n "\t$CXX $CXXFLAGS "elseecho -e -n "\t$CC $CFLAGS "fiif compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n " ${f%.cpp}.o"donefiif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n " ${f%.c}.o"donefiecho " -o output $LIBRARIES"echo ""}function compileAllObjectFiles(){#bruh.o: bruh.cpp yeet.h# CXX $CXXFLAGS -c bruh.cpp $LIBRARIESif compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n "${f%.cpp}.o: $f"getDependencies.sh < $fecho ""echo -e "\t$CXX $CXXFLAGS -c $f"echo ""donefi#yeet.o: yeet.c# CC $CFLAGS -c yeet.c $LIBRARIESif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n "${f%.c}.o: $f"getDependencies.sh < $fecho ""echo -e "\t$CC $CFLAGS -c $f"echo ""donefi}compileAllFilescompileAllObjectFiles#does not work on windowsecho "clean:"echo -e "\trm -f -v *.o output"echo ""echo "run:"echo -e "\t./output"echo ""echo "debug:"if compgen -G "*.cpp" &> /dev/null; thenecho -e -n "\t$CXX $CXXFLAGS -g "elseecho -e -n "\t$CC $CFLAGS -g "fiif compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n " ${f}"donefiif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n " ${f}"donefiecho " $LIBRARIES -o output"echo ""
for region in `aws ec2 describe-regions --output text | cut -f4`doecho -e "\nListing Instances in region:'$region'..."aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,Subnet:SubnetId}' --region $regiondone#This script is to be used with any AWS CLI configured environment, it will list any EC2 instances and their associated subnet network ID's in JSON format
#!/bin/bash#Installs the Vulkan library and other goodies. Works on Arch and Arch based distros. Needs pacman and makepkginstallVulkan(){#Tries installing every linux package in existencepackages=( vulkan-tools libvulkan-dev vulkan-loader-devel vulkan-validation-layers spirv-tools mesa-vulkan-devel vulkan-validation-layers-devel )for package in ${packages[*]}; dosudo pacman --noconfirm -S $packagedone}installLibraries(){#All of these packages don't exist, so we have to download and install the AUR packages#packages=( libglfw3-dev glfw-devel libglm glm-devel )#for package in ${packages[*]}; do# sudo pacman --noconfirm -S $package#donesudo git clone https://aur.archlinux.org/glfw-git.git /tmp/glfw-gitsudo chmod 777 /tmp/glfw-gitcd /tmp/glfw-gitmakepkg -sisudo git clone https://aur.archlinux.org/glm-git.git /tmp/glm-gitsudo chmod 777 /tmp/glm-gitcd /tmp/glm-gitmakepkg -si}installShaderCompiler(){#Basically installs glslcsudo pacman -S shaderc}while true; doselect bruh in installVulkan installLibraries installShaderCompiler "exit"; do$bruhdonedone
#!/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
#!/bin/bash#Changes the remote url from https to ssh.#Only works for github, because I'd have to store a dictionary of every https to ssh url otherwise.#Made using Bing Chat# Get the remote URL from the consoleREPO_URL=$(git config --get remote.origin.url)# Check that REPO_URL contains https://github.comif [[ $REPO_URL == *"https://github.com"* ]]; then# Replace https with ssh in the URL# Change the remote URL to the SSH versiongit remote set-url origin "$REPO_URL"elseecho "Error: REPO_URL does not contain https://github.com" >&2exit 1fi