Skip to content

Commit 1c2bce9

Browse files
chore: fixed installation script
1 parent af4b347 commit 1c2bce9

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

setup.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ install() {
178178
log "Installing SystemGuard from Git repository..."
179179

180180

181-
log "Removing any existing installation in the directory $EXTRACT_DIR/SystemGuard-dev ..."
182-
if [ -d "$EXTRACT_DIR/SystemGuard-*" ]; then
183-
rm -rf "$EXTRACT_DIR/SystemGuard-*"
181+
log "Removing previous installation of SystemGuard, if any..."
182+
if [ -d "$EXTRACT_DIR" ]; then
183+
rm -rf "$EXTRACT_DIR"
184184
log "Old installation removed."
185185
fi
186186

@@ -376,7 +376,7 @@ check_status() {
376376
log "No cron job found for SystemGuard."
377377
fi
378378

379-
log "Performing health check on localhost:5005..."
379+
log "Performing health check on $HOST_URL..."
380380
if curl -s --head $HOST_URL | grep "200 OK" > /dev/null; then
381381
log "SystemGuard services are running."
382382
else
@@ -441,10 +441,15 @@ esac
441441
change_ownership() {
442442
local directory="$1"
443443
if [ -d "$directory" ]; then
444-
chown -R "$USER_NAME:$USER_NAME" "$directory"
444+
# if permission is set to root then change it to the user
445+
if [ "$(stat -c %U "$directory")" == "root" ]; then
446+
chown -R "$USER_NAME:$USER_NAME" "$directory"
447+
log "Ownership changed to $USER_NAME for directory: $directory"
448+
fi
445449
fi
446450
}
447451

452+
448453
# Call the change_ownership function
449454
change_ownership "$EXTRACT_DIR"
450455

0 commit comments

Comments
 (0)