Skip to content

Instantly share code, notes, and snippets.

@mkouhei
mkouhei / set-vrrp-vyatta.sh
Created March 22, 2012 04:24
Set 20 Virtural IP addresses per VRID for mapping NAT of Vyatta.
#!/bin/vbash
SET=${vyatta_sbindir}/my_set
COMMIT=${vyatta_sbindir}/my_commit
startip=2
delta=20
count=0
tip=0
prio=100
while getopts "b" flag; do
@mkouhei
mkouhei / diff optparse, argparse
Created April 22, 2012 03:51
Change optparse to argparse in command.py of tonicdnscli
diff --git a/src/tonicdnscli/command.py b/src/tonicdnscli/command.py
index d0a4f35..bf82292 100644
--- a/src/tonicdnscli/command.py
+++ b/src/tonicdnscli/command.py
@@ -18,105 +18,180 @@
"""
-def parse_options():
- import sys
@mkouhei
mkouhei / generate_list.py
Created September 12, 2012 02:39
generate tonicdnscli input file: Firstly tonicdnscli get --domian example.org > registrered_list.txt, then `domain` set `.example.org`, so run this script.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
domain = '.example.org'
def is_hostname(string):
pat_hostname = re.compile('^[a-zA-Z0-9]+([0-9a-zA-Z\-]+)$')
if pat_hostname.search(string):
return True
@mkouhei
mkouhei / keyimport.sh
Created September 24, 2012 05:43
importing signed your gpg public key.
#!/bin/sh
# MYKEY is 0x + $(gpg --list-keys mkouhei | awk '/pub\s*4096R/ { print $2}' | cut -d / -f 2)
MYKEY="0x0000000"
#KEYSERVER="18.92.0.144"
KEYSERVER="202.12.30.53"
test -z $1 && exit 1
test ! -f $1 && exit 2
KEYFILE=$1
@mkouhei
mkouhei / update_keyring.sh
Created September 24, 2012 05:45
update syncing from caff to gpg key ring
#!/bin/sh
gpg --import ~/.caff/gnupghome/pubring.gpg
@mkouhei
mkouhei / vpn.sh
Created September 27, 2012 14:33
Update resolv.conf when vpn connect and disconnect
#!/bin/sh
remove_ns() {
sudo sed -i '/nameserver xxx.xxx.xxx.xxx/ d' /etc/resolv.conf
}
sudo sed -i '/search/a nameserver xxx.xxx.xxx.xxx' /etc/resolv.conf
trap remove_ns 2
sudo openvpn --config ~/work/vpnclient-conf/gateway.ovpn
@mkouhei
mkouhei / watchdog_httpd.py
Created December 20, 2012 13:09
watchdog httpd server on another host , when detect fall down, boot self httpd server.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
from pyquery import PyQuery
from lxml import etree
import commands
from time import sleep
import syslog
@mkouhei
mkouhei / execute result
Created April 16, 2013 15:23
check read state with web storage of HTML5.
Web storage is supported readstate.js:3
Array[10]
readstate.js:14
Array[5]
readstate.js:15
0 has been read readstate.js:22
1 has been read readstate.js:22
2 has been read readstate.js:22
3 is unread readstate.js:19
4 is unread readstate.js:19
@mkouhei
mkouhei / gist:1cf5eabb2ffd938f41a9
Last active January 4, 2016 10:09
Go関連のパッケージ化

Upstreamが

Gitリポジトリの場合

$ git clone <url>/hoge.git
$ cd hoge
@mkouhei
mkouhei / gist:588bed8d6bdecda93469
Last active August 29, 2015 13:57
Plan of Auto building debian package

Prepare base image for clean build

  1. cowbuilder --create
  2. Append deb-src of sid, snapshot, backports, deb and deb-src of custom to apt line.

Case already packaged in Sid

  1. Give package name