Merge claude/1
This commit is contained in:
commit
cf148327fd
@ -7,25 +7,22 @@ copyFile()
|
|||||||
local file_name=$(basename "$file")
|
local file_name=$(basename "$file")
|
||||||
local save_dir="$3"
|
local save_dir="$3"
|
||||||
local save_dir_file=$(basename "$save_dir")
|
local save_dir_file=$(basename "$save_dir")
|
||||||
local clean_dir=$(echo "$save_dir" | sed 's#//*#/#g')
|
local user_name="$4" # advisory — the destination path determines the owner
|
||||||
local user_name="$4"
|
|
||||||
local flags="$5"
|
local flags="$5"
|
||||||
|
local flags_full=""
|
||||||
|
[[ "$flags" == "overwrite" ]] && flags_full="-f"
|
||||||
|
|
||||||
if [[ $flags == "overwrite" ]]; then
|
# Write as the destination's owner — no root, no chown. Under
|
||||||
flags_full="-f"
|
# /docker/containers/<app> that's the docker install user (runFileOp);
|
||||||
fi
|
# the manager-owned control plane (configs/logs/etc.) is runInstallOp.
|
||||||
|
# Mirrors createTouch's path-based ownership; $user_name is now advisory.
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
local op="runInstallOp"
|
||||||
local result=$(sudo cp $flags_full "$file" "$save_dir")
|
[[ "$save_dir" == "$containers_dir"* || "$save_dir" == /docker/containers/* ]] && op="runFileOp"
|
||||||
checkSuccess "Copying $file_name to $(basename "$save_dir")"
|
|
||||||
elif [ "$silent_flag" == "silent" ]; then
|
|
||||||
local result=$(sudo cp $flags_full "$file" "$save_dir")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
if [ "$silent_flag" == "loud" ]; then
|
||||||
local result=$(sudo chown $user_name:$user_name "$save_dir")
|
local result=$($op cp $flags_full "$file" "$save_dir")
|
||||||
checkSuccess "Updating $save_dir_file with $user_name ownership"
|
checkSuccess "Copying $file_name to $save_dir_file"
|
||||||
elif [ "$silent_flag" == "silent" ]; then
|
else
|
||||||
local result=$(sudo chown $user_name:$user_name "$save_dir")
|
$op cp $flags_full "$file" "$save_dir" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,31 +5,24 @@ copyFiles()
|
|||||||
local silent_flag="$1"
|
local silent_flag="$1"
|
||||||
local source="$2"
|
local source="$2"
|
||||||
local save_dir="$3"
|
local save_dir="$3"
|
||||||
local user_name="$4"
|
local user_name="$4" # advisory — the destination path determines the owner
|
||||||
local clean_dir=$(echo "$save_dir" | sed 's#//*#/#g')
|
|
||||||
|
|
||||||
# Ensure the source path is expanded to a list of files
|
# Write as the destination's owner (see copyFile).
|
||||||
local files=($(sudo find "$source" -type f))
|
local op="runInstallOp"
|
||||||
|
[[ "$save_dir" == "$containers_dir"* || "$save_dir" == /docker/containers/* ]] && op="runFileOp"
|
||||||
|
|
||||||
|
local files=($($op find "$source" -type f))
|
||||||
if [ ${#files[@]} -eq 0 ]; then
|
if [ ${#files[@]} -eq 0 ]; then
|
||||||
echo "No files found in the source directory: $source"
|
echo "No files found in the source directory: $source"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for file in "${files[@]}"; do
|
for file in "${files[@]}"; do
|
||||||
local file_name=$(basename "$file")
|
local file_name=$(basename "$file")
|
||||||
|
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
if [ "$silent_flag" == "loud" ]; then
|
||||||
local result=$(sudo cp -f "$file" "$save_dir")
|
local result=$($op cp -f "$file" "$save_dir")
|
||||||
checkSuccess "Copying $file_name to $save_dir"
|
checkSuccess "Copying $file_name to $save_dir"
|
||||||
elif [ "$silent_flag" == "silent" ]; then
|
else
|
||||||
local result=$(sudo cp -f "$file" "$save_dir")
|
$op cp -f "$file" "$save_dir" >/dev/null 2>&1
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
|
||||||
local result=$(sudo chown $user_name:$user_name "$save_dir/$file_name")
|
|
||||||
checkSuccess "Updating $file_name with $user_name ownership"
|
|
||||||
elif [ "$silent_flag" == "silent" ]; then
|
|
||||||
local result=$(sudo chown $user_name:$user_name "$save_dir/$file_name")
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,11 +23,8 @@ copyResource()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local result=$(sudo cp "$app_dir/resources/$file_name" "$destination_dir/")
|
# Destination is always /docker/containers/<app> -> write as the docker
|
||||||
|
# install user (runFileOp); no root, no chown.
|
||||||
|
local result=$(runFileOp cp "$app_dir/resources/$file_name" "$destination_dir/")
|
||||||
checkSuccess "Copying $file_name to $destination_dir"
|
checkSuccess "Copying $file_name to $destination_dir"
|
||||||
|
|
||||||
local destination_path="$destination_dir/$file_name"
|
|
||||||
|
|
||||||
local result=$(sudo chown $docker_install_user:$docker_install_user "$destination_path")
|
|
||||||
checkSuccess "Updating $file_name with $docker_install_user ownership"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
moveFile()
|
moveFile()
|
||||||
{
|
{
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local file_name=$(basename "$file")
|
local file_name=$(basename "$file")
|
||||||
local save_dir="$2"
|
local save_dir="$2"
|
||||||
local save_dir_file=$(basename "$save_dir")
|
local save_dir_file=$(basename "$save_dir")
|
||||||
local clean_dir=$(echo "$save_dir" | sed 's#//*#/#g')
|
|
||||||
|
|
||||||
if [ -e "$file" ]; then
|
if [ -e "$file" ]; then
|
||||||
local result=$(sudo mv "$file" "$save_dir")
|
# Move as the destination's owner — no root, no chown (see copyFile).
|
||||||
|
local op="runInstallOp"
|
||||||
|
[[ "$save_dir" == "$containers_dir"* || "$save_dir" == /docker/containers/* ]] && op="runFileOp"
|
||||||
|
local result=$($op mv "$file" "$save_dir")
|
||||||
checkSuccess "Moving $file_name to $save_dir"
|
checkSuccess "Moving $file_name to $save_dir"
|
||||||
|
|
||||||
if [[ $clean_dir != *"$containers_dir"* ]]; then
|
|
||||||
local result=$(sudo chown $sudo_user_name:$sudo_user_name "$save_dir")
|
|
||||||
checkSuccess "Updating $save_dir_file with $sudo_user_name ownership"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
isNotice "Source file does not exist: $file"
|
isNotice "Source file does not exist: $file"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -5,12 +5,12 @@ copyFolder()
|
|||||||
local folder="$1"
|
local folder="$1"
|
||||||
local folder_name=$(basename "$folder")
|
local folder_name=$(basename "$folder")
|
||||||
local save_dir="$2"
|
local save_dir="$2"
|
||||||
local user_name="$3"
|
local user_name="$3" # advisory — the destination path determines the owner
|
||||||
local clean_dir=$(echo "$save_dir" | sed 's#//*#/#g')
|
|
||||||
|
|
||||||
local result=$(sudo cp -rf "$folder" "$save_dir")
|
# Write as the destination's owner — no root, no chown (see copyFile).
|
||||||
checkSuccess "Coping $folder_name to $save_dir"
|
local op="runInstallOp"
|
||||||
|
[[ "$save_dir" == "$containers_dir"* || "$save_dir" == /docker/containers/* ]] && op="runFileOp"
|
||||||
|
|
||||||
local result=$(sudo chown $user_name:$user_name "$save_dir/$folder_name")
|
local result=$($op cp -rf "$folder" "$save_dir")
|
||||||
checkSuccess "Updating $folder_name with $user_name ownership"
|
checkSuccess "Copying $folder_name to $save_dir"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,23 +4,20 @@ copyFolders()
|
|||||||
{
|
{
|
||||||
local source="$1"
|
local source="$1"
|
||||||
local save_dir="$2"
|
local save_dir="$2"
|
||||||
local user_name="$3"
|
local user_name="$3" # advisory — the destination path determines the owner
|
||||||
local clean_dir=$(echo "$save_dir" | sed 's#//*#/#g')
|
|
||||||
|
# Write as the destination's owner — no root, no chown (see copyFile).
|
||||||
|
local op="runInstallOp"
|
||||||
|
[[ "$save_dir" == "$containers_dir"* || "$save_dir" == /docker/containers/* ]] && op="runFileOp"
|
||||||
|
|
||||||
# Ensure the source path is expanded to a list of subdirectories
|
|
||||||
local subdirs=($(find "$source" -mindepth 1 -maxdepth 1 -type d))
|
local subdirs=($(find "$source" -mindepth 1 -maxdepth 1 -type d))
|
||||||
|
|
||||||
if [ ${#subdirs[@]} -eq 0 ]; then
|
if [ ${#subdirs[@]} -eq 0 ]; then
|
||||||
echo "No subdirectories found in the source directory: $source"
|
echo "No subdirectories found in the source directory: $source"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for subdir in "${subdirs[@]}"; do
|
for subdir in "${subdirs[@]}"; do
|
||||||
local subdir_name=$(basename "$subdir")
|
local subdir_name=$(basename "$subdir")
|
||||||
|
local result=$($op cp -rf "$subdir" "$save_dir")
|
||||||
local result=$(sudo cp -rf "$subdir" "$save_dir")
|
|
||||||
checkSuccess "Copying $subdir_name to $save_dir"
|
checkSuccess "Copying $subdir_name to $save_dir"
|
||||||
|
|
||||||
local result=$(sudo chown -R $user_name:$user_name "$save_dir/$subdir_name")
|
|
||||||
checkSuccess "Updating $subdir_name with $user_name ownership"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,20 +24,13 @@ createFolders()
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Non-container path = manager-owned control plane -> create AS the
|
||||||
|
# manager (runInstallOp); no root, no chown.
|
||||||
if [ ! -d "$dir_path" ]; then
|
if [ ! -d "$dir_path" ]; then
|
||||||
local result=$(sudo mkdir -p "$dir_path")
|
local result=$(runInstallOp mkdir -p "$dir_path")
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
[ "$silent_flag" == "loud" ] && checkSuccess "Creating $folder_name directory"
|
||||||
checkSuccess "Creating $folder_name directory"
|
elif [ "$silent_flag" == "loud" ]; then
|
||||||
fi
|
isNotice "$folder_name directory already exists"
|
||||||
else
|
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
|
||||||
isNotice "$folder_name directory already exists"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
local result=$(sudo chown $user_name:$user_name "$dir_path")
|
|
||||||
if [ "$silent_flag" == "loud" ]; then
|
|
||||||
checkSuccess "Updating $folder_name with $user_name ownership"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,6 @@ updateFileOwnership()
|
|||||||
local user_name_1="$2"
|
local user_name_1="$2"
|
||||||
local user_name_2="$3"
|
local user_name_2="$3"
|
||||||
|
|
||||||
local result=$(sudo chown $user_name_1:$user_name_2 "$file")
|
local result=$(runSystem chown $user_name_1:$user_name_2 "$file")
|
||||||
checkSuccess "Updating $file_name with $user_name ownership"
|
checkSuccess "Updating $file_name with $user_name ownership"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user