Skip to content

Instantly share code, notes, and snippets.

View joshespi's full-sized avatar

Josh Espinoza joshespi

View GitHub Profile
@joshespi
joshespi / check_turnoffTV.sh
Last active December 11, 2023 21:29
Checks power status of device 0 then turns it off if the device is on
#!/bin/bash
# Get the current hour in local time
current_hour_local=$(date +%H)
# Check if the current time is before 7 AM or after 5 PM
if [ "$current_hour_local" -lt 7 ] || [ "$current_hour_local" -ge 17 ]; then
# Run cec-client and capture the power status of the TV
power_status=$(echo 'pow 0' | cec-client -s -d 1 | grep 'power status' | awk '{print $3}')
@joshespi
joshespi / bottom-modal.html
Created June 12, 2023 16:22
simple bottom modal for a survey
<?php //=============================Survey Modal=======================
if(is_null($_COOKIE['pcsd-chocochip'])){ ?>
<div id="modalcontrols">
<h2>Bottom Modal</h2>
<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>
<!-- The Modal -->
<div id="myModal" class="modal">
#!/bin/bash
# Creates backup folder if it doesn't exist
mkdir -p /home/pi/backup;
# Moves files to home backup folder
rsync -av --delete /etc/snmp/ /home/pi/backup/snmp
rsync -av --delete /usr/local/bin/ /home/pi/backup/usrlocalbin
rsync -av --delete /etc/rc.local /home/pi/backup/rc.local
rsync -av --delete /boot/config.txt /home/pi/backup/config.txt
@joshespi
joshespi / update-server-sh
Created May 24, 2023 19:32
simple script that will invoke our update script on remote servers. then ping for you to monitor the reboot
#!/bin/sh
#
# Define the IP address variable
IP_ADDRESS="158.91.1.124"
# Runs apt upgrade, dist-upgrade, autoclean, autoremove, and reboots the VM
ssh webadmin@$IP_ADDRESS -t 'sudo /home/webadmin/update.sh'
# Ping the IP address
ping $IP_ADDRESS
@joshespi
joshespi / ubuntu22_ipv6_disable.sh
Last active May 23, 2023 19:32
script to disable IPV6 on ubuntu22 LT
#!/bin/bash
# Append IPv6 disable configuration to /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1" | sudo tee -a /etc/sysctl.conf > /dev/null
# Apply the changes
sudo sysctl -p
@joshespi
joshespi / docker-laravel.sh
Last active April 30, 2023 06:01
docker composer to create a new laravel app
docker run --rm -v C:\Users\Joshe\OneDrive\Documents\docker\laravel:/app composer create-project --prefer-dist laravel/laravel myapp
@joshespi
joshespi / backup.sh
Last active August 11, 2023 16:23
pcsd - pi device, ship backup folder to backup server.
#!/bin/bash
hs=$HOSTNAME
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=10
i=0
# Set the initial return value to failure
@joshespi
joshespi / index.php
Last active May 28, 2023 15:57
basic wordpress loop
<?php
// Start “The Loop”
if ( have_posts() ) : // Does our website have any posts to display?
while ( have_posts() ) : the_post(); // If the answer is “yes”, let’s run some code.
the_title( '<h2>', '</h2>' ); // Let’s display the title of our post.
the_content(); // Let’s display the content of our post.
@joshespi
joshespi / chromefunction.sh
Created November 30, 2021 22:20
detect if chrome is running
#!/bin/bash
SERVICE="chromium"
if pgrep "$SERVICE" > /dev/null
then
echo "$SERVICE is running"
#for SNMP
echo "0"
else
echo "$SERVICE stopped"
#for SNMP
@joshespi
joshespi / update.sh
Last active August 28, 2022 03:56
APT update everything, cleanup, reboot
#!/bin/bash
sudo apt update --fix-missing -y && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y && sudo shutdown -r now