Skip to content

Instantly share code, notes, and snippets.

View dmytro's full-sized avatar

Dmytro Kovalov (uk: Дмитро Ковальов) dmytro

View GitHub Profile
@dmytro
dmytro / ssh-multi.sh
Created October 31, 2012 03:46
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
@dmytro
dmytro / generate_openvpn_config.sh
Last active March 19, 2023 12:21
Script for OpenVPN generate client config file.
#!/bin/bash
# Easy script to create OpenVPN client configuration with the user, pre-generating user's
# RSA key and certificate.
#
# Configuration template must exist in the same directory, with only missing part: certificates.
#
# (c) Dmytro Kovalov, 2015
#
cd $(dirname ${BASH_SOURCE[0]})
@dmytro
dmytro / run_root_remotely.sh
Created June 26, 2012 01:56
Various scripts
#!/bin/bash
:<<"=cut"
=head1 NAME
C<run_root_remotely> - use expect and sudo to deploy SSH key to remote
server root account and execute script on the remote via SSH as root
=head1 DESCRIPTION
@dmytro
dmytro / tmux_pwd.sh
Created November 22, 2012 06:15
Open Tmux panes in current directory
tmux_pwd () {
[ -z "${TMUX}" ] && return
TARGET=\-t$(tmux display-message -p "#S")
tmux set-window-option ${TARGET} default-path $PWD > /dev/null
(( sleep 300;
tmux set-window-option ${TARGET} default-path ~/Development > /dev/null; ) & ) > /dev/null 2>&1
}
alias pwd="\pwd; tmux_pwd"

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@dmytro
dmytro / gist:7887843
Last active November 8, 2018 11:14
Shell script for SYN flood DOS attacks prevention. Use sqlite3 to filter IP's
#!/bin/bash
SLEEP=120
MAX_CONN=20
MY_IP=0.0.0.0 # Configure your IP here
while true; do
(
echo "create table ips (ip string);"
echo 'begin transaction;'
netstat -an | grep -v ESTABLISHED | grep ${MY_IP}:80 | awk '{print $5}' | cut -f4 -d: | while read IP; do
@dmytro
dmytro / TikiWiki_Dockerfile
Last active February 24, 2016 01:47
Dockerize PHP application for safe serving RO web site. Server several LAMP sites from Docker containers read-only. MySQL dumps are loaded at the time of containers start.
FROM tutum/lamp:latest
RUN rm -fr /app
ADD src /app
RUN chown www-data -R /app/tiki
ADD kraiany.dump.bz2 /kraiany.dump.bz2
ADD prepare.sh /prepare.sh
@dmytro
dmytro / rip_dvd.sh
Last active February 4, 2016 01:36
Rip and encode DVD
#!/bin/bash
# (c) Dmytro Kovalov, 2016.
#
# Converts VIDEO_TS folder of the DVD stored on disk into VOB file for each of the titles
# and converts them to H264 (using separate to264 script.)
# Tested on Debian Linux with:
# lsdvd -V
# lsdvd 0.16 - GPL Copyright (c) 2002, 2003, 2004, 2005 "Written" by Chris Phillips <acid_kewpie@users.sf.net>
# mplayer -V
# MPlayer svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer Team
@dmytro
dmytro / nfc_checks.yml
Created December 12, 2012 08:37
checks configuration for Nagios for Couchbase
:vb_active_num:
:namespace: Wizcorp::Couchbase
:class: BucketStats
:function: :avg # :avg, :sum, :none
:operator: :<
:rag: [1024,1024,1025]
@dmytro
dmytro / rag.rb
Created December 12, 2012 08:00
RAG Checks for Nagios
def rag
rag = -1
res = @connection.send(@key[:name]).send(@key[:function].to_sym)
thresholds = @key[:rag].reverse
thresholds.each_index do |idx|
val = thresholds[idx]
rag = idx if res.send(@key[:operator].to_sym, val)
end