Files
discord-stock-bot/setup-unraid.sh
Michael Simard 584ad2a4f4 Add market close updates and update deployment path for Compose Manager
Bot enhancements:
- Add scheduled update at market close (4:00 PM ET on trading days)
- Implement is_trading_day() method to check weekdays/holidays
- Market close update sends PYPL price at end of trading day

Deployment changes:
- Update all scripts to use Docker Compose Manager plugin path
- New path: /boot/config/plugins/compose.manager/projects/discord-stock-bot
- Container now integrates with Unraid Docker UI Compose section
- Update documentation with plugin integration details

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 18:57:13 -06:00

83 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# setup-unraid.sh - Initial Unraid setup for git-based deployment
set -e
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
REMOTE_PATH="/boot/config/plugins/compose.manager/projects/discord-stock-bot"
echo "Setting up Unraid server for git-based deployment..."
echo ""
# Setup SSH config on Unraid for git access
echo "1. Configuring SSH for git.michaelsimard.ca..."
ssh ${UNRAID_HOST} bash << 'EOF'
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Add SSH config for git server
if ! grep -q "git.michaelsimard.ca" ~/.ssh/config 2>/dev/null; then
cat >> ~/.ssh/config << 'SSHCONFIG'
Host git.michaelsimard.ca
Port 28
SSHCONFIG
chmod 600 ~/.ssh/config
echo "SSH config updated"
else
echo "SSH config already contains git.michaelsimard.ca"
fi
# Add host key
ssh-keyscan -p 28 git.michaelsimard.ca >> ~/.ssh/known_hosts 2>/dev/null || true
echo "Host key added to known_hosts"
EOF
echo ""
echo "2. Checking for SSH key on Unraid..."
ssh ${UNRAID_HOST} bash << 'EOF'
if [ ! -f ~/.ssh/id_rsa ] && [ ! -f ~/.ssh/id_ed25519 ]; then
echo "No SSH key found. Generating ed25519 key..."
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -C "unraid@discord-bot"
echo ""
echo "=== PUBLIC KEY - Add this to your Gitea account ==="
cat ~/.ssh/id_ed25519.pub
echo "=== END PUBLIC KEY ==="
echo ""
echo "Add this key at: https://git.michaelsimard.ca/user/settings/keys"
echo "Press Enter when done..."
read
else
echo "SSH key exists"
if [ -f ~/.ssh/id_ed25519.pub ]; then
cat ~/.ssh/id_ed25519.pub
elif [ -f ~/.ssh/id_rsa.pub ]; then
cat ~/.ssh/id_rsa.pub
fi
fi
EOF
echo ""
echo "3. Testing git access..."
if ssh ${UNRAID_HOST} "git ls-remote git@git.michaelsimard.ca:msimard/discord-stock-bot.git HEAD" &>/dev/null; then
echo "✓ Git access successful"
else
echo "✗ Git access failed. Ensure SSH key is added to Gitea"
exit 1
fi
echo ""
echo "4. Creating .env file on Unraid..."
if ssh ${UNRAID_HOST} "[ -f ${REMOTE_PATH}/.env ]"; then
echo ".env already exists on Unraid"
else
echo "Copying local .env to Unraid..."
ssh ${UNRAID_HOST} "mkdir -p ${REMOTE_PATH}"
scp .env ${UNRAID_HOST}:${REMOTE_PATH}/.env
echo "✓ .env copied"
fi
echo ""
echo "=== Setup Complete ==="
echo "Run './deploy.sh' to deploy the bot"