From 50d4b045e702c1ef0e2c4ac91731affebd22e23d Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 1 Apr 2024 16:16:33 -0400 Subject: [PATCH 1/2] Update permissions script to include progress --- .gitlab/scripts/linux_perms_fix.sh | 39 +++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/.gitlab/scripts/linux_perms_fix.sh b/.gitlab/scripts/linux_perms_fix.sh index 24b92176..41993fc3 100644 --- a/.gitlab/scripts/linux_perms_fix.sh +++ b/.gitlab/scripts/linux_perms_fix.sh @@ -3,13 +3,44 @@ # Prompt the user for the directory path read -p "Enter the directory path to set permissions (/var/opt/minecraft/crafty): " directory_path +# Count the total number of directories +total_dirs=$(find "$directory_path" -type d | wc -l) + +# Count the total number of files +total_files=$(find "$directory_path" -type f | wc -l) + +# Initialize a counter for directories and files +dir_count=0 +file_count=0 + +# Function to print progress +print_progress() { + echo -ne "\rDirectories: $dir_count/$total_dirs Files: $file_count/$total_files" +} + # Check if the script is running within a Docker container if [ -f "/.dockerenv" ]; then echo "Script is running within a Docker container. Exiting with error." exit 1 # Exit with an error code if running in Docker else echo "Script is not running within a Docker container. Executing permissions changes..." - # Run the commands to set permissions - sudo chmod 700 $(find "$directory_path" -type d) - sudo chmod 644 $(find "$directory_path" -type f) -fi \ No newline at end of file + + # Run the commands to set permissions for directories + echo "Changing permissions for directories:" + for dir in $(find "$directory_path" -type d); do + sudo chmod 700 "$dir" + ((dir_count++)) + print_progress + done + + # Run the commands to set permissions for files + echo -e "\nChanging permissions for files:" + for file in $(find "$directory_path" -type f); do + sudo chmod 644 "$file" + ((file_count++)) + print_progress + done + echo "You will now need to execute a chmod +x on all bedrock executables" +fi + +echo "" # Adding a new line after the loop for better readability \ No newline at end of file From 91a601fb5f13efa73d0d7a444abd0242f522f911 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 1 Apr 2024 16:30:12 -0400 Subject: [PATCH 2/2] Remove console spam --- .gitlab/scripts/linux_perms_fix.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.gitlab/scripts/linux_perms_fix.sh b/.gitlab/scripts/linux_perms_fix.sh index 41993fc3..d727b16b 100644 --- a/.gitlab/scripts/linux_perms_fix.sh +++ b/.gitlab/scripts/linux_perms_fix.sh @@ -4,10 +4,10 @@ read -p "Enter the directory path to set permissions (/var/opt/minecraft/crafty): " directory_path # Count the total number of directories -total_dirs=$(find "$directory_path" -type d | wc -l) +total_dirs=$(find "$directory_path" -type d 2>/dev/null | wc -l) # Count the total number of files -total_files=$(find "$directory_path" -type f | wc -l) +total_files=$(find "$directory_path" -type f 2>/dev/null | wc -l) # Initialize a counter for directories and files dir_count=0 @@ -27,17 +27,19 @@ else # Run the commands to set permissions for directories echo "Changing permissions for directories:" - for dir in $(find "$directory_path" -type d); do - sudo chmod 700 "$dir" - ((dir_count++)) + for dir in $(find "$directory_path" -type d 2>/dev/null); do + if [ -e "$dir" ]; then + sudo chmod 700 "$dir" && ((dir_count++)) + fi print_progress done # Run the commands to set permissions for files echo -e "\nChanging permissions for files:" - for file in $(find "$directory_path" -type f); do - sudo chmod 644 "$file" - ((file_count++)) + for file in $(find "$directory_path" -type f 2>/dev/null); do + if [ -e "$file" ]; then + sudo chmod 644 "$file" && ((file_count++)) + fi print_progress done echo "You will now need to execute a chmod +x on all bedrock executables"