Skip to content

Instantly share code, notes, and snippets.

@pacmac
pacmac / brcmfmac4356-pcie.txt
Last active January 20, 2022 06:00
Ubuntu Broadcom 4356 Fix (/lib/firmware/brcm/brcmfmac4356-pcie.txt)
# Sample variables file for BCM94356Z NGFF 22x30mm iPA, iLNA board with PCIe for production package
NVRAMRev=$Rev: 492104 $
#4356 chip = 4354 A2 chip
sromrev=11
boardrev=0x1102
boardtype=0x073e
boardflags=0x02400201
#0x2000 enable 2G spur WAR
boardflags2=0x00802000
boardflags3=0x0000000a
@pacmac
pacmac / myrestore
Created November 4, 2021 01:34
Restore a MYSQL database using raw .sql or gzipped .sql.gz file
MYSQL="$(which mysql)";
GUNZIP="$(which gunzip)";
## Usage
if [ $1 == "help" ];then
echo "usage myrestore [DBNAME] [filename.sql|filename.sql.gz]"
echo "myrestore MYDB mydb.12345.sql.gz";
exit 0;
fi
@pacmac
pacmac / mysql_native_pwd.sql
Created October 15, 2021 00:16
Set native password for mysql connection & allow root connection from any ip (allowed by firewall)
; allow root access from any host
GRANT ALL ON *.* to 'root'@'%' IDENTIFIED BY 'your-password-here';
; switch to native passwords
update mysql.user set plugin = 'mysql_native_password' where User='root';
; apply changes
Flush privileges;
## Move default mysql databases to new volume.
##############################################
# https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04
echo "This cannot be executed"
exit 1;
## Backup before we start just in case.
/usr/share/scripts/cron/mybackup.sh
#!/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 April 24, 2020 23:54
Ping a Host & Save Status to Log File
#!/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 April 24, 2020 02:13
Broadcom USB Fix
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 April 22, 2020 02:35
Asterisk Check Offline Extensions
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 March 22, 2020 10:58
get fastest host ping and only output if a host is faster than the one provided in $1
#!/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 February 25, 2020 02:31
Asus Padadavan - Run the Script After Connected/Disconnected to VPN Server:
#!/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