-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-typebot.sh
More file actions
executable file
·45 lines (34 loc) · 1.25 KB
/
update-typebot.sh
File metadata and controls
executable file
·45 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Typebot Security Update Script
# Run this weekly or when security updates are released
set -e
LOG_FILE="/var/log/typebot-updates.log"
DATE=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$DATE] Starting Typebot update..." >> "$LOG_FILE"
cd /opt/typebot
# Backup current configuration
cp docker-compose.yml "docker-compose.yml.backup-$(date +%Y%m%d-%H%M%S)"
cp .env ".env.backup-$(date +%Y%m%d-%H%M%S)"
# Pull latest images
echo "[$DATE] Pulling latest images..." >> "$LOG_FILE"
docker compose pull >> "$LOG_FILE" 2>&1
# Restart with new images
echo "[$DATE] Restarting services..." >> "$LOG_FILE"
docker compose down >> "$LOG_FILE" 2>&1
docker compose up -d >> "$LOG_FILE" 2>&1
# Wait for services
sleep 30
# Check if services are running
if docker compose ps | grep -q "Up"; then
echo "[$DATE] Update completed successfully!" >> "$LOG_FILE"
# Clean old backups (keep last 5)
ls -t docker-compose.yml.backup-* 2>/dev/null | tail -n +6 | xargs -r rm
ls -t .env.backup-* 2>/dev/null | tail -n +6 | xargs -r rm
else
echo "[$DATE] ERROR: Services failed to start!" >> "$LOG_FILE"
exit 1
fi
# Log current versions
echo "[$DATE] Current versions:" >> "$LOG_FILE"
docker compose images >> "$LOG_FILE" 2>&1
echo "[$DATE] Update completed!" >> "$LOG_FILE"