Repository navigation
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·73 lines (57 loc) · 2.24 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·73 lines (57 loc) · 2.24 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# =============================================================================
# OCI One-Click Update & Upgrade Script
# This script updates the OS, performs a backup, and updates all containers.
# =============================================================================
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
DEPLOY_ROOT="${DEPLOY_ROOT:-/opt/deploy}"
main() {
echo -e "${GREEN}Starting Full System Update & Upgrade...${NC}"
# 1. Perform Backup
if [ -f "$DEPLOY_ROOT/scripts/backup.sh" ]; then
echo -e "${YELLOW}[1/4] Performing safety backup...${NC}"
sudo bash "$DEPLOY_ROOT/scripts/backup.sh"
else
echo -e "${RED}Warning: Backup script not found at $DEPLOY_ROOT/scripts/backup.sh. Skipping backup...${NC}"
fi
# 2. Update OS Packages
echo -e "${YELLOW}[2/4] Updating OS packages...${NC}"
sudo apt update
sudo apt upgrade -y
# 3. Update Docker Containers
echo -e "${YELLOW}[3/4] Updating Docker containers...${NC}"
SERVICES=("db" "automation" "webserver" "storage" "proxy")
source "$DEPLOY_ROOT/scripts/utils.sh"
for service in "${SERVICES[@]}"; do
if [ -d "$DEPLOY_ROOT/$service" ]; then
echo -e "Updating $service..."
cd "$DEPLOY_ROOT/$service"
# Fix for Postgres 18+ data directory structure
if [ "$service" == "db" ]; then
migrate_postgres "$DEPLOY_ROOT"
fi
sudo docker compose pull
sudo docker compose up -d
fi
done
# 4. Clean up
echo -e "${YELLOW}[4/4] Cleaning up old Docker images...${NC}"
sudo docker image prune -f
echo -e "${GREEN}================================================================${NC}"
echo -e "${GREEN}Update Completed Successfully!${NC}"
echo -e "${GREEN}================================================================${NC}"
if [ -f /var/run/reboot-required ]; then
echo -e "${RED}NOTE: A system reboot is required to complete some OS updates.${NC}"
echo -e "You can reboot by typing: ${YELLOW}sudo reboot${NC}"
else
echo -e "No system reboot is required."
fi
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi