Skip to content

Instantly share code, notes, and snippets.

View rodneyshupe's full-sized avatar

Rodney Shupe rodneyshupe

View GitHub Profile
@rodneyshupe
rodneyshupe / backup.sh
Created January 20, 2023 18:41
Openwrt backup script
#!/usr/bin/env sh
SD_MOUNT="$(echo "$(mount | grep '/dev/mmcblk.* on /mnt/mmcblk' | sed -e 's/\/dev\/mmcblk.* on \(\/mnt\/mmcblk.*\) type.*/\1/')")"
if [ -z $SD_MOUNT ]; then
echo "SD Card missing. Saving to /tmp"
BACKUP_PATH="/tmp"
else
BACKUP_PATH="${SD_MOUNT}/backup"
fi
@rodneyshupe
rodneyshupe / tunnel.sh
Last active January 18, 2023 23:45
Example of opening a ssh tunnel for a web app
#!/usr/bin/env bash
# Provides an example of how to setup a ssh tunnel on WSL
LOCAL_PORT=8080
REMOTE_HOST='localhost' # remote server may be the server being connected to (remote localhost) OR it could be a different server
REMOTE_PORT=8080
SSH_ADDRESS='appserver' # this can be user@hostip or an alias configured in ssh config file.
if [ "$1" == "-k" ]; then
@rodneyshupe
rodneyshupe / surface_setup.ps1
Created October 10, 2022 05:59
Install some apps on new Surface
# Microsoft Surface Install
# Unattended Install of Firefox
$SourceURL = "https://download.mozilla.org/?product=firefox-msi-latest-ssl&os=win64&lang=en-US";
$Installer = $env:TEMP + "\firefox.exe";
Invoke-WebRequest $SourceURL -OutFile $Installer;
Start-Process -FilePath $Installer -Args "/s" -Verb RunAs -Wait;
Remove-Item $Installer;
@rodneyshupe
rodneyshupe / wireguard.sh
Last active September 27, 2022 06:09
Connect / Disconnect from Wireguard Client on GL MT1300 travel router.
#!/usr/bin/env sh
function usage() {
cat << EOF
Usage: $0 [options...]
This script allows for easy access to connect or disconnect the wireguard vpn client.
Options:
-h show the help and exit
-u wireguard Up
@rodneyshupe
rodneyshupe / sync.sh
Last active January 20, 2023 22:49
Script to sync with Kodi server to GL MT1300 Travel router's SD card. Will pull recently downloaded TV Shows and Movies over Wireguard VPN.
#!/usr/bin/env sh
SYNC2WATCH="sync2watch.sh"
function echoerr() {
echo "$@" 1>&2
}
function parse_args() {
while getopts ":hdgoa:u" OPT; do
@rodneyshupe
rodneyshupe / prompt.sh
Created September 27, 2022 01:13
Linux Prompt Variable
PS1='$(if [[ $? == 0 ]]; then echo "\[\e[30;46m\] \@ \[\e[m\] \[\e[32m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]:\[\e[0;33m\][\w]\[\e[m\]\$ "; else echo "\[\e[30;46m\] \@ \[\e[m\] \[\e[32m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]:\[\e[0;33m\][\w]\[\e[m\]\[\e[41m\]($?)\[\e[m\]$ "; fi)'
@rodneyshupe
rodneyshupe / node-exporter.service
Created March 24, 2022 07:03
Service definition for node_exporter
[Unit]
Description=Node Exporter
[Service]
# Provide a text file location for https://github.com/fahlke/raspberrypi_exporter data with the
# --collector.textfile.directory parameter.
ExecStart=/usr/local/bin/node_exporter --collector.textfile.directory /var/lib/node_exporter/textfile_collector
[Install]
WantedBy=multi-user.target
@rodneyshupe
rodneyshupe / node-exporter.conf
Created March 24, 2022 07:00
upstart service configuration file for node_exporter
# node-exporter: Prometheus Node Exporter - to make metrics available
#
# Homepage: https://prometheus.io
#
description "node-exporter: Prometheus Node Exporter - to make metrics available"
start on (local-filesystems and net-device-up IFACE!=lo)
respawn
#!/bin/bash
# Install Script to setup Raspberry Pi
# Runs updates, fixes the Locale
# Changes keyboard to US Layout
# Sets Timezone
LOCALE="en_US.UTF-8"
TMZ="America/Vancouver"
@rodneyshupe
rodneyshupe / BBB_StepperMoterServer.js
Last active November 4, 2019 07:09
Simple Node.js server that receives a message and triggers a step motor on a Beagle Bone Black
#!/usr/bin/env node
var b = require('bonescript');
// reference the http module so we can create a webserver
var http = require("http");
var url = require("url");
var PORT = 8123;
var IP = "184.71.190.50";
var controller = ["P9_11", "P9_13", "P9_15", "P9_12"];