Skip to content

Instantly share code, notes, and snippets.

View h0tw1r3's full-sized avatar
🏝️
Living the dream

Jeffrey Clark h0tw1r3

🏝️
Living the dream
View GitHub Profile
#!/bin/bash
# halt on any errors
set -o pipefail -e
BREW_INSTALL_PATH=/home/linuxbrew/.linuxbrew
if ! [ -x "/home/linuxbrew/.linuxbrew/bin/brew" ] ; then
if ! sudo -l -U root >/dev/null 2>&1 ; then
echo "root sudo permission required to install"
@h0tw1r3
h0tw1r3 / playbook-system-update.yml
Last active March 27, 2022 14:26
ansible playbook to update all apt or yum packages
---
- hosts: all
tasks:
- name: "yum: upgrade packages"
yum:
name: '*'
state: latest
update_cache: yes
update_only: yes
register: yum_update_status
@h0tw1r3
h0tw1r3 / check_lastupdate.py
Last active October 24, 2021 00:36
nagios style last system update check for yum, dnf and apt
#!/usr/bin/env python
from __future__ import print_function
from datetime import timedelta
from datetime import datetime
import os
import re
import sys
@h0tw1r3
h0tw1r3 / dns-sync.sh
Created April 19, 2020 19:53
Work-around issues with WSL DNS resolver
#!/bin/bash
# Based on https://gist.github.com/matthiassb/9c8162d2564777a70e3ae3cbee7d2e95
PATH=/sbin:/bin
WINSYS32=/mnt/c/Windows/System32
PS=$WINSYS32/WindowsPowerShell/v1.0/powershell.exe
CHCP=$WINSYS32/chcp.com
PIDFILE=/var/run/dns-sync.pid
@h0tw1r3
h0tw1r3 / linux-powershell_alias.sh
Last active April 19, 2020 19:47
WSL bash powershell alias
__WINSYS32=/mnt/c/Windows/system32
__POWERSHELL=${__WINSYS32}/WindowsPowerShell/v1.0/powershell.exe
powershell() {
if [ -z "${__OEMCP}" ] ; then
__OEMCP=$(${__WINSYS32}/reg.exe query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage" /v OEMCP 2>&1 | sed -n 3p | tr -d '\015' | grep -o '[[:digit:]]*')
fi
$__WINSYS32/chcp.com $__OEMCP >/dev/null
$__POWERSHELL "$@" | tr -d '\015'
$__WINSYS32/chcp.com 65001 >/dev/null
@h0tw1r3
h0tw1r3 / nsca-ng.spec
Created January 8, 2020 21:03
RPM spec for packaging nsca-ng 1.6 tested on RHEL/CentOS 6 and 7
%if 0%{?fedora} > 17 || 0%{?rhel} > 6
%global systemd_support 1
%else
%global systemd_support 0
%endif
Summary: A modern replacement for NSCA
Name: nsca-ng
Version: 1.6
Release: 1%{?dist}
#!/usr/bin/env python2
#
# lxc.hook.pre-start
#
# remounts proxmox container mounts with noatime for performance
#
# copy this file to /usr/share/lxc/hooks/lxc-proxmox-noatime
# create /usr/share/lxc/config/common.conf.d/99-mount-noatime.conf
# with contents: lxc.hook.pre-mount /usr/share/lxc/hooks/lxc-proxmox-noatime
@h0tw1r3
h0tw1r3 / nic.rb
Created November 6, 2018 09:07
nic fact for puppet gathers speed, duplex, state, slaves, device module, carrier, etc
# Fact: nic { speed, state, duplex, ... }
#
# Copyright: Jeffrey Clark
# License: GPLv3
require 'pathname'
nic = Hash.new
ifaces = Facter.value(:interfaces)
@h0tw1r3
h0tw1r3 / all-libvirt-hooks
Created October 7, 2018 19:40
hooks.d for libvirt
#!/bin/bash
# Copy or link this script to /etc/libvirt/hooks/{network,qemu,daemon,lxc}
TYPE=$(basename $0)
HOOKS_PATH="/etc/libvirt/hooks.d/${TYPE}/${1}"
[ ! -e "${HOOKS_PATH}" ] && exit 0
if [ -x "${HOOKS_PATH}/${2}/${3}" ] ; then
@h0tw1r3
h0tw1r3 / syslog-ng.conf
Created October 22, 2017 11:57
Syslog-ng 3.6.4 configuration
@version:3.6
@include "scl.conf"
options {
flush-timeout(2000);
chain-hostnames(no);
use-dns(yes);
use-fqdn(no);
create-dirs(yes);
keep-hostname(yes);