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_rootlessdocker.sh
Last active December 8, 2022 14:44
Deploy rootless docker (on debian buster)
#!/bin/bash
# wget https://gist.githubusercontent.com/waja/0deb4dd5cd759371270dc3e1f5dabcb5/raw/deploy_rootlessdocker.sh -O /tmp/a && sh /tmp/a
# Check if dockerd is installed
[ $(which dockerd) ] || wget https://gist.githubusercontent.com/waja/01ba2641f93f461044f9/raw/docker_deploy.sh \
-O /tmp/docker_deploy.sh && bash /tmp/docker_deploy.sh
# Stop and disable dockerd (runs as root)
systemctl stop docker && systemctl disable docker && systemctl disable docker.socket
# Crossgrade jessie over to amd64 along https://stbuehler.de/blog/article/2017/06/28/debian_stretch__upgrade_32-bit_to_64-bit.html,
# but on jessie downloading the correct packages is a bit more complicated
aptitude search ~M | cut -c5- | cut -d' ' -f1 > aptitude.auto
dpkg -l | grep '^ii' | awk '{print $2}' > packages
dpkg --print-architecture
dpkg --print-foreign-architectures
dpkg --add-architecture amd64
apt-get update
@waja
waja / deploy_dom0.sh
Last active September 27, 2019 20:40
deploy_dom0.sh
# Install needed packages
apt install bridge-utils xen-system-amd64 grub-xen-host xen-tools lvm2
# Reduce dom0 memory
sed -i s/#GRUB_CMDLINE_XEN=\"\"/GRUB_CMDLINE_XEN=\"dom0_mem=1024M\"/ /etc/default/grub.d/xen.cfg && update-grub
# Don't touch iptables when creating te bridge interface
cp /etc/xen/scripts/vif-bridge /etc/xen/scripts/vif-bridge-local && \
sed -i s/^handle_iptable/#handle_iptable/g /etc/xen/scripts/vif-bridge-local && \
sed -i s/#vif.default.script=\"vif-bridge\"/vif.default.script=\"vif-bridge-local\"/g /etc/xen/xl.conf
# Disable saving and restoring domains
sed -i s/XENDOMAINS_RESTORE=true/XENDOMAINS_RESTORE=false/ /etc/default/xendomains
@waja
waja / deploy_phpmyadmin_buster.sh
Last active April 30, 2020 10:20
Deploy phpmyadmin on Debian (Buster) 10.x
#!/bin/bash
# wget https://gist.githubusercontent.com/waja/77e3d2febb0745478466344f0ce5a50e/raw/deploy_phpmyadmin_buster.sh -O /tmp/a && sh /tmp/a
# taken from https://github.com/phpmyadmin/phpmyadmin/issues/15236#issuecomment-507871960
[ $(grep buster-backports /etc/apt/sources.list.d/* | wc -l) -le 0 ] && cat <<EOF >> /etc/apt/sources.list.d/buster-backports.list
#
# Debian backports
#
deb http://ftp.de.debian.org/debian/ buster-backports main non-free contrib
deb-src http://ftp.de.debian.org/debian/ buster-backports main non-free contrib
#!/bin/bash
# Creating some temp dir
TMPDIR=$(mktemp -d /tmp/d.XXXXXX) && \
trap 'rm -rf "${TMPDIR}"' EXIT && \
# Install lazydocker
LAZYDOCKER_VERSION=$(curl -L -s -H 'Accept: application/json' https://github.com/jesseduffield/lazydocker/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') && \
GITHUB_FILE="lazydocker_${LAZYDOCKER_VERSION//v/}_$(uname -s)_$(uname -m).tar.gz" && \
GITHUB_URL="https://github.com/jesseduffield/lazydocker/releases/download/${LAZYDOCKER_VERSION}/${GITHUB_FILE}" && \
curl -o ${TMPDIR}/lazydocker.tar.gz -L ${GITHUB_URL} && \
tar xzvf ${TMPDIR}/lazydocker.tar.gz -C ${TMPDIR} && \
@waja
waja / backuppc-achive-rclone.sh
Last active October 16, 2021 18:22
Script to glue http://backuppc.sourceforge.net/faq/BackupPC.html#Archive-Configuration and https://rclone.org/ for pushing encrypted backups also into the clouds
#!/bin/bash
if [ -r /opt/etc/default/backuppc-achive-rclone ]; then
source /opt/etc/default/backuppc-achive-rclone
else
source /etc/default/backuppc-achive-rclone
fi
if [ -r /opt/etc/backuppc-achive-rclone.conf ]; then
source /opt/etc/backuppc-achive-rclone.conf
@waja
waja / pgsql_dump_all.sh
Created May 10, 2019 09:18
Dump postgresql databases and roles, keeping last 14 days, the lazy way
#!/bin/bash
DATE="$(date +%d)"
psql_user="postgres"
psql_host="/var/run/postgresql/"
psql_port="5432"
[ -f /opt/gitlab/etc/gitlab-psql-rc ] && . /opt/gitlab/etc/gitlab-psql-rc
@waja
waja / jessie_fix_source_lists.sh
Last active April 28, 2021 16:37
Fix source lists after removal of jessie-updates and move of jessie-backports into archive.debian.org
#!/bin/bash
# disable jessie-updates in /etc/apt/sources.list
sed -i 's/\(.*jessie\-updates\)/#\1/' /etc/apt/sources.list
# disable jessie-backports, it's deprecated
sed -i 's/\(.*jessie\-backports\)/#\1/' /etc/apt/sources.list.d/jessie-backports.list
apt-get update
@waja
waja / README.md
Last active December 15, 2021 10:54
Migration from Debian Stretch to Buster
@waja
waja / deploy_portainer.sh
Last active December 7, 2018 11:10
Deploy Portainer UI for Docker
#!/bin/bash
DOCKER_BASE=/srv/docker
mkdir -p ${DOCKER_BASE}/portainer/container.conf
cat > ${DOCKER_BASE}/portainer/container.conf/docker-compose.yml <<EOF
version: '3.7'
services:
portainer:
image: portainer/portainer