Skip to content

Instantly share code, notes, and snippets.

View xenithorb's full-sized avatar

Michael Goodwin xenithorb

View GitHub Profile
@xenithorb
xenithorb / fedora-rsync-mirror.sh
Last active November 26, 2021 09:24
Script for rsyncing fedora repos for local private mirror
#!/bin/bash
VERSION=24
ARCH="x86_64"
REPO_DIR=/media/backup/repos/fedora/linux/
MIRROR=(
"rsync://repo.atlantic.net/fedora/linux/"
"rsync://mirror.lstn.net/fedora-enchilada/"
)
@xenithorb
xenithorb / kmod-signer.sh
Last active November 16, 2021 07:49
Akmod kernel module auto-signer for kernel upgrades on Fedora
#!/bin/bash
#
# /etc/kernel/postinst.d script to sign akmods kmods after kernel upgrade
#
# Author: Michael Goodwin Date: 2016-09-21
# 1. Copy this script to /etc/kernel/postinst.d/ and `chmod +x` it
#
# 2. Create signing keys (store these somewhere useful and safe):
# $ mkdir -p /etc/pki/tls/private/mok
@xenithorb
xenithorb / ssl.inc
Last active December 6, 2016 17:41
Favorite NGINX SSL settings
# Parts configured from recommmendations at:
# https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html and
# https://cipherli.st/
#ssl_trusted_certificate /etc/letsencrypt/live/[ ]/chain.pem;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
#ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_session_cache shared:SSL:10M;
@xenithorb
xenithorb / .bashrc
Created December 22, 2016 18:59
List listening ports for a cgroup - bashrc style function
# Find listening ports of a service cgroup
# https://www.redpill-linpro.com/sysadvent/2016/12/22/systemd-at-3am.html
lsof_listen() {
local pids=$( ps -e -o pid,cgroup | awk '$2 ~ /'"$1"'/ { print "-p", $1 }' )
sudo lsof -n -i -a -P ${pids:?ERROR: No PIDs found.}
}
@xenithorb
xenithorb / fonts.conf
Created January 1, 2017 13:17
fontconfig from laptop ~/.config/fontconfig/fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit name="rgba" mode="assign">
<const>bgr</const>
</edit>
</match>
<match target="font">
<edit name="hinting" mode="assign">
@xenithorb
xenithorb / colortail.sh
Created February 10, 2017 15:51
tail with highlight for matching lines with color
color_tail() { local file="$1"; shift; local awk_cmd="$(count=0; for i in "$@"; do ((count++)); printf '/%s/ {print "\\033[3%sm",$0,"\\033[39m"; next; }\n' "$i" "$count"; done; echo "{ print \$0 }")"; tail -n100 -f "$file" | eval awk \'"${awk_cmd}"\'; }
@xenithorb
xenithorb / rpi_enable_watchdog.sh
Last active February 23, 2017 04:23
One-liner to enable Rasbperry Pi 3 watchdog timer
if [[ -c /dev/watchdog ]]; then if [[ -d /etc/systemd ]]; then mkdir /etc/systemd/system.conf.d &>/dev/null; else { echo "ERROR: No systemd"; exit; }; fi; echo -e "[Manager]\nRuntimeWatchdogSec=10\nShutdownWatchdogSec=3min" > /etc/systemd/system.conf.d/watchdog.conf; else { echo "No watchdog device present"; exit; }; fi && systemctl daemon-reload && systemctl daemon-reexec && systemctl show | grep Watchdog
#!/bin/bash
FILESET_NAME="${1:?ERROR: First argument (fileset name) not provided}"
AND_VERS="7.0"
API_VERS="24"
patch_list=(
"sigspoof-hook-${AND_VERS}"
"sigspoof-core"
"sigspoof-ui-global-${AND_VERS}"
@xenithorb
xenithorb / ssh-auth-sock.service
Created April 5, 2017 21:32
systemd user unit: Custom SSH_AUTH_SOCK variable for X11/Wayland (Fedora/GNOME)
# Because setting environment variables is HARD!! (apparently)
# 1. Disable gnome-keyring-ssh, or just allow ExecStartPre to do it:
# $ NAME="gnome-keyring-ssh.desktop"; cat "/etc/xdg/autostart/${NAME}" \
# <(echo "Hidden=true") > "${HOME}/.config/autostart/${NAME}"
# 2. $ mkdir -p ~/.config/systemd/user
# 3. Place this file in ~/.config/systemd/user/ssh-auth-sock.service
# 4. $ systemctl --user enable --now ssh-auth-sock.service
# 5. Logout or reboot.
[Unit]
@xenithorb
xenithorb / dtmf_getter.sh
Created April 19, 2017 14:51
Parse freeswitch log for DTMF codes and output a single string
#!/bin/bash
LOGFILE="/var/log/freeswitch/freeswitch.log*"
#LOGFILE="/usr/local/freeswitch/log/freeswitch.log*"
USER="centos"
REMOTE_ADDR="${1:?ERROR: No remote address provided}"
UUID="${2:?ERROR: No UUID provided}"
get_logs() {
"$SUDO" find "${LOGFILE%/*}" -type f -name "${LOGFILE##*/}" ! -empty