Created
November 8, 2016 11:23
-
-
Save miso4ru/85a6afa6f11232d9a6992dcf1103dcf5 to your computer and use it in GitHub Desktop.
base shellscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
SCRIPT_NAME=`basename $0` | |
PARENT_PATH=$(cd $(dirname $0);pwd) | |
DATE=`date +"%Y%m%d"` | |
YEATERDAY=`date --date "yesterday" +"%Y%m%d"` | |
############################################# | |
# AWS CLIs param | |
############################################# | |
export AWS_ACCESS_KEY_ID= | |
export AWS_SECRET_ACCESS_KEY= | |
export AWS_DEFAULT_REGION=ap-northeast-1 | |
export AWS_DEFAULT_OUTPUT=json | |
############################################# | |
# Usage (command options) | |
############################################# | |
function usage { | |
cat <<EOF | |
$SCRIPT_NAME is hogehoge | |
Usage: | |
$SCRIPT_NAME [<options>] | |
Options: | |
--help, -h print this | |
--debug, -d debug mode | |
EOF | |
} | |
############################################# | |
# functions | |
############################################# | |
# 続行確認 | |
function question { | |
echo "適用しますか: [Y/n]" | |
read ANSWER | |
case $ANSWER in | |
"Y" | "y" | "yes" | "Yes" | "YES") | |
;; | |
*) | |
exit 0 | |
;; | |
esac | |
} | |
############################################# | |
# main | |
############################################# | |
# 引数チェック(あれば) | |
if [ $# -eq 0 ]; then | |
echo "Error: 何か引数入れろ" | |
usage | |
exit 1; | |
fi | |
# コマンドオプションの処理 | |
while [ $# -gt 0 ]; | |
do | |
case ${1} in | |
--debug|-d) | |
set -x | |
;; | |
--help|-h) | |
usage | |
exit 0 | |
;; | |
*) | |
echo "何も指定なし" | |
;; | |
esac | |
shift | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment