Skip to content

Commit

Permalink
fix(install): improve root detection and set ownership on files
Browse files Browse the repository at this point in the history
  • Loading branch information
psyray committed Sep 2, 2024
1 parent 48ec4ac commit 7f5b8bc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 57 deletions.
3 changes: 2 additions & 1 deletion .env-dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ STATE=Georgia
CITY=Atlanta

#
# Database configurations
# Database configurations
# /!\ POSTGRES_USER & PG_USER must be the same user or Celery will fail to start
#
POSTGRES_DB=rengine
POSTGRES_USER=rengine
Expand Down
30 changes: 25 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@ for ip in $internal_ips; do
done

# Check for root privileges
if [ "$(whoami)" != "root" ]
then
log ""
log "Error installing reNgine-ng: please run this script as root!" $COLOR_RED
if [ $EUID -eq 0 ]; then
if [ "$SUDO_USER" = "root" ] || [ "$SUDO_USER" = "" ]; then
log "Error: Do not run this script as root. Use sudo with a non-root user." $COLOR_RED
log "Example: sudo ./install.sh" $COLOR_RED
exit 1
fi
fi

# Check if the script is run with sudo
if [ -z "$SUDO_USER" ]; then
log "Error: This script must be run with sudo." $COLOR_RED
log "Example: sudo ./install.sh" $COLOR_RED
exit
exit 1
fi

# Check that the project directory is not owned by root
project_dir=$(pwd)
if [ "$(stat -c '%U' $project_dir)" = "root" ]; then
log "The project directory is owned by root. Changing ownership..." $COLOR_YELLOW
sudo chown -R $SUDO_USER:$SUDO_USER $project_dir
if [ $? -eq 0 ]; then
log "Project directory ownership successfully changed." $COLOR_GREEN
else
log "Failed to change project directory ownership." $COLOR_RED
exit 1
fi
fi

usageFunction()
Expand Down
51 changes: 0 additions & 51 deletions make.bat

This file was deleted.

0 comments on commit 7f5b8bc

Please sign in to comment.