Skip to content

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
zamkara authored May 6, 2024
1 parent 74ea445 commit 74f49c1
Showing 1 changed file with 96 additions and 33 deletions.
129 changes: 96 additions & 33 deletions script
Original file line number Diff line number Diff line change
@@ -1,40 +1,103 @@
#!/bin/bash
usage() {
echo "Usage: allowme [path_to_app]"
echo "Grant permissions to the specified app."
echo "If no path is provided, you will be prompted to enter the app path."
}
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
usage
exit 0
fi

# Check if the tccplus package is already installed
if ! command -v tccplus &> /dev/null; then
echo "Package 'tccplus' is not found. Downloading and installing..."
sudo curl -L -o /usr/local/bin/tccplus https://github.com/zamkara/Allowme/raw/main/tccplus
sudo chmod +x /usr/local/bin/tccplus
else
echo "set app permissions..."
echo "tccplus package not found. Downloading..."

# Download the tccplus file from GitHub
curl -L -o tccplus https://github.com/zamkara/Allowme/raw/main/tccplus

# Move the tccplus file to /usr/local/bin/ with sudo access
sudo mv tccplus /usr/local/bin/

# Change the permission of the tccplus file to executable
sudo chmod +x /usr/local/bin/tccplus

echo "tccplus package downloaded and installed successfully."
fi
if [[ -z "$1" ]]; then
echo "Enter the folder path to execute:"
read -r folder_path
else
folder_path="$1"

# Check if the command is 'flag'
if [ "$1" == "flag" ]; then
echo "emFta2FyYQ=={th15_15_n0t_4_fl4g}"
exit 0
fi

# Check the number of arguments provided
if [ $# -lt 3 ] || [ "$1" == "-h" ]; then
echo "Usage: allowme [add/reset] [permission] [application_path]"
echo "permission:"
echo " - All"
echo " - Accessibility"
echo " - AddressBook"
echo " - AppleEvents"
echo " - Calendar"
echo " - Camera"
echo " - ContactsFull"
echo " - ContactsLimited"
echo " - DeveloperTool"
echo " - Facebook"
echo " - LinkedIn"
echo " - ListenEvent"
echo " - Liverpool"
echo " - Location"
echo " - MediaLibrary"
echo " - Microphone"
echo " - Motion"
echo " - Photos"
echo " - PhotosAdd"
echo " - PostEvent"
echo " - Reminders"
echo " - ScreenCapture"
echo " - ShareKit"
echo " - SinaWeibo"
echo " - Siri"
echo " - SpeechRecognition"
echo " - SystemPolicyAllFiles"
echo " - SystemPolicyDesktopFolder"
echo " - SystemPolicyDeveloperFiles"
echo " - SystemPolicyDocumentsFolder"
echo " - SystemPolicyDownloadsFolder"
echo " - SystemPolicyNetworkVolumes"
echo " - SystemPolicyRemovableVolumes"
echo " - SystemPolicySysAdminFiles"
echo " - TencentWeibo"
echo " - Twitter"
echo " - Ubiquity"
echo " - Willow"
exit 1
fi
folder_path="${folder_path//\\/}"
cd "$folder_path" || { echo "Failed to enter the folder: $folder_path"; exit 1; }
cd Contents || { echo "Failed to enter the Contents folder"; exit 1; }
output=$(grep -A 1 '<key>CFBundleIdentifier</key>' Info.plist | grep -o '<string>.*</string>')
# <!-- What do you think you're doing here? -->
# <!-- emFta2FyYQ=={th15_15_n0t_4_fl4g} -->
if [[ -z "$output" ]]; then
echo "Failed to find the bundle identifier in Info.plist"
exit 1

# Get the options from the provided arguments
command=$1
permission=$2
app_directory=$3

# Check for valid options
if [ "$command" != "add" ] && [ "$command" != "reset" ]; then
echo "Usage: allowme [add/reset] [permission] [application_path]"
exit 1
fi
value=$(echo "$output" | sed -E 's/<\/?string>//g')
if [[ -n "$value" ]]; then
sudo tccplus add All "$value"

# Check if the application directory exists
if [ -d "$app_directory" ]; then
# Get the CFBundleIdentifier value from Info.plist
bundle_identifier=$(defaults read "$app_directory/Contents/Info.plist" CFBundleIdentifier)

# Check if CFBundleIdentifier is found
if [ -z "$bundle_identifier" ]; then
echo "CFBundleIdentifier not found"
exit 1
fi

# Form the command with the provided permission option
if [ "$command" == "reset" ]; then
command="sudo tccplus reset $permission $bundle_identifier"
else
command="sudo tccplus add $permission $bundle_identifier"
fi

# Run the command
eval "$command"
else
echo "Failed to extract the bundle identifier value"
exit 1
echo "Application directory not found"
fi

0 comments on commit 74f49c1

Please sign in to comment.