-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-ghostfolio.sh
executable file
·52 lines (42 loc) · 1.59 KB
/
update-ghostfolio.sh
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
#!/bin/bash
# Copyright (C) 2025 Niklas Fuchshofer
#
# This script is licensed under the GNU General Public License Version 3 or
# any later version.
# See LICENSE file for more details.
#
# -----------------------------------------------------------------------------
# Script to update Ghostfolio and related services
# Variables
COMPOSE_FILE="/root/ghostfolio/docker/docker-compose.yml"
LOG_FILE="/root/update-ghostfolio/update-ghostfolio.log"
TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
# Functions
# Function to log messages with a timestamp
log() {
echo "[${TIMESTAMP}] $1" | tee -a "$LOG_FILE"
}
# Function to log errors and exit the script
error() {
log "ERROR: $1"
exit 1
}
# Script start
log "Starting Ghostfolio Update Script..."
# 1. Docker Compose Pull
log "Pulling latest Docker Images..."
docker compose -f "$COMPOSE_FILE" pull || error "Docker Compose Pull failed!"
# 2. Docker Compose Up
log "Starting Docker Compose..."
docker compose -f "$COMPOSE_FILE" up -d || error "Docker Compose Up failed!"
# 3. Docker Image Prune
log "Removing unused Docker Images..."
docker image prune -a -f || log "Docker Image Prune failed (no problem if no images were removed)."
# 4. Docker Update (Restart Policy)
log "Updating Restart Policy for Ghostfolio Container..."
docker update --restart unless-stopped ghostfolio || error "Docker Update for Ghostfolio failed!"
docker update --restart unless-stopped gf-postgres || error "Docker Update for gf-postgres failed!"
docker update --restart unless-stopped gf-redis || error "Docker Update for gf-redis failed!"
# Script end
log "Ghostfolio Update completed."
exit 0