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 | |
# * script is executed by root | |
# * will detach from current session | |
su -p user <<"EOF" | |
/path/to/app -o option1 > /path/to/app.log 2> /path/to/app-errors.log & | |
echo $! > /path/to/app.pid | |
EOF |
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/env ruby | |
require 'timeout' | |
def exec_with_timeout(cmd, timeout) | |
r,w = IO.pipe | |
pid = Process.spawn(cmd, {[:err, :out] => w, :pgroup => true}) | |
w.close | |
[begin |
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
# Usage: | |
# | |
# TCPSocket.socks_server = "socks-proxy.example.net" | |
# TCPSocket.socks_port = 8888 | |
require 'socket' | |
class TCPSocket | |
alias :direct_to :initialize |
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
class Foo | |
def schedule | |
# crontab like string, e.g. "5 * * * *" | |
end | |
def run?(time) | |
fields = schedule.split(/\s+/) | |
!%w(min hour day month wday).map.with_index do |name, i| | |
fields[i].gsub(/(?:(?![\d\/\*,]).)*/, '').split(',').select do |v| |
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
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 443 -m owner --uid-owner root -j RETURN | |
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 443 -m owner --uid-owner nginx -j RETURN | |
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3130 |