Skip to content

Instantly share code, notes, and snippets.

View waja's full-sized avatar
🐢
#yoloOps #itscomplicated

waja

🐢
#yoloOps #itscomplicated
View GitHub Profile
@waja
waja / createsasluser.sh
Last active February 26, 2019 08:27
Create user in sasldb and replicate the db to other system(s)
#!/bin/bash
[ -f /etc/dehydrated/hook.sh ] && . /etc/dehydrated/hook.sh
SASLDBFILE="/var/spool/postfix/etc/sasldb2"
SASLDBPASSWD="$(/usr/bin/which saslpasswd2)"
SASLDBLISTUSER="$(/usr/bin/which sasldblistusers2)"
LOGFILE="/var/log/sasl/createsasluser.log"
RSYNC="$(/usr/bin/which rsync)"
PWGEN="$(/usr/bin/which pwgen)"
@waja
waja / cloudatcost-pxe.sh
Created September 17, 2018 09:43
cloudatcost-pxe.sh
#!/usr/bin/env bash
cdr2mask ()
{
# Number of args to shift, 255..255, first non-255 byte, zeroes
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
[[ $1 -gt 1 ]] && shift ${1} || shift
echo "${1-0}.${2-0}.${3-0}.${4-0}"
}
@waja
waja / 0-performance.md
Last active March 2, 2018 23:37
OVH disc performance test

VPS Performance Tests

Test procedure https://dzone.com/articles/iops-benchmarking-disk-io-aws-vs-digitalocean

VPS 2016 Cloud 2

$ aptitude -y install -o quiet=2 ioping fio > /dev/null; time fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --output=/root/tempfile --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75; rm -f test.*; cat tempfile; ioping -c 10 /root | tail -4
Jobs: 1 (f=1): [m(1)] [100.0% done] [1529KB/580KB/0KB /s] [382/145/0 iops] [eta 00m:00s]
real	14m20.420s
user	0m14.620s
@waja
waja / deploy_traefik.sh
Last active July 26, 2025 05:59
Deploy Traefik as Frontend Proxy for Docker
#!/bin/bash
DOCKER_BASE="${DOCKER_BASE:-/srv/docker}"
TRAEFIK_DIR="${TRAEFIK_DIR:-traefik}"
mkdir -p ${DOCKER_BASE}/${TRAEFIK_DIR}/container.conf
touch ${DOCKER_BASE}/${TRAEFIK_DIR}/container.conf/.env
ln -s container.conf/.env ${DOCKER_BASE}/${TRAEFIK_DIR}/
cat > ${DOCKER_BASE}/${TRAEFIK_DIR}/container.conf/docker-compose.yml <<EOF
@waja
waja / add_healthcheack.sh
Last active June 5, 2025 09:50
Deploy watchtower container with label support
#!/bin/bash
DOCKER_BASE=/srv/docker
mkdir -p ${DOCKER_BASE}/watchtower/container.conf
[ $(grep -c "healthcheck:" ${DOCKER_BASE}/watchtower/container.conf/production.yml) -eq 0 ] && sed -i '/labels:/i\ healthcheck:\n\ test: ["CMD", "/watchtower", "--health-check"]\n\ interval: 30s\n\ timeout: 10s\n\ retries: 3\n\ start_period: 40s' ${DOCKER_BASE}/watchtower/container.conf/docker-compose.yml && cd ${DOCKER_BASE}/watchtower/ && docker-compose -f docker-compose.yml -f container.conf/production.yml config && systemctl restart watchtower
#!/bin/sh
# install needed curl package
sudo apt install --no-install-recommends curl -y
# install kubectl
# https://github.com/kubernetes/minikube/issues/3437#issuecomment-449408316, maybe use https://storage.googleapis.com/minikube/releases/v0.30.0/docker-machine-driver-kvm2
curl -Lo /tmp/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x /tmp/kubectl && \
sudo mv /tmp/kubectl /usr/local/bin/kubectl
# kubectl tab completion
sudo sh -c 'echo "source <(kubectl completion bash)" > /etc/bash_completion.d/kubectl'
@waja
waja / deploy_icinga2_agent_hw.sh
Last active April 24, 2024 12:46
Deploying icinga2 satellite or agent
#!/bin/bash
# wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_agent_hw.sh -O /tmp/b && bash /tmp/b
. /etc/os-release
if [ "$(systemd-detect-virt)" == "none" ]; then
modprobe ipmi_si && modprobe ipmi_devintf && \
apt-get install -y --no-install-recommends -t ${VERSION_CODENAME}-backports freeipmi-tools libipc-run-perl pciutils && \
echo "nagios ALL=(root) NOPASSWD: /usr/sbin/ipmi-sensors, /usr/sbin/ipmi-sel, /usr/sbin/ipmi-fru, /usr/sbin/ipmi-dcmi" > /etc/sudoers.d/check_ipmi_sensor && \
echo "nagios ALL=(root) NOPASSWD: /usr/sbin/smartctl" > /etc/sudoers.d/check_smart && \
@waja
waja / create_debian-sys-maint_for_mysqladmin.sh
Last active January 21, 2025 11:44
Create 'debian-sys-maint' MariaDB user for use of mysqladmin. Just in case you can't use 'root' via 'unix_socket' plugin.
#!/bin/sh
MYSQLADMIN_CFG="/etc/mysql/mariadb.conf.d/90-mysqladmin.cnf"
# generate password
PASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
# adjust /etc/mysql/debian.cnf (used as defaults file by system scripts)
sed -i "s/^password =.*$/password = ${PASS}/" /etc/mysql/debian.cnf
sed -i "s/^user =.*$/user = debian-sys-maint/" /etc/mysql/debian.cnf
# create config file for mysqladmin itself (maybe not needed)
umask 066
cat > ${MYSQLADMIN_CFG} <<EOF
@waja
waja / README.md
Last active July 30, 2024 09:17
Migration from Debian Jessie to Stretch
wget -c "https://boot.netboot.xyz/ipxe/netboot.xyz.lkrn" -O /boot/netboot.xyz.lkrn && \
cat > /etc/grub.d/40_custom <<EOF
#!/bin/sh
exec tail -n +3 \$0
menuentry 'netboot.xyz' {
set root='hd0,msdos1'
linux16 /netboot.xyz.lkrn
}
EOF
update-grub