From 675ce8c9d7f40769ea96ca91633369f5976bc351 Mon Sep 17 00:00:00 2001 From: cswimr Date: Sun, 9 Mar 2025 19:21:45 -0500 Subject: [PATCH] update symlink script --- setup_symlinks.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/setup_symlinks.sh b/setup_symlinks.sh index 8a0a061..ed3f2fd 100755 --- a/setup_symlinks.sh +++ b/setup_symlinks.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Directory to copy/symlink mods to +# Directory to copy/hardlink mods to TARGET_DIR="${HOME}/.local/share/Paradox Interactive/Stellaris/mod/" # Create the target directory if it doesn't exist @@ -8,24 +8,26 @@ mkdir -p "$TARGET_DIR" # Loop through each subdirectory in the same directory as the script for mod_dir in */; do - # Remove trailing slash from directory name - mod_name="${mod_dir%/}" + # Remove trailing slash from directory name + mod_name="${mod_dir%/}" - # Path to the .mod file with the same name as the directory - mod_file="${mod_name}.mod" + # Path to the .mod file with the same name as the directory + mod_file="${mod_name}.mod" - # Check if the .mod file exists - if [ -f "$mod_file" ]; then - echo "Processing mod: $mod_name" + # Check if the .mod file exists + if [ -f "$mod_file" ]; then + echo "Processing mod: $mod_name" - # Symlink the mod directory to the target directory - ln -sfn "$(pwd)/$mod_dir" "$TARGET_DIR$mod_name" + # Remove existing .mod file if it exists + if [ -f "$TARGET_DIR$mod_file" ]; then + rm "$TARGET_DIR$mod_file" + fi - # Symlink the .mod file to the target directory - ln -sfn "$(pwd)/$mod_file" "$TARGET_DIR$mod_file" + # Hardlink the .mod file to the target directory + ln "$mod_file" "$TARGET_DIR$mod_file" else echo "Warning: .mod file for $mod_name not found, skipping." fi done -echo "Mod copying/symlinking completed." +echo "Mod linking completed."