Skip to content

Instantly share code, notes, and snippets.

View lorello's full-sized avatar
🏠
Working from home

LoreLLo lorello

🏠
Working from home
View GitHub Profile
@lorello
lorello / backup-dbs.sh
Last active April 17, 2020 17:25
pgdump for a list of db
#!/bin/bash
DB_LIST='sdc
sdc_bugliano
sdc_ala
sdc_treville'
for DB in $DB_LIST; do
pg_dump $DB > $DB.sql
@lorello
lorello / docker-compose.yml
Last active September 1, 2020 11:10
Initialitaion inside yaml file with a long bash command .... example from min.io
createbuckets:
image: minio/mc
networks:
- backplane
depends_on:
- minio
entrypoint: >
/bin/sh -c "
while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done;
sleep 5;
@lorello
lorello / swarm-nodes-cleanup.sh
Created August 21, 2020 15:20
Docker swarm dead workers cleanup
#!/bin/bash
#
# This script clean a docker swarm cluster from all the dead worker nodes
#
# docker node ls output example
# ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
#y4000************e1uv5vdj * boat-manager-c240 Ready Active Reachable 19.03.11
#wlqc4************zywu7z90 boat-manager-cb78 Ready Active Reachable 19.03.8
#i9fz8************rkmn98yh boat-manager-e102 Ready Active Leader 19.03.8
#wgrj7************rj8sglzg boat-tank01-9a5b Down Active 19.03.9
@lorello
lorello / docker-setup-loki-plugin.sh
Last active August 27, 2024 15:41
Loki plugin for docker setup
#!/bin/bash
set -ex
if docker plugin inspect loki > /dev/null; then
echo "Loki plugin already installed"
else
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
fi
@lorello
lorello / gist:9c0bb25194d403c53963b4cb15ccbbaa
Created September 8, 2020 21:36
Realtime accesslog statistic of Traefik web router with goaccess
docker logs -f traefik | \
goaccess \
--log-format "%h %^ %e [%d:%t %^] \"%r\" %s %b \"%R\" \"%u\" %^ \"%v\" \"%^\" %Lms" \
--date-format "%d/%b/%Y" --time-format "%H:%M:%S"
@lorello
lorello / deploy.sh
Last active March 30, 2021 13:07
Swarm deploy utility with slack notification
#!/bin/bash
# vim: autoindent tabstop=2 shiftwidth=2 expandtab softtabstop=2 fileencoding=utf-8
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
DEPLOY_CONTEXT=
@lorello
lorello / gist:69e16f1c9caa851f1fcbb674d545a109
Last active March 8, 2021 23:58
Unattended upgrades configuration
#!/usr/bin/env bash
set -e
[[ $DEBUG ]] && set -x
conf=/etc/apt/apt.conf.d/50unattended-upgrades
if [[ ! -f $conf ]]; then
echo "Cannot fine /etc/apt/apt.conf.d/50unattended-upgrades, is this an Ubuntu host?"
exit 1
@lorello
lorello / README.md
Created December 17, 2021 18:02
Opencontent Developer Links
@lorello
lorello / gh-download-latest.sh
Created February 9, 2023 23:49
Download latest github version os something
wget $(curl -s https://api.github.com/repos/$USER/$REPO/releases/latest | jq -r '.assets[] | select(.name|match("Linux_x86_64.tar.gz$")) | .browser_download_url') && tar xzvf *.tar.gz kaf
@lorello
lorello / byobu-unattended-setup.sh
Last active February 26, 2023 16:34
Byobu unattended setup
if ! which byobu >/dev/null; then
echo "Byobu not installed, skip configuration"
exit 1
fi
[[ ! -f /var/lock/.byobu-shell-fixed ]] && \
echo "fixes byobu problem with UMASK, now byobu-shell is a login shell" && \
sed -i -e 's/exec "$SHELL"/exec "$SHELL" --login/' /usr/bin/byobu-shell && \
touch /var/lock/.byobu-shell-fixed