Skip to content

Instantly share code, notes, and snippets.

View lorentzca's full-sized avatar
🏕️
In the Woods.

Kohta Kunishima lorentzca

🏕️
In the Woods.
View GitHub Profile
@lorentzca
lorentzca / ghostblog_update.sh
Last active April 19, 2017 04:41
my ghostblog updater
#/bin/sh -x
# version
version="0.11.8"
# backup
cd /var/www/ghost
sudo tar cpf /tmp/ghost_snapshot_$(date +%Y%m%d%H%M).tar .
# download latest ghost
@lorentzca
lorentzca / mhamanager
Last active January 28, 2016 06:37
[WIP] mha-managerの起動スクリプト
#!/bin/bash
#
# chkconfig: - 58 74
# description: masterha_manager is master monitoring and running failover automatically in case of master down
# processname: masterha_manager
# pidfile: /var/lib/mysql/master1.pid
# config: /etc/masterha_default.cnf
# source profile
. /etc/profile
@lorentzca
lorentzca / kunishima.rb
Created January 21, 2016 10:46
集え我が一族
#!/usr/bin/ruby
require 'uri'
require 'open-uri'
require 'net/http'
open('http://data.iana.org/TLD/tlds-alpha-by-domain.txt') {|f|
f.each_line {|line|
next line if %r(^#) =~ line
url = "http://kunishima.#{line}"
@lorentzca
lorentzca / master_name_failover
Last active February 22, 2017 01:56
mhaフェイルオーバー時consulのカタログデータベースを書き換えるスクリプト
#!/usr/bin/env perl
# Copyright (C) 2011 DeNA Co.,Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@lorentzca
lorentzca / consul.conf
Last active January 18, 2016 05:49
consulドメインへの名前解決にdnsmasqを利用するための設定
server=/consul/127.0.0.1#8600
@lorentzca
lorentzca / consul
Last active January 18, 2016 05:56
install monit (centos)
check process consul
with pidfile "/var/run/consul.pid"
start program "/etc/init.d/consul start"
stop program "/etc/init.d/consul stop"
@lorentzca
lorentzca / install_consul.sh
Last active February 1, 2016 06:48
install consul (centos5)
#!/bin/sh
sudo yum install -y wget unzip
# add consul binary
wget --no-check-certificate -O /tmp/consul.zip https://releases.hashicorp.com/consul/0.6.0/consul_0.6.0_linux_amd64.zip
sudo unzip /tmp/consul.zip -d /usr/local/sbin
sudo rm -f /tmp/consul.zip
sudo chmod 755 /usr/local/sbin/consul
@lorentzca
lorentzca / install_mha4mysql-manager.sh
Last active February 2, 2016 02:39
install mha4mysq (centos5)
#!/bin/sh
# install depend packages
sudo yum install -y epel-release wget
sudo yum install -y perl-DBD-MySQL
sudo yum install --enablerepo=epel -y perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager
# install mha-node
wget --no-check-certificate -O /tmp/mha4mysql-node-0.56-0.el5.noarch.rpm https://72003f4c60f5cc941cd1c7d448fc3c99e0aebaa8.googledrive.com/host/0B1lu97m8-haWeHdGWXp0YVVUSlk/mha4mysql-node-0.56-0.el5.noarch.rpm
sudo rpm -ivh /tmp/mha4mysql-node-0.56-0.el5.noarch.rpm
@lorentzca
lorentzca / my_ami.json
Created January 7, 2016 03:19
create ami with packer
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
@lorentzca
lorentzca / my_box.json
Created January 7, 2016 02:03
Create a Vagrant Box from an existing Virtualbox image
{
"builders": [
{
"type": "virtualbox-ovf",
"source_path": "my_box.ova",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -h now"
}
],