This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
T="$(date +%Y-%m-%d-%H%M)" | |
BASEDIR=/opt/backups/clickhouse | |
DESTDIR="$BASEDIR/$T" | |
. ~/.env.clickhouse # ..CLICKHOUSE_HOST,USERNAME,PASSWORD,DATABASE | |
Query() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Screen 12 | |
Let StepX = 100 | |
Let StepY = 100 | |
Let ScreenWidth = _Width | |
Let ScreenHeight = _Height - 20 | |
For X = 0 To ScreenWidth Step StepX | |
Line (X, 0)-(X, ScreenHeight), 7 | |
Next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Storable qw/freeze/; | |
$Storable::canonical = 1; # https://www.perlmonks.org/?node_id=127254 | |
die "Usage: $0 domain-name\n" unless @ARGV == 1; | |
my $domain = shift @ARGV; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
WAV_AGE="185" | |
WAV_DIR="/var/spool/asterisk/monitor" | |
ARC_DIR="/home/asterisk-archives" | |
if test $# = 0; then | |
test "$(pgrep -fc "$0")" = "1" || { echo "${0##*/} is already running, exit."; exit 1; } | |
cd "$WAV_DIR" | |
nice ionice -c3 find . -type f -mtime +"$WAV_AGE" -name "*.wav" -exec "$0" '{}' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# apt install python3-bcrypt | |
import string | |
import random | |
import bcrypt | |
import sys | |
from getpass import getpass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Environment variables: | |
# username (required) | |
# password (optional for all except check) | |
# Usage in openvpn-server.conf: | |
# auth-user-pass-verify "/etc/openvpn/passwd-auth-script" via-env | |
# script-security 3 | |
# verify-client-cert none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# string samples: | |
# /etc/pve/nodes/node1/lxc/123.conf:net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.20.30.1,hwaddr=1A:2A:3A:CC:C0:0A,ip=10.20.30.40/24,type=veth | |
# /etc/pve/nodes/pm8/qemu-server/134.conf:net0: virtio=A1:B2:C3:B4:D5:E6,bridge=vmbr0,firewall=1 | |
use strict; | |
use warnings; | |
open F, "grep -R hwaddr= /etc/pve |" or die "Cannot grep /etc/pve: $!\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# Based on https://serverfault.com/a/787380/228027 | |
CT="123" | |
DIR="/$VE-$(date +%Y-%m-%d-%H%M)" | |
NEWSIZE="100G" | |
UNPRIV="1" # ..missed by dump/restore => should be selected explicitly | |
mkdir -p "$DIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
test "0" = "$(grep -vc '^Filename' /proc/swaps)" && exit 0 # ..no swaps | |
SWAP_FREE="$(awk ' | |
/^SwapTotal:/ { total = $2 } | |
/^SwapFree:/ { unused = $2 } | |
END { printf "%d\n", 100 * unused / total }' /proc/meminfo)" | |
test "$SWAP_FREE" -lt "${SWAP_NEED_FREE:-55}" || exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Usage sample: | |
# python find-jdups.py dir1 dir2 ... | grep -v = | sort | uniq | awk -F/ '{ print $NF }' | |
import os | |
import sys | |
import zipfile | |
pathlist = dict() |
NewerOlder