Skip to content

Instantly share code, notes, and snippets.

View waja's full-sized avatar
🥾
#yoloOps #itscomplicated #BackpackingThroughAsia

waja

🥾
#yoloOps #itscomplicated #BackpackingThroughAsia
View GitHub Profile
@waja
waja / deploy_watchtower.sh
Last active April 23, 2025 08:44
Deploy watchtower container with label support
#!/bin/bash
DOCKER_BASE=/srv/docker
mkdir -p ${DOCKER_BASE}/watchtower/container.conf
cat > ${DOCKER_BASE}/watchtower/container.conf/docker-compose.yml <<EOF
version: '3.7'
services:
watchtower:
@waja
waja / autoupgrade_docker-ce_container.io.sh
Last active April 18, 2025 15:55
Deploy docker on Debian
#!/bin/bash
cat <<EOF > /etc/apt/preferences.d/docker_pinning
Package: docker-ce*
Pin: version 5:27.5.*
Pin-Priority: 1000
Package: containerd.io
Pin: version 1.7*
Pin-Priority: 1000
@waja
waja / Dockerfile
Created January 25, 2016 13:35
Example Dockerfile creating a simple nginx container
# Pull base image
FROM debian:latest
# Dockerfile Maintainer
MAINTAINER Jan Wagner "waja@cyconet.org"
# Install nginx and adjust nginx config to stay in foreground
RUN apt-get update && apt-get install --no-install-recommends -y nginx; \
echo "daemon off;" >> /etc/nginx/nginx.conf
@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 / deploy_traefik.sh
Last active November 26, 2024 07:55
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 / README.md
Last active July 30, 2024 09:17
Migration from Debian Jessie to Stretch
@waja
waja / redis-sentinel-switch-state.sh
Last active April 30, 2024 15:51
Shell script to migrate a VIP to the actual redis master when managing them with redis-sentinel
#!/bin/sh
_DEBUG="on"
DEBUGFILE=/tmp/sentinel_failover.log
VIP='10.125.125.30'
MASTERIP=${6}
MASK='24'
IFACE='eth0'
MYIP=$(ip -4 -o addr show dev ${IFACE}| grep -v secondary| awk '{split($4,a,"/");print a[1]}')
DEBUG () {
@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 / traefik_export_certs.sh
Last active November 22, 2023 14:11
Export key and cert from traefiks acme.json
#!/bin/bash
SAN="${1}"
ACME_FILE="${2}"
TMP_DIR="$(mktemp -d /tmp/XXXXXXX)"
trap 'rm -rf -- "${TMP_DIR}"' EXIT
if [ ! -f "${ACME_FILE}" ] || [ -z "${ACME_FILE}" ] ; then
echo "error: acme file (${ACME_FILE}) missing"
exit
@waja
waja / .gitlab-ci.yml
Last active November 17, 2023 16:10
Ansible molecule Gitlab CI
# See https://gitlab.com/richardskumat/ansible-role-client-debian-role/-/blob/master/.gitlab-ci.yml
image: qwe1/dind-ansible-molecule:latest
variables:
# DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
# https://gitlab.com/gitlab-org/gitlab-ce/issues/64959
# 19.03 had some breaking changes compared to 18.09
DOCKER_TLS_CERTDIR: ""
services: