Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 22:09 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@ilyaevseev
ilyaevseev / tcp3.pl
Last active August 29, 2015 14:17
Proxy between single uplink and multiple clients. Implements http://ru-root.livejournal.com/2617418.html -- Proxy transmits requests from all clients to uplink connection. All responses are sent to all clients.
#!/usr/bin/perl
use strict;
use warnings;
# apt-get install libio-async-loop-epoll-perl
use IO::Async::Loop::Epoll;
use IO::Async::Socket;
use constant {
@ilyaevseev
ilyaevseev / rhodecode2mirror.sh
Created June 29, 2015 10:02
Backup all Git and Mercirial repos from Rhodecode/Kallithea to remote server
#!/bin/sh
M="admins"
L="/tmp/hg2mirror.log"
E="/tmp/hg2mirror.err"
TOPDIR="/var/www/rhodecode/"
try_mercurial() {
test -d "$1/.hg" || return 1
@ilyaevseev
ilyaevseev / cronhourly-check-df-centos.sh
Created July 3, 2015 12:47
Check free space on server and in OpenVZ containers
#!/bin/sh
( df -h | tail -n +2
df -i | tail -n +2
awk '/^\/vz/ {print $2}' /proc/mounts | xargs -r df -h | tail -n +2
awk '/^\/vz/ {print $2}' /proc/mounts | xargs -r df -i | tail -n +2
) | grep -v ^none | egrep -v ' [ 1234567 ][0-9]% ' | sort | uniq \
| mail -E -s 'Check-df warning' admins
@ilyaevseev
ilyaevseev / copy4timeinterval.sh
Created July 24, 2015 21:26
Find files in specific datetime interval, then copy to selected folder.
#!/bin/sh
test $# = 2 || test $# = 3 || { echo "Usage: $0 start-time end-time [dest-folder]"; exit; }
Fail() { echo "ERROR: $@" 1>&2; exit 1; }
NOW="$(date +%s)"
START="$(date +%s -d "$1" 2>/dev/null)"; test -z "$START" && Fail "wrong start-time: $1"
FINISH="$(date +%s -d "$2" 2>/dev/null)"; test -z "$FINISH" && Fail "wrong end-time: $2"
DESTDIR="$3"
@ilyaevseev
ilyaevseev / xen2ovz.sh
Created July 25, 2015 02:54
Convert Xen VM to Openvz CT
#!/bin/sh
CTID="123"
NAME="mysite"
HOSTNAME="mysite.org"
IPADDR="1.2.3.4"
OLD_IPADDR="5.6.7.8"
SRCHOST="root@mysite.org::RootDir"
export RSYNC_PASSWORD="JustPassMe"
@ilyaevseev
ilyaevseev / InnoBackup.sh
Last active July 24, 2018 14:40
Innobackup usage sample.
#!/bin/sh
BASEDIR="/var/lib/mysqlbackup"
TSTAMP="$(date +%Y.%m.%d_%H%M%S)"
DESTDIR="$BASEDIR/new"
PREVDIR="$BASEDIR/full"
LOGSDIR="$BASEDIR/logs"
LOGFILE="$LOGSDIR/$TSTAMP.log"
Fail() {
@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 / dom0-firewall-init.sh
Created January 21, 2016 05:09
Xen vSwitch configuration sample.
#!/bin/sh
IP="/sbin/ip"
EXT_IFACE="$($IP route get 8.8.8.8 | grep ' src ' | sed -e 's,.* dev ,,' -e 's, .*,,')"
EXT_IPADDR="$($IP addr ls dev $EXT_IFACE | grep ' inet ' | sed -e 's,.* inet ,,' -e 's,/.*,,')"
# Default filter policy..
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
@ilyaevseev
ilyaevseev / webcrawler.js
Created January 26, 2016 20:11 — forked from amoilanen/webcrawler.js
Simple PhantomJS-based web crawler library
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 2012
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler"
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist
(function(host) {
function Crawler() {
this.visitedURLs = {};
};
#!/bin/sh
# http://vk.com/wall403284_81744
SRCURL="http://transport.orgp.spb.ru/Portal/transport/internalapi/gtfs/realtime/vehicle?bbox=30.32,59.84,30.33,59.85&transports=bus,trolley,tram,ship&routeIDs=1329"
DESTURL="ftp://volokhonsky:password@kremlin.spb.ru/folder1"
MAILTO="volokhonsky@kremlin.spb.ru"
MYNAME="${0##*/}"
LOGFILE="/tmp/$MYNAME.log"
FNAME="$(date +%Y-%m-%d_%H%M%S).bin"