Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 17:01 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@ilyaevseev
ilyaevseev / ffmpeg-nvenc-parbench.sh
Created October 18, 2018 12:13
Benchmark concurrent ffmpeg-nvenc instances.
#!/bin/sh
test $# = 1 || { echo "Usage: ${0##*/} num-loops"; exit 1; }
D="/tmp/${0##*/}"
F="$HOME/lord-inquisitor.mp4"
rm -rf "$D" || :
mkdir -p "$D"
@ilyaevseev
ilyaevseev / update-resolv-conf.sh
Created June 29, 2018 20:01
Quick and dirty update-resolv-conf for OpenVPN under Fedora
#!/bin/sh
test -z "$dev" && exit 0
DNS="$(printenv | awk '/^foreign_option_.*=dhcp-option DNS / { print $NF; exit; }')"
test -z "$DNS" && exit 0
# Error: Reading applied connection from device 'tun0' (/org/freedesktop/NetworkManager/Devices/6) failed: Device is not activated
# When called manually after connection esablished: removes all routes!
@ilyaevseev
ilyaevseev / otrs-new-package.sh
Created June 18, 2018 16:36
Check, install, update OTRS package under CentOS 7. Requires lftp.
#!/bin/sh
FPATH="$(lftp -e 'cls -q -1 -D --sort=date /pub/otrs/RPMS/rhel/7/otrs*.noarch.rpm; exit' http://ftp.otrs.org/ 2>&1 | tail -1)"
LATEST="${FPATH##*/}" #"
LATEST="${LATEST%.rpm}"
CURRENT="$(rpm -q otrs)"
case "$1" in
install|reinstall ) yum "$1" "http://ftp.otrs.org/$FPATH" ;;
geturl ) echo "http://ftp.otrs.org/$FPATH" ;;
@ilyaevseev
ilyaevseev / ldap-replicas-checksum-compare.sh
Last active June 18, 2018 16:34
Quick and dirty Zabbix check for replication status between OpenLDAP master and slave. Should be called on slave.
#!/bin/sh
CONFIG="/etc/openldap/slapd.d/cn=config/olcDatabase={2}hdb.ldif"
Return() { echo $@; exit; }
test -s "$CONFIG" || Return "BAD_CONF"
URL="$(sed -n 'H; ${ x; s/\n//; s/\n //g; p}' "$CONFIG" | awk 'match($0, "provider=([^ ]+)", m) { print m[1] }')" ; test -z "$URL" && Return "BAD_URL" #'
DN="$(sed -n 'H; ${ x; s/\n//; s/\n //g; p}' "$CONFIG" | awk 'match($0, "binddn=\"([^ ]+)\"", m) { print m[1] }')" ; test -z "$DN" && Return "BAD_DN" #'
@ilyaevseev
ilyaevseev / teamcheck.sh
Last active June 1, 2018 16:17
Zabbix check for status of aggregated links under Linux
#!/bin/sh
FAILED=""
SLAVES_COUNTER=""
cd /sys/class/net/
Check_iface() {
local master="$1" slave="$2" mask="$3"
#echo "DEBUG: check_iface $master:$slave"
@ilyaevseev
ilyaevseev / Cloudflare-Nginx-RealIP-Update.sh
Created May 30, 2018 13:59
/etc/cron.daily/Cloudflare-Nginx-RealIP-Update -- update Nginx config by list of Cloudflare frontends.
#!/bin/sh -e
# https://support.cloudflare.com/hc/en-us/articles/200170706-How-do-I-restore-original-visitor-IP-with-Nginx-
STATEDIR="${1:-/var/log/${0##*/}}"
mkdir -p "$STATEDIR"
CONFDIR="${2:-/etc/nginx/conf.d}"
test -d "$CONFDIR" || { echo "missing confdir: $CONFDIR" 1>&2; exit 1; }
@ilyaevseev
ilyaevseev / squidcheck.sh
Created April 14, 2018 07:34
Check that Squid is crashed and restart it.
#!/bin/sh
Logger() { level="$1"; shift; logger -t "${0##*/}" -p "user.$level" -- "$@"; return 0; }
test -f "/var/run/squid/squid.pid" || exit 0
pgrep -F "/var/run/squid/squid.pid" | grep -q '' &&
Logger info "Squid OK" &&
exit 0
@ilyaevseev
ilyaevseev / chelsio-make-nic-fedora27-errors.log
Created March 7, 2018 13:28
Try to build Chelsio drivers under Fedora27
$ LANG=C make nic
Building for kernel 4.15.6-300.fc27.x86_64
Building for kernel 4.15.6-300.fc27.x86_64
##################################################
# Building Network Drivers #
##################################################
Preparing for build ...
#### Preparing cxgb4 ####
#!/bin/bash -ue
#
# Sets up mq+$shed combo for given interface.
#
# NB! To not degrade upload speeds, fq should only be used on kernels >= 3.19:
# https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9878196578286c5ed494778ada01da094377a686
#
if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then
echo "usage: $0 interface scheduler" >&2
@ilyaevseev
ilyaevseev / Kerio-connect-nginx.conf
Last active October 20, 2021 17:02
Copy Kerio Connect backups to Hetzner backup server.
server {
listen 80;
listen [::]:80;
server_name mail.remotesrv.ru;
location /.well-known { alias /var/www/letsencrypt/.well-known; }
location / { return 308 https://mail.remotesrv.ru$request_uri; }
}