Skip to content

Instantly share code, notes, and snippets.

@whitekid
whitekid / kvm_vm.sh
Last active December 17, 2015 01:09
KVM 인스턴스 생성 스크립트
#!/bin/bash
set -e
function usage(){
echo "Usage: `basename $0` [domain]"
echo " -m memory as Mb"
echo " -s disk as Gb"
echo " -n comma separated network"
echo " -f first delete image file"
echo
@whitekid
whitekid / gsm.sh
Last active December 17, 2015 04:49
git submodule commit / push script
#!/bin/bash
# submodule commit/push
set -e
submodules=`git submodule status | awk '{print $2}'`
command="$1"
shift
args="$@"
@whitekid
whitekid / os-clear.sh
Last active December 17, 2015 08:38
OpenStack scripts
#!/bin/bash
PURGE='apt-get -y --auto-remove purge'
$PURGE python-keystoneclient
$PURGE nova-common
$PURGE quantum-common
$PURGE openstack-dashboard apache2
$PURGE cinder-common
$PURGE glance-common
$PURGE openvswitch-common
@whitekid
whitekid / block_moin_ddos.sh
Created May 16, 2013 05:06
moinmoin에 계정 생성을 지속적으로 하는 그 아이피 차단하는 스크립트
#!/usr/local/bin/bash
patterns+='?action=newaccount '
access_file='/usr/local/www/wiki/.htaccess'
ips_tmp=`mktemp`
trap 'on_exit; exit' SIGINT SIGQUIT EXIT
function on_exit(){
rm -f $ips_tmp
@whitekid
whitekid / os-router-move.sh
Created May 24, 2013 10:25
l3 agent를 특정 네트워크 노드로 옮기는 스크립트
#!/bin/bash
# os-router-move.sh <router-name> <host-name>
set -e
target_router=$1
target_node=$2
function usage(){
echo "Usage: `basename $0` ROUTER-NAME TARGET-NETWORK-NODE"
}
@whitekid
whitekid / aes.py
Created May 30, 2013 13:54
MySQL aes_encrypt compatible encrypt/decrypt function
def aes_encrypt(data, key):
"""MySQL aes_encrypt compatible encrypt function"""
import mcrypt
import binascii
m = mcrypt.MCRYPT('rijndael-128', 'ecb')
m.init(key)
# MySQL은 여기다 padding을 붙여서 진행하니까...
@whitekid
whitekid / aes.php
Created May 30, 2013 13:55
MySQL aes_encrypt compatible encrypt/decrypt function
static public function aes_encrypt($data, $key){
$expected_length = 16 * (floor(strlen($data) / 16) +1);
$padding_length = $expected_length - strlen($data);
$data = $data . str_repeat(chr($padding_length), $padding_length);
$enc = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_ECB);
return strtoupper(bin2hex($enc));
}
static public function aes_decrypt($data, $key){
// bin2hex의 역 함수가 php는 없어서 새로 만듦
define :generate_ssh_keys, :user_account => nil do
username = params[:user_account]
raise ":user_account should be provided." if username.nil?
Chef::Log.debug("generate ssh skys for #{username}.")
execute "generate ssh skys for #{username}." do
user username
creates "/home/#{username}/.ssh/id_rsa.pub"
@whitekid
whitekid / screenrc
Last active December 21, 2015 08:19
screen.rc
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
defscrollback 1000
@whitekid
whitekid / moin_spam_clear.sh
Last active December 21, 2015 10:29
moinmoin wiki spam clear script alias가 없는 사용자는 무조건 날린다. ㅎㅎ
#!/usr/bin/env bash
wiki_dir=/usr/local/www/wiki
cd $wiki_dir
# clear pages
rm -rf trash
mkdir trash
moin --config-dir=$wiki_dir --wiki-url=http://wiki.woosum.net maint cleanpage | bash