#!/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 if [ ! -d "temp" ]; then mkdir temp fi if [ ! -d "temp/auth" ]; then mkdir temp/auth fi # If doesn't have temp/cookies.json, create it if [ ! -f "./temp/auth/cookies.json" ]; then mkdir temp/auth python3 library/init-auth.py fi echo "Successfully generated config.json"