Skip to content

Instantly share code, notes, and snippets.

Avatar

pacmac

  • Singapore
View GitHub Profile
View ufw-dns
#!/bin/bash
## bash <(curl -Ls https://gist.github.com/pacmac/41651c4f19c4760ebb20b5de0ee0476f/raw/)
## curl -o ufw-dns -L https://gist.github.com/pacmac/41651c4f19c4760ebb20b5de0ee0476f/raw/
## */5 * * * * bash <(curl -s https://gist.github.com/pacmac/41651c4f19c4760ebb20b5de0ee0476f/raw/)
HOSTNAME="$1";
if [ $# -eq 0 ]; then
echo "Hostname is required";
exit 0;
@pacmac
pacmac / ping.sh
Created Apr 24, 2020
Ping a Host & Save Status to Log File
View ping.sh
#!/bin/bash
STAMP=`date "+%y%m%d-%H:%M:%S"`
FILE="/var/log/ping.log"
ISUP="DOWN"
_update () {
if [ ! -f "$FILE" ]; then
echo "$STAMP $ISUP" > $FILE
fi
@pacmac
pacmac / broadcom.sh
Created Apr 24, 2020
Broadcom USB Fix
View broadcom.sh
wget https://s3.amazonaws.com/plugable/bin/fw-0a5c_21e8.hcd;
mv fw-0a5c_21e8.hcd /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd;
cp /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd /lib/firmware/brcm/BCM20702A1-0a5c-21e8.hcd;
@pacmac
pacmac / online.sh
Last active Apr 22, 2020
Asterisk Check Offline Extensions
View online.sh
OFFS="";
NOW=$(date +%H:%M)
SENDER="voip@email.com"
RECIP="user@email.com"
## MORNING
MORN_S="09:30"
MORN_E="12:30"
@pacmac
pacmac / fastest-ping.sh
Last active Mar 22, 2020
get fastest host ping and only output if a host is faster than the one provided in $1
View fastest-ping.sh
#!/bin/bash
# pacmac - 2020-03-22
# fast-ping list-of-hosts | current-host
# fast-ping "uk-berkshire-2-ca-version-2.expressnetw.com,uk-east-london-ca-version-2.expressnetw.com" "uk-east-london-ca-version-2.expressnetw.com"
# fast-ping "uk-berkshire-2-ca-version-2.expressnetw.com,uk-east-london-ca-version-2.expressnetw.com"
## Initial Defaults
Smallest=1000000
Server=""
@pacmac
pacmac / ovpn_client_upscript.sh
Created Feb 25, 2020
Asus Padadavan - Run the Script After Connected/Disconnected to VPN Server:
View ovpn_client_upscript.sh
#!/bin/sh
### Custom user script
### Called after internal VPN client connected/disconnected to remote VPN server
### $1 - action (up/down)
### $IFNAME - tunnel interface name (e.g. ppp5 or tun0)
### $IPLOCAL - tunnel local IP address
### $IPREMOTE - tunnel remote IP address
### $DNS1 - peer DNS1
### $DNS2 - peer DNS2
@pacmac
pacmac / pm2-root.service
Created Feb 19, 2020
PM2 Startup Script for systemctl
View pm2-root.service
# /etc/systemd/system/pm2-root.service
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=root
@pacmac
pacmac / linode-dns.sh
Last active Dec 19, 2019
linode update dns with APIV4
View linode-dns.sh
#!/bin/sh
TOKEN=""
DOMAIN_ID=""
RECORD_ID=""
WAN_IP=`curl -s ipecho.net/plain`;
OLD_WAN_IP=`cat /tmp/CURRENT_WAN_IP.txt`
func_go () {
curl -H "Content-Type: application/json" \
View ufwdyndns.sh
#!/bin/sh
HOSTNAME="my.domain.com"
LOGFILE=$HOME/ufw.log
Current_IP=$(host $HOSTNAME | head -n1 | cut -f4 -d ' ')
if [ ! -f $LOGFILE ]; then
/usr/sbin/ufw insert 1 allow from $Current_IP to any port 22 proto tcp
echo $Current_IP > $LOGFILE
else
View namecheapdns.sh
#!/bin/sh
LINODE_API_KEY="12345"
DOMAIN_ID="12345"
SUB_NAME="my.sub.domain.com"
WAN_IP=`curl -s ipecho.net/plain`;
OLD_WAN_IP=`cat /tmp/CURRENT_WAN_IP.txt`
if [ "$WAN_IP" = "$OLD_WAN_IP" ]; then
echo "IP Unchanged"
You can’t perform that action at this time.