mirror of
https://github.com/CodeninjasWS/GameSharingSite.git
synced 2024-11-27 09:55:41 -05:00
27 lines
663 B
Bash
27 lines
663 B
Bash
#!/bin/bash
|
|
|
|
grant_directory_access() {
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must be run as root."
|
|
return
|
|
fi
|
|
|
|
read -p "Enter the directory path: " directory
|
|
read -p "Enter the username: " username
|
|
|
|
# Check if the directory exists
|
|
if [ ! -d "$directory" ]; then
|
|
echo "Directory does not exist."
|
|
return
|
|
fi
|
|
|
|
# Grant full access to the directory for the specified user
|
|
if chown -R "$username:$username" "$directory" && chmod -R 700 "$directory"; then
|
|
echo "Access granted successfully."
|
|
else
|
|
echo "An error occurred."
|
|
fi
|
|
}
|
|
|
|
# Call the function
|
|
grant_directory_access
|