You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
629 B
19 lines
629 B
#!/bin/bash
|
|
|
|
# 変数を呼び出し側に影響させないために関数化
|
|
function get_env_file_path() {
|
|
# スクリプト自身のディレクトリを取得
|
|
local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# 1つ上の階層にある .env ファイルを読み込む
|
|
local ENV_FILE="$SCRIPT_DIR/../.env"
|
|
echo $ENV_FILE
|
|
}
|
|
|
|
if [ -f $(get_env_file_path) ]; then
|
|
echo "Loading .env from $(get_env_file_path)"
|
|
export $(grep -v '^#' "$(get_env_file_path)" | xargs)
|
|
echo "環境変数を設定しました"
|
|
else
|
|
echo ".env ファイルが見つかりません: $(get_env_file_path)"
|
|
exit 1
|
|
fi
|
|
|