Skip to content

Instantly share code, notes, and snippets.

View hotta's full-sized avatar

HOTTA, Michihide hotta

View GitHub Profile
@hotta
hotta / dotfiles.sh
Created March 21, 2024 05:23
指定したユーザーのドットファイルをまとめて収集する。
#!/bin/bash
# Gather dotfiles of specified users.
ARC=/tmp/dotfiles.tar
USERS=(user1 user2 user3)
sudo sh -c "tar cf $ARC /home/etl/.??*" || exit 1
for u in ${USERS[@]} ; do
echo $u
sudo sh -c "tar rf $ARC /home/$u/.??*" || exit 1
done
sudo gzip $ARC
@hotta
hotta / find-latest-files.sh
Last active February 28, 2024 05:50
Scans the directories immediate under /home and find the last updated files (excluding dot files).
#!/bin/bash
#
# /home/直下のディレクトリをスキャンし、ユーザーごとに最終更新ファイルを表示する(ドットファイルは除く)。
# 該当ファイルがない場合はディレクトリ名(ユーザー名)を表示する。
#
TMP_OUTPUT=/tmp/a.txt
if [ "$#" -eq 1 ]; then
TARGET="$1"
fi
cd /home
@hotta
hotta / lastlog.sh
Created February 13, 2024 01:20
display last login date for each users
#!/bin/bash
#
# display last login date for each users
#
for user in vagrant dirsrv dummy ; do
if ! id $user >& /dev/null ; then
echo -e "$user\tno such user"
continue
fi
LINE="$(LANG=C lastlog -u $user | tail -1)"
@hotta
hotta / Vagrantfile
Last active September 2, 2021 04:36
Vagrant TIPS
# Tune resolver settings to prevent from yum slow down (for use in Japan)
config.vm.provision "shell", inline: <<-SHELL
sudo nmcli con mod "System eth0" ipv4.ignore-auto-dns Yes ipv4.dns 8.8.8.8
sudo systemctl restart NetworkManager
echo "include_only=.jp" | sudo tee -a /etc/yum/pluginconf.d/fastestmirror.conf
SHELL
@hotta
hotta / .bashrc
Created September 1, 2021 23:40
Small TIPS on CentOS
# Enable git-bash-prompt
if [ ! -d $HOME/bash-git-prompt ]; then
git clone https://github.com/magicmonty/bash-git-prompt.git
fi
if [ -f "$HOME/bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
source $HOME/bash-git-prompt/gitprompt.sh
fi
@hotta
hotta / pgpool-check.sh
Created June 17, 2021 23:47
A script to monitor pgpool status
#!/bin/bash
MAILTO=mhotta@example.com
_INITDIR=~/.pgpool-check/init/
_CHECKDIR=~/.pgpool-check/current/
function _die {
echo $1
exit 1
}
@hotta
hotta / pg-persist.php
Last active June 17, 2021 23:51
Pgpool 通常稼働のため、Pgpool を定期的にポーリングしてDB接続を維持する
#!/usr/bin/php
<?php
//
// pg-persist.php
// pgpool ではクライアントからの接続がない場合は障害時でもフェイルオーバー
// しないため、DB接続を維持するため(だけ)のスクリプトを準備した。
// cron から起動する場合はバックグラウンド起動とすること。
// テスト側でのみ必要。
//
// https://www.php.net/manual/ja/ref.pdo-pgsql.connection.php
@hotta
hotta / Vagrantfile
Last active January 17, 2020 02:24
Vagrantfile with multiple NICs and additional storage enabled
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "private_network", ip: "192.168.56.13"
config.vm.network "private_network", ip: "172.16.32.4"
config.vm.network "private_network", ip: "172.16.0.7"
config.vm.hostname = "db2"
config.vm.synced_folder ".", "/vagrant", disabled: true
@hotta
hotta / build.gradle
Last active August 27, 2019 04:11
Gradle QuickStart
// Gradle QuickStart - 7.2. 基本的なJavaプロジェクト
// cf. http://gradle.monochromeroad.com/docs/userguide/userguide.html
// Gradle が使用する JRE
// システムの JDK/JRE。デフォルト以外の JDK を使用したい場合は
// JAVA_HOME 環境変数を調整する。
// Gradle が使用する Groovy
// Gradle 同梱の Groovy。システムの Groovy は参照されない。
@hotta
hotta / ib-csv-cleanup.sh
Created March 21, 2018 04:57
インターネットバンキングで取得した入出金明細のCSVをまともにするスクリプト
#!/bin/bash
cat $1 | \
nkf -Sw -Lu -Z4 -X | \
sed -e '1,5d' | \
head -n -2 | \
sed -e 's/","/\t/g'
-e 's/"//g' \
-e 's/フリカエ/振替/g' \
-e 's/コクミンネンキン/国民年金/g' \
-e 's/ホケンリヨウ/保険料/g' \