Skip to content

Instantly share code, notes, and snippets.

@youhey
youhey / postgresql_vacuum.sh
Created September 20, 2012 02:56
PostgreSQLのVACUUM
#!/bin/sh
set -e
set -u
POSTGRESQLUSER="postgres"
POSTGRESQLHOST="localhost"
LOCKFILE="/var/run/postgresql_vacuum.lock"
RETRIES=3
@youhey
youhey / postgresql-backup.sh
Created September 20, 2012 02:58
PostgreSQLのバックアップ
#!/bin/sh
set -e
set -u
POSTGRESQLUSER="postgres"
POSTGRESQLHOST="localhost"
BACKUPDIR="/srv/postgresql-backup-datastore"
# 25 days (24 * 25 = 600 hours)
@youhey
youhey / contents-backup.sh
Created September 20, 2012 02:59
コンテンツのバックアップ
#!/bin/bash
set -e
set -u
BACKUPDIR="/srv/contents-backup-datastore"
# 25 days (24 * 25 = 600 hours)
SAVED=600
TARGETS=("/path/to/1st" "/path/to/2nd")
@youhey
youhey / gist:3753725
Created September 20, 2012 03:04
PostgreSQLデータベースサーバ上で稼働しているデータベースの名前を一覧表示
psql --user=postgres --list --tuples-only --pset="format=unaligned" --pset="fieldsep=," | sed 's!^postgres=CTc/postgres$!!g' | cut --delimiter="," --fields=1 | sed -e 's/^template[01]$//g' -e '/^$/d'
@youhey
youhey / gist:3753759
Created September 20, 2012 03:14
salt係数のリストをもとに、Perlのcrypt関数の動作を確認
perl -ane 'printf("%s\n", crypt("opensesame", $F[0]))' salt.txt
@youhey
youhey / gist:3753761
Created September 20, 2012 03:15
salt係数のリストをもとに、PHPのcrypt関数の動作を確認
php -r '$f = file("salt.txt"); foreach($f as $r) echo crypt("opensesame", trim($r)), PHP_EOL;'
@youhey
youhey / gist:3753767
Created September 20, 2012 03:16
salt係数のリストをもとに、Rubyのcrypt関数の動作を確認
ruby -ane 'puts "opensesame".crypt($F[0]);' salt.txt
@youhey
youhey / crypt.c
Created September 20, 2012 03:18
cryptライブラリの動作確認
#include <crypt.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
if (argc < 3) {
fprintf(stderr, "%s [string] [salt]\n", argv[0]);
exit(1);
}
@youhey
youhey / webdav-useradd.sh
Created September 20, 2012 03:52
特定環境のWebDAVでユーザとディレクトリを作成
#!/bin/sh
set -e
set -u
WEBDAV_PATH="/var/www/WebDAV"
WEBDAV_URL="https://www.example.com/WebDAV/"
HTPASSWD=".htpasswd"
PASSWORD_LENGTH=16
@youhey
youhey / limited-scp-useradd.sh
Created September 20, 2012 03:58
rsshでchrootなどアクセス制限したSCP専用ユーザの追加
#!/bin/sh
set -u
INITIAL_GROUP="users"
INITIAL_SHELL="/usr/bin/rssh"
SSHTYPE="rsa"
RSSH_CONFIG="/etc/rssh.conf"
RSSH_SKELETON="/var/rssh_skeleton"