Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 08:09 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@ilyaevseev
ilyaevseev / unbound-unknown2fake.py
Last active March 19, 2024 15:07
Unbound Python module for replacing "Unknown Host/Domain" responses by fake addresses
'''
/etc/unbound/unbound-unknown2fake.py
Required packages: unbound, python-unbound
unbound.conf should contain:
server:
module-config: "validator python iterator"
python:
@ilyaevseev
ilyaevseev / proxmox-shrink-pct-rootfs
Last active October 22, 2023 13:08
Shrink rootfs for container under Proxmox
#!/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"
@ilyaevseev
ilyaevseev / Rebuild-Unbound-srpm.sh
Last active April 16, 2023 16:11
RPM specfile fixes for Unbound DNS, see https://bugzilla.redhat.com/show_bug.cgi?id=1389061 (support for CentOS 7, rebuild without Python)
#!/bin/sh -e
DIR="$(mktemp -d)"
cd "$DIR"
echo "Working directory = $DIR"
yum install -y flex openssl-devel libevent-devel expat-devel pkgconfig python2-devel swig python34-devel systemd wget rpm-build
RPM="unbound-1.5.10-1.fc24.src.rpm"
wget -qcN "http://mirror.yandex.ru/fedora/linux/updates/24/SRPMS/u/$RPM"
@ilyaevseev
ilyaevseev / rocket1.bas
Created February 21, 2023 17:38
First sample for Sofa on QB64
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
@ilyaevseev
ilyaevseev / check-nservers
Created December 3, 2022 21:00
Validate domain NS records against whois and NS servers.
#!/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;
@ilyaevseev
ilyaevseev / Asterisk-WAV-Compress
Created October 19, 2022 14:51
Asterisk cron.weekly script for compressing old wav-files stored in /var/spool/asterisk/monitor
#!/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" '{}' +
@ilyaevseev
ilyaevseev / genbcrypt.py
Created September 22, 2022 02:25
Generate bcrypt password for GLAuth
#!/usr/bin/python3
# apt install python3-bcrypt
import string
import random
import bcrypt
passlen = 30
letters = string.ascii_letters
@ilyaevseev
ilyaevseev / passwd-auth-script.sh
Created April 23, 2022 23:49
External password authorization script for OpenVPN server
#!/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
@ilyaevseev
ilyaevseev / rsnap.sh
Last active November 28, 2021 23:40
Rsnap - do periodic incremental snapshots using Rsync and ls4sweep.
#!/bin/sh
Fail() {
logger -p "user.err" -t "rsnap" -s "$@";
#echo "$@" | mail -s "rsnap failed on $(hostname -f)" admins
exit 1
}
#====== Parse command line =================================
@ilyaevseev
ilyaevseev / find-proxmox-macaddr-dups.pl
Created November 21, 2021 21:39
Find MAC address dups in Proxmox environment, happen after VM/CT cloning
#!/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";