Skip to content

Instantly share code, notes, and snippets.

View konstruktoid's full-sized avatar
🤖

Thomas Sjögren konstruktoid

🤖
  • Sweden
  • 20:09 (UTC +02:00)
  • LinkedIn in/thosjo
View GitHub Profile
@konstruktoid
konstruktoid / ansible-fqcn.sh
Created January 6, 2022 10:43
crude Ansible FQCN converter
#!/bin/bash
set -uo pipefail
builtin="add_host
apt
apt_key
apt_repository
assemble
assert
@konstruktoid
konstruktoid / macosxthings.sh
Last active February 4, 2022 10:35
MacOS X things
#!/bin/sh
echo "this will exit so you can go through the code before actually doing anything"
exit 0
if ! [ "$SHELL" = "$(which bash)" ]; then
chsh -s "$(which bash)"
fi
curl -sSL https://raw.githubusercontent.com/konstruktoid/dotfiles/master/.bashrc > ~/.bashrc
@konstruktoid
konstruktoid / VBox_clean.sh
Last active April 19, 2024 10:25
Clean VirtualBox VMs, Vagrant boxes and Containers
#!/bin/bash
set -uo pipefail
CONTAINER_RUNTIME="unset"
if command -v docker >/dev/null 2>&1; then
CONTAINER_RUNTIME=docker
else
CONTAINER_RUNTIME=podman
fi
#!/bin/bash
TESTFILE="$1"
ASSERTRESULT="0"
if [[ -z "${TESTFILE}" ]]; then
echo "Please specify a testfile."
exit 1
fi
if ! file "${TESTFILE}" | grep -q "Python script text"; then
#!/bin/bash
IMG=ubuntu-20.04-server-cloudimg-amd64.img
USER_DATA=user-data
if [ ! -f "${IMG}" ]; then
wget "https://cloud-images.ubuntu.com/releases/focal/release/${IMG}"
qemu-img resize "${IMG}" +10G
fi
if [ ! -f "${USER_DATA}" ]; then
@konstruktoid
konstruktoid / sshpass.rb
Last active September 30, 2021 11:58
brew install sshpass
# curl -sSL <URL>/sshpass.rb > /tmp/sshpass.rb && brew install /tmp/sshpass.rb && rm /tmp/sshpass.rb
require 'formula'
class Sshpass < Formula
url 'http://sourceforge.net/projects/sshpass/files/sshpass/1.09/sshpass-1.09.tar.gz'
homepage 'http://sourceforge.net/projects/sshpass'
sha256 '71746e5e057ffe9b00b44ac40453bf47091930cba96bbea8dc48717dedc49fb7'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
@konstruktoid
konstruktoid / ansible_forks.sh
Last active April 26, 2022 11:52
Script to calculate Ansible forks based on the number of CPUs.
#!/bin/bash -eux
if nproc &>/dev/null; then
CPUS=$(nproc)
elif grep -qc processor /proc/cpuinfo; then
CPUS=$(grep -c processor /proc/cpuinfo)
elif sysctl -n hw.ncpu &>/dev/null; then
CPUS=$(sysctl -n hw.ncpu)
else
CPUS=1
@konstruktoid
konstruktoid / genHostfile.sh
Created October 26, 2020 08:59
Generate a Ansible hosts file from running Vagrant VMs
#!/bin/bash
{
for VM in $(vagrant status | grep -iE 'running.*virtualbox' | grep "$1" | awk '{print $1}'); do
mapfile -t VAGRANT_SSH < <(vagrant ssh-config "$VM" | awk '{print $NF}')
echo "[${VAGRANT_SSH[0]}]"
echo "${VAGRANT_SSH[1]} ansible_connection=ssh ansible_port=${VAGRANT_SSH[3]} ansible_user=${VAGRANT_SSH[2]} ansible_ssh_private_key_file=${VAGRANT_SSH[7]}"
done
} > "hosts"
#!/bin/sh
# https://github.com/jeremylong/DependencyCheck
dependency-check -f JSON -o . -s . &&\
jq -r '. | .dependencies[].vulnerabilities[]?.severity + " " + .dependencies[].vulnerabilities[]?.vulnerableSoftware[].software.id + " " + .dependencies[].projectReferences[]?' dependency-check-report.json |\
awk '{print tolower($0)}' |\
grep -vE '/.*:".*"$|transitive$' |\
sort |\
uniq
@konstruktoid
konstruktoid / mac_developer_certs.md
Last active March 3, 2022 00:25
Installing Developer ID certificates on Mac OS X

Installing Developer ID certificates on Mac OS X

Short guide showing how to install Developer ID certificates, when the Allow button doesn't show up under System Preferences > Security & Privacy > General or you're seeing (libkern/kext) system policy prevents loading; check the system/kernel logs for errors or try kextutil(8). in the installation logs (CMD + L).

System information

macOS Catalina
ProductName:    Mac OS X
ProductVersion: 10.15.4