Skip to content

Instantly share code, notes, and snippets.

View bodsch's full-sized avatar

Bodo Schulz bodsch

View GitHub Profile
@bodsch
bodsch / bash_aliases
Created November 7, 2019 05:58
bash_aliases
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]
then
eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
fi
# some more ls aliases
@bodsch
bodsch / ks.cfg
Created September 2, 2019 12:28
kickstart file for centos
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text or graphical install
text
#graphical
# Run the Setup Agent on first boot
firstboot --enable
@bodsch
bodsch / tmux-cheatsheet.markdown
Created August 12, 2019 07:37 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@bodsch
bodsch / add-dynamic-group-var.bash
Created April 8, 2019 14:37 — forked from kenny-evitt/add-dynamic-group-var.bash
Files for Ansible for supporting dynamic host variables retrieved from a local SQLite database
#!/usr/bin/env bash
group_name="$1"
var_name="$2"
var_value="$3"
./create_dynamic_vars_db.py
sqlite3 dynamic_vars.db "INSERT OR REPLACE INTO group_vars ( group_name, var_name, var_value ) VALUES ( '${group_name}', '${var_name}', '${var_value}' );"
@bodsch
bodsch / graphite_send
Created March 6, 2019 05:45
Shell script to submit "metrics" to graphite.
#!/bin/sh
#
# About
# -----
# This script sends simple system-metrics to a remote graphite server.
#
#
# Metrics
# -------
# The metrics currently include the obvious things such as:
@bodsch
bodsch / ansible-vault.md
Created January 30, 2019 16:55 — forked from hvanderlaan/ansible-vault.md
Ansible-vault example

Ansible vault example

New in Ansible 1.5, “Vault” is a feature of ansible that allows keeping sensitive data such as passwords or keys in encrypted files, rather than as plaintext in your playbooks or roles. These vault files can then be distributed or placed in source control. To enable this feature, a command line tool, ansible-vault is used to edit files, and a command line flag –ask-vault-pass or –vault-password-file is used. Alternately, you may specify the location of a password file or command Ansible to always prompt for the password in your ansible.cfg file. These options require no command line flag usage.

Requirements

@bodsch
bodsch / gist:4ea55240d7c4b0706d8504eba6b975fc
Last active November 10, 2018 10:26
install icingaweb2-module-vspheredb in alpine
apk add php7-phar php7-sockets php7-pcntl
cd /usr/bin/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
ln -s composer.phar composer
cd /usr/share/webapps/icingaweb2-2.6.1/modules/vspheredb/
@bodsch
bodsch / replacement for netcat
Created August 10, 2018 15:59
replacement for netcat
# now wait for ssh port
RETRY=20
until [[ ${RETRY} -le 0 ]]
do
timeout 1 bash -c "cat < /dev/null > /dev/tcp/${VM_NAME}.${VM_DOMAIN}/22" 2> /dev/null
if [ $? -eq 0 ]
then
break
else
sleep 20s
@bodsch
bodsch / get_latest_release.sh
Created June 1, 2018 20:56 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@bodsch
bodsch / vercomp
Last active May 29, 2018 13:45
compare two strings in dot separated version format in Bash
#!/bin/bash
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
vercomp() {
[[ $1 == $2 ]] && return 0
v1=$(echo "$1" | sed -e 's|-|.|g')
v2=$(echo "$2" | sed -e 's|-|.|g')
local IFS=.