← back to Animate Museum Posts
setup.sh
67 lines
#!/bin/bash
echo "Museum Art Bot Setup Script"
echo "==========================="
if [ ! -f .env ]; then
echo "Creating .env file from template..."
cp .env.example .env
echo "Please edit .env file with your API credentials"
fi
echo "Installing dependencies..."
npm install
echo "Creating required directories..."
mkdir -p output
mkdir -p logs
echo ""
echo "Testing configuration..."
node src/index.js --test
if [ $? -eq 0 ]; then
echo "✓ Configuration test passed!"
else
echo "✗ Configuration test failed. Please check your .env file"
exit 1
fi
echo ""
echo "Do you want to:"
echo "1) Run once now"
echo "2) Set up system cron job (runs every 6 hours)"
echo "3) Run continuously with built-in scheduler"
echo "4) Exit"
read -p "Choose option (1-4): " choice
case $choice in
1)
echo "Running once..."
node src/index.js --once
;;
2)
echo "Setting up system cron job..."
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd)/src/index.js"
CRON_CMD="0 */6 * * * cd $(pwd) && /usr/bin/node $SCRIPT_PATH --once >> $(pwd)/logs/cron.log 2>&1"
(crontab -l 2>/dev/null | grep -v "animatemuseumposts"; echo "$CRON_CMD") | crontab -
echo "Cron job installed! It will run every 6 hours."
echo "To view cron jobs: crontab -l"
echo "To remove: crontab -l | grep -v animatemuseumposts | crontab -"
;;
3)
echo "Starting continuous scheduler..."
node src/index.js
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option"
exit 1
;;
esac