Skip to main content

Useful NVM Commands

CHS
0 likes • Mar 20, 2023 • 0 views
Shell
Loading...

More Shell Posts

Symlink Desktop

0 likes • Nov 18, 2022 • 0 views
Shell
#
# Austin Leath
# checks for /Desktop symlink. Creates the symlink if it doesnt already exist
#
#Fetch the target user if desired, otherwise use the currently logged in user.
if [ "$4" != "" ]; then
TARGET_USER=$4
else
TARGET_USER=$3
fi
if [ "$5" != "" ]; then
DIRECTORY_NAME=$5
else
TARGET_USER="$3 Desktop"
fi
# Functions
CHECK_SYMLINK() {
if test -f "/Desktop"; then
echo "/Desktop exists"
else
echo "/Desktop does not exist"
fi
}
CHECK_SYNTHETIC_CONF() {
if test -f "/etc/synthetic.conf"; then
echo "/etc/synthetic.conf exists"
else
echo "/etc/synthetic.conf does not exist"
fi
}
CREATE_SYMLINK() {
if [[ $(CHECK_SYNTHETIC_CONF) != "/etc/synthetic.conf exists" ]]; then
echo "/etc/synthetic.conf does not exist. creating.."
touch /etc/synthetic.conf
chown -R root:wheel /etc/synthetic.conf
fi
if grep -q "$DIRECTORY_NAME" /etc/synthetic.conf; then
echo "$DIRECTORY_NAME already exists"
exit 1
else
echo "$DIRECTORY_NAME\t/Users/$TARGET_USER/Desktop" >> /etc/synthetic.conf
fi
echo "/Desktop symbolic link created"
}
if [[ $(CHECK_SYMLINK) != "/Desktop exists" ]]; then
CREATE_SYMLINK
fi
exit 0

abuseipdb config

0 likes • Nov 18, 2022 • 0 views
Shell
#for ssh abuse attempts
action = %(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"

upload_key.sh

0 likes • Jan 12, 2023 • 0 views
Shell
#!/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 computer
if [ -e ~/.ssh/id_rsa.pub ];
then
echo "SSH Key already exists on local machine"
else
echo "Generating SSH key on local machine"
ssh-keygen -t rsa #generates id_rsa and id_rsa.pub
chmod -R 700 ~/.ssh #Sets permissions of ssh folder
ssh-add #Adds keys (and passwords?) to ssh_agent. (hopefully doesn't require password)
fi
echo "Loading client public key into memory"
pubKey=$(<~/.ssh/id_rsa.pub)
for server
do
echo "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-add
ssh-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 portnumber
echo "Displaying server public key"
ssh $server "cat ~/.ssh/id_rsa.pub"
#Though, he did give me a good idea
echo "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_keys
done
echo "SSH keys schronized successfully!"

Nginx Serve Storybook

CHS
0 likes • Oct 17, 2023 • 10 views
Shell
# ---------------- FIREWALL STEPS ----------------
# Check if firewalld is installed and running
sudo systemctl status firewalld
# If it's not running, you can start and enable it
sudo systemctl start firewalld
sudo systemctl enable firewalld
# Add a rule to allow traffic on port 6006. Port 6006 is the default port that storybook runs on.
sudo firewall-cmd --permanent --add-port=6006/tcp
# Reload the firewall for the changes to take effect
sudo firewall-cmd --reload
# Check the list of allowed ports
sudo firewall-cmd --list-ports
# ---------------- NGINX STEPS ----------------
# Install Nginx (if not already installed)
sudo yum install nginx
# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
# Copy your storybook-static directory to a location that Nginx can serve from.
# The default web root directory for Nginx is /usr/share/nginx/html.
sudo cp -r /path/to/storybook-static /usr/share/nginx/html/
# Adjust file permissions if needed to ensure that Nginx can read the files
sudo chown -R nginx:nginx /usr/share/nginx/html/storybook-static
# Put the following server block in /etc/nginx/conf.d/storybook.conf
server {
listen 6006;
server_name your_domain.com;
location / {
root /usr/share/nginx/html/storybook-static;
index index.html;
}
}
# Test the Nginx configuration for syntax errors
sudo nginx -t
# If there are no errors, reload Nginx to apply the changes
sudo systemctl reload nginx

Outputs list of $PATH dirs sorted by line length

0 likes • Nov 18, 2022 • 0 views
Shell
echo -e ${PATH//:/\\n} | awk '{print length, $0}' | sort -n | cut -f2- -d' '

pinger.sh

0 likes • Mar 21, 2021 • 0 views
Shell
#pinger.sh by Leif Messinger
#./pinger.sh [ADDRESS] to search
#./pinger.sh [ADDRESS] & to search in the background
#https://serverfault.com/a/42382
ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded
until ping -c1 "$1" >/dev/null 2>&1; do :; done & # The "&" backgrounds it
trap "kill $!; ping_cancelled=true" SIGINT
wait $! # Wait for the loop to exit, one way or another
trap - SIGINT # Remove the trap, now we're done with it
if [ "$ping_cancelled" == true ] #https://stackoverflow.com/a/21210966/10141528
then
printf "The pinger for $1 just closed bro.\n"
else
printf "$1 IS UP BROOO\a\n"
fi