fmt: fixed formatting
This commit is contained in:
parent
8e3c8a6a2f
commit
551b056d9f
1 changed files with 35 additions and 35 deletions
58
old_home.sh
58
old_home.sh
|
@ -14,40 +14,40 @@ change_owner_and_permissions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
iter_dirs(){
|
iter_dirs(){
|
||||||
local root="$1"
|
local root="$1"
|
||||||
|
|
||||||
# Loop through each directory in /home
|
# Loop through each directory in /home
|
||||||
for dir in $root/*; do
|
for dir in $root/*; do
|
||||||
if [ -d "$dir" ]; then
|
if [ -d "$dir" ]; then
|
||||||
# Extract the directory name without the leading path
|
# Extract the directory name without the leading path
|
||||||
username=$(basename "$dir")
|
username=$(basename "$dir")
|
||||||
|
|
||||||
# handle caps
|
# handle caps
|
||||||
username_lower=$(echo "$username" | tr '[:upper:]' '[:lower:]')
|
username_lower=$(echo "$username" | tr '[:upper:]' '[:lower:]')
|
||||||
if [ "$username" != "$username_lower" ]; then
|
if [ "$username" != "$username_lower" ]; then
|
||||||
mv "$root/$username" "$root/$username_lower"
|
mv "$root/$username" "$root/$username_lower"
|
||||||
echo "Changed $username to $username_lower"
|
echo "Changed $username to $username_lower"
|
||||||
username=$username_lower
|
username=$username_lower
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# names must atart with either underscore or letter
|
# names must atart with either underscore or letter
|
||||||
if [[ $username =~ ^[0-9] ]]; then
|
if [[ $username =~ ^[0-9] ]]; then
|
||||||
mv "$root/$username" "$root/_$username"
|
mv "$root/$username" "$root/_$username"
|
||||||
echo "Changed $username to _$username"
|
echo "Changed $username to _$username"
|
||||||
username="_$username"
|
username="_$username"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set permissions to read-only for the owner and not readable by others
|
# Set permissions to read-only for the owner and not readable by others
|
||||||
# folders have to be executable to be able to read their contents
|
# folders have to be executable to be able to read their contents
|
||||||
chmod -R 500 "$dir"
|
chmod -R 500 "$dir"
|
||||||
|
|
||||||
# Check if the user exists before changing ownership and permissions
|
# Check if the user exists before changing ownership and permissions
|
||||||
if id "$username" &>/dev/null; then
|
if id "$username" &>/dev/null; then
|
||||||
change_owner_and_permissions "$dir" "$username"
|
change_owner_and_permissions "$dir" "$username"
|
||||||
echo "Changed owner and permissions of $dir to $username"
|
echo "Changed owner and permissions of $dir to $username"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
iter_dirs /skynet_old/home
|
iter_dirs /skynet_old/home
|
||||||
|
|
Loading…
Reference in a new issue