Skip to content

Instantly share code, notes, and snippets.

View bgstack15's full-sized avatar

B. Stack bgstack15

View GitHub Profile
@bgstack15
bgstack15 / ls-leases
Created April 2, 2017 16:38
list dhcp leases
#!/bin/sh
# 2017-04-02 12:30 quick and dirty ls-leases
# sed combine lines: http://stackoverflow.com/a/7853846/3569534
DEFAULT_LEASE_FILE=/var/lib/dhcpd/dhcpd.leases
leasefile="${DEFAULT_LEASE_FILE}"
#leasefile=/home/bgirton-local/foo
@bgstack15
bgstack15 / convert_to_seq.sh
Created October 11, 2017 20:28
Convert input sets of numbers into numerical sequences
convert_to_seq() {
printf "${@}" | xargs -n1 -d',' | tr '-' ' ' | awk 'NF == 2 { system("/bin/seq "$1" "$2); } NF != 2 { print $1; }' | xargs
}
convert_to_seq "$1"
@bgstack15
bgstack15 / update_root_pw.yml
Created October 25, 2017 13:29
Ansible playbook that changes root password
---
# File: /etc/ansible/playbooks/prod/update_root_pw.yml
# Authors: bgstack15
# Startdate: 2017-10-24
# Title: Playbook that updates the local root password
# Purpose: Makes it easy to update the root password
# Usage:
# time ansible-playbook /etc/ansible/playbooks/prod/update_root_pw.yml -i /etc/ansible/dc3.inv -l el7test14 -v --ask-vault-pass
# Make file /home/ansible/rootpw.yml with the contents:
# ---
@bgstack15
bgstack15 / xfe.spec
Created November 5, 2017 14:56
xfe spec Fedora 26 with proper build deps
Name: xfe
Version: 1.42
Summary: X File Explorer (Xfe) is a file manager for X.
Release: 1{?dist}
License: GPL
Group: File tools
Requires: fox >= 1.6 libpng >= 1.2
BuildRequires: fox-devel >= 1.6 libpng-devel >= 1.2 glib-devel libXft-devel freetype-devel gcc-c++
Source: %{name}-%{version}.tar.gz
Packager: Roland Baudin <roland65@free.fr>
@bgstack15
bgstack15 / get-hrefs.sh
Created December 6, 2017 15:46
Get hrefs from html
#!/bin/sh
# read stdin
grep -oE 'href=\".+\"' | sed -r -e 's/^href=\"//g;' -e 's/\"\s*$//;'
@bgstack15
bgstack15 / htmlize
Created December 6, 2017 21:23
Htmlize function
htmlize () { $( which sed ) -r -e 's/&lt;/\xCAlt;/g;' -e 's/&gt;/\xCAgt;/g;' -e 's/\&amp;/\&amp;amp;/g;' -e 's/\xCA([lg])t;/\&amp;\1t;/g;' ; }
@bgstack15
bgstack15 / hash-cert-dir.sh
Created December 19, 2017 20:54
Hash certificate directory in another directory
#!/bin/sh
# File: hash-cert-dir.sh
# Location: /etc/ansible/roles/general_conf/files/hash-cert-dir.sh
# Author: bgstack15@gmail.com
# Startdate: 2017-12-18
# Title: Script that Makes Symlinks for Certs in a Directory
# Purpose: Make a directory suitable for openldap to use as TLS_CACERTDIR
# History:
# Usage:
# HCD_SOURCEDIR=/etc/pki/ca-trust/source/anchors HCD_LINKDIR=/etc/openldap/cacerts hash-cert-dir.sh
@bgstack15
bgstack15 / userinfo.sh
Created January 5, 2018 13:02
Script that Displays User Info
#!/bin/sh
# Filename: userinfo.sh
# Author: bgstack15@gmail.com
# Startdate: 2018-01-03 16:11
# Title: Script that Displays User Info
# Purpose: Displays specific metrics this environment would like to query
# History:
# Usage:
# Reference:
# id -Gnz https://stackoverflow.com/questions/14059916/is-there-a-command-to-list-all-unix-group-names/29615866#29615866
@bgstack15
bgstack15 / access_like.yml
Created February 12, 2018 16:16
Ansible playbook for configuring access like a user
---
# Filename: access_like.yml
# Location: /etc/ansible/playbooks/access_like.yml
# Author: bgstack15
# Startdate: 2018-02-01 15:00
# Title: Playbook that Sets Access Like a User for a Different User
# Purpose: To make it easy to set up similar user access
# History:
# 2018-02-02 Add sssd support
# 2018-02-09 Add basic sudoers checking
@bgstack15
bgstack15 / delayed_cleanup.sh
Last active March 14, 2018 12:18
Delayed cleanup of temp files in shell
# Example script name: fetch
clean_fetch() {
# Delayed cleanup
if test -z "${FETCH_NO_CLEAN}" ;
then
nohup /bin/bash <<EOF 1>/dev/null 2>&1 &
sleep "${FETCH_CLEANUP_SEC:-300}" ; /bin/rm -r "${FETCH_TMPDIR:-NOTHINGTODELETE}" 1>/dev/null 2>&1 ;
EOF
fi
}