today.isangjeong/app/gen-config.sh
2025-02-02 13:59:25 +09:00

32 lines
819 B
Bash

#!/bin/bash
# Required environment variables
required_vars=("BOT_ROOT" "BOT_INSTAGRAM_ID" "BOT_INSTAGRAM_PASSWD" "BOT_INSTAGRAM_TOTP" "BOT_KEY" "BOT_WEBHOOK_URL")
# Check for missing environment variables
missing_vars=()
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
missing_vars+=("$var")
fi
done
if [ ${#missing_vars[@]} -ne 0 ]; then
echo "Error: Missing required environment variables:"
printf '%s\n' "${missing_vars[@]}"
exit 1
fi
# Generate config.json
cat > config.json << EOF
{
"ROOT": "${BOT_ROOT}",
"INSTAGRAM_ID": "${BOT_INSTAGRAM_ID}",
"INSTAGRAM_PASSWORD": "${BOT_INSTAGRAM_PASSWD}",
"INSTAGRAM_TOTP": "${BOT_INSTAGRAM_TOTP}",
"KEY": "${BOT_KEY}",
"WEBHOOK_URL": "${BOT_WEBHOOK_URL}"
}
EOF
echo "Successfully generated config.json"