Skip to content

Instantly share code, notes, and snippets.

@yamamoto-febc
Created October 11, 2017 01:48
Show Gist options
  • Save yamamoto-febc/a9bd55ca02c992eef4c0819dc0edb088 to your computer and use it in GitHub Desktop.
Save yamamoto-febc/a9bd55ca02c992eef4c0819dc0edb088 to your computer and use it in GitHub Desktop.
さくらのクラウド スタートアップスクリプトでのベストプラクティス(motdで通知編) ref: http://qiita.com/yamamoto-febc/items/d3b498f53c7d973f3e59
_motd() {
LOG=$(ls /root/.sacloud-api/notes/*log)
case $1 in
start)
echo -e "\n#-- Startup-script is \\033[0;32mrunning\\033[0;39m. --#\n\nPlease check the log file: ${LOG}\n" > /etc/motd
;;
fail)
echo -e "\n#-- Startup-script \\033[0;31mfailed\\033[0;39m. --#\n\nPlease check the log file: ${LOG}\n" > /etc/motd
exit 1
;;
end)
cp -f /dev/null /etc/motd
;;
esac
}
# 開始時
_motd start
# エラー発生時
_motd fail
# 終了時
_motd end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment