Skip to main content

pinger.sh

0 likes • Mar 21, 2021 • 0 views
Shell
Loading...

More Shell Posts

githubSetSSH.sh

0 likes • Sep 9, 2023 • 2 views
Shell
#!/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 console
REPO_URL=$(git config --get remote.origin.url)
# Check that REPO_URL contains https://github.com
if [[ $REPO_URL == *"https://github.com"* ]]; then
# Replace https with ssh in the URL
REPO_URL=${REPO_URL/https:\/\/github.com\//[email protected]:}
# Change the remote URL to the SSH version
git remote set-url origin "$REPO_URL"
else
echo "Error: REPO_URL does not contain https://github.com" >&2
exit 1
fi

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

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

credit.sh

0 likes • Oct 26, 2021 • 0 views
Shell
#!/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

cppToStdout.sh

0 likes • Nov 17, 2021 • 1 view
Shell
#!/bin/bash
#Takes command line arguments and pulls the header files.
#Good for checking if the function you want is in the header or not.
#cppToStdout.sh "time.h"
while [ "$1" != "" ]; do
echo "#include<$1>" | g++ -x c++ -E -
shift
done

getDependencies.sh

0 likes • Oct 30, 2020 • 2 views
Shell
#!/bin/bash
#getDependencies.sh by Leif Messinger
grep -Po '#include\s*"\K.+(?=")' | while read -r line ; do
echo -n " $line"
./getDependencies.sh < $line
done