Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Send desktop notification (Xorg & Wayland support)
#
# Example:
# notify.sh -u critical "resticprofile backup is too old!"
# detect the user id of the user logged in
_EUID=$(loginctl | head -n2 | tail -1 | sed -e 's/^[ \t]*//' | cut -f2 -d' ')
#!/usr/bin/env bash
# notify in case of error
set -eE # same as: `set -o errexit -o errtrace`
trap '_error_trap $? $LINENO' ERR
_error_trap(){
if [ "$1" != "0" ]; then
echo >&2 "Error - exited with status $1 at line $2:" ; pr -tn $0 | tail -n+$((${2} - 3)) | head -n7
/home/kalos/.bin/notify.sh -u critical "resticprofile check last backup: exited ($1) at line $2"
@kalos
kalos / btrbk_report
Created September 10, 2020 17:10
btrbk report script (copy in /etc/cron.weekly/)
#!/usr/bin/env bash
# create reports for weekly email
LOG_DIR='/var/log/btrbk'
echo "LAST BACKUPS"
echo ""
for log in `ls "${LOG_DIR}"/*.latest`; do
log_name="`basename "${log}"| tr '_' '/'`"
@kalos
kalos / backup_btrbk
Last active September 10, 2020 17:10
script I use to run btrbk backup (copy in /etc/cron.hourly/)
#!/usr/bin/env bash
# alarm check if launch this script with 'onlycheck' as fist param
test "${1}" != 'onlycheck' && \
(
if /home/kalos/.bin/check_desegno_network.sh ; then
# if I'm at work, run btrbk (resume + run) using config with only external disk that I have at work
/usr/sbin/btrbk -c /etc/btrbk/btrbk-desegno.conf resume && systemd-inhibit --who="btrbk" --why="Prevent interrupting btrbk scheduled backup" /usr/sbin/btrbk -c /etc/btrbk/btrbk-desegno.conf -q run >/dev/null 2>&1
else

Keybase proof

I hereby claim:

  • I am kalos on github.
  • I am c_loleggio (https://keybase.io/c_loleggio) on keybase.
  • I have a public key ASAt3QRJQzyEGA0XJQ16K8utkAWDM29apv6n-fKAB1sYzAo

To claim this, I am signing this object:

#!/usr/bin/ruby
# Require:
# - linux or Mac
# - ruby 1.8.7
# - Gem soap4r
# - curl
#
# Usage :
# ruby ovhfact.rb 2011
#
@kalos
kalos / mysql
Created September 6, 2012 13:42
mysql/percona default init
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
# MySQL (Percona Server) daemon start/stop script.
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.
@kalos
kalos / bsnap.sh
Created December 5, 2011 14:47
create btrfs simple snapshot
#!/bin/bash
pool_btrfs=`mount -t btrfs | grep " / " | cut -d " " -f 1` && \
tmp=`mktemp -p /tmp -d bsnap-XXXX` && \
mount $pool_btrfs $tmp && \
btrfs subvol snapshot $tmp/@ $tmp/@bsnap_`date '+%Y-%m-%d_%H.%M'`${1} && \
umount $tmp && \
rmdir $tmp
@kalos
kalos / ye-pass-update.sh
Created October 12, 2011 16:06
update and backup password
#!/bin/bash
# simple script to update my yubikey and ecryptfs password
# http://nerdrug.org/blog/gestione-delle-credenziali/
YBAK="/root/yubikey"
TO="kalos.nerd@gmail.com"
SUBJ="[backup]: pass"
MSMTP_OPT="-C $HOME/.mail/.msmtprc"
bindkey "^v" edit_command_line
edit_command_line () {
# edit current line in $EDITOR
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
print -R - "$PREBUFFER$BUFFER" >$tmpfile
exec </dev/tty
${VISUAL:-${EDITOR:-vi}} $tmpfile
zle kill-buffer