From 79198dc0093cd852033ceb034ee90d41958e7020 Mon Sep 17 00:00:00 2001 From: Andrei Boyanov Date: Sat, 19 Apr 2025 12:16:13 +0200 Subject: [PATCH] Exit on failure Signed-off-by: Andrei Boyanov --- run.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/run.sh b/run.sh index 0562b37..bcb6035 100644 --- a/run.sh +++ b/run.sh @@ -5,17 +5,18 @@ CHAT=$3 # Clone Odoo directory echo "Clonning the repository" -git clone --depth=1 https://github.com/andreiboyanov/emf-1995-docker-compose $DESTINATION -rm -rf $DESTINATION/.git +git clone --depth=1 https://github.com/andreiboyanov/emf-1995-docker-compose $DESTINATION || exit -1 +rm -rf $DESTINATION/.git || exit -1 # Create PostgreSQL directory echo "Creating the poostgresql folder $DESTINATION/postgresql" -mkdir -p $DESTINATION/postgresql +mkdir -p $DESTINATION/postgresql || exit -1 # Change ownership to current user and set restrictive permissions for security echo "Configuring permissions" -sudo chown -R $USER:$USER $DESTINATION -sudo chmod -R 700 $DESTINATION # Only the user has access +sudo chown -R $USER:$USER $DESTINATION || exit -1 +sudo chmod -R 700 $DESTINATION || exit -1 # Only the user has access + # Check if running on macOS if [[ "$OSTYPE" == "darwin"* ]]; then @@ -30,27 +31,28 @@ else fi sudo sysctl -p fi +if [ $? -ne 0 ]; then exit -1; fi # Set ports in docker-compose.yml # Update docker-compose configuration if [[ "$OSTYPE" == "darwin"* ]]; then # macOS sed syntax - sed -i '' 's/10018/'$PORT'/g' $DESTINATION/docker-compose.yml - sed -i '' 's/20018/'$CHAT'/g' $DESTINATION/docker-compose.yml + sed -i '' 's/10018/'$PORT'/g' $DESTINATION/docker-compose.yml || exit -1 + sed -i '' 's/20018/'$CHAT'/g' $DESTINATION/docker-compose.yml || exit -1 else # Linux sed syntax echo "Configuring the Odoo ports" - sed -i 's/10018/'$PORT'/g' $DESTINATION/docker-compose.yml - sed -i 's/20018/'$CHAT'/g' $DESTINATION/docker-compose.yml + sed -i 's/10018/'$PORT'/g' $DESTINATION/docker-compose.yml || exit -1 + sed -i 's/20018/'$CHAT'/g' $DESTINATION/docker-compose.yml || exit -1 fi # Set file and directory permissions after installation echo "Configuring $DESTINATION permissions" -find $DESTINATION -type f -exec chmod 644 {} \; -find $DESTINATION -type d -exec chmod 755 {} \; +find $DESTINATION -type f -exec chmod 644 {} \; || exit -1 +find $DESTINATION -type d -exec chmod 755 {} \; || exit -1 echo "Making the entrypoint executable" -chmod +x $DESTINATION/entrypoint.sh +chmod +x $DESTINATION/entrypoint.sh || exit -1 # Run Odoo "Running the EMF-1995 social app"