diff --git a/Scripts/override.sh b/Scripts/override.sh new file mode 100755 index 0000000..72f890d --- /dev/null +++ b/Scripts/override.sh @@ -0,0 +1,322 @@ +#!/bin/bash + +action="" +if [[ $# -gt 0 ]]; then + action="$1" +fi + +method="" +if [[ $# -gt 1 ]]; then + method="$2" +fi + +key="" +if [[ $# -gt 2 ]]; then + key="$3" +fi + +UTIL_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/eligibility_util" +UTIL_SIP_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/eligibility_util_sip" +DOWNLOAD_DIR="/tmp" +UTIL_FILE="${DOWNLOAD_DIR}/eligibility_util" +UTIL_SIP_FILE="${DOWNLOAD_DIR}/eligibility_util_sip" +OVERRIDE_FILE="${DOWNLOAD_DIR}/eligibility_overrides.data" +OVERRIDE_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/$key.eligibility_overrides.data" +DAEMON_CONTAINERS_DIR=/private/var/root/Library/Daemon\ Containers + +show_usage() { + echo "Usage: $0 install [util|override] [all|xcodellm|greymatter]" + echo "Usage: $0 uninstall [util|override] [all|xcodellm|greymatter]" + echo "Usage: $0 doctor" + echo "Usage: $0 version" +} + +download_file() { + echo "[download_file] Download started" + echo "[download_file] Downloading from $1 to $2" + local url="$1" + local output_path="$2" + curl -L -o "$output_path" "$url" + echo "[download_file] Download completed" +} + +method_util() { + download_file "$UTIL_URL" "$UTIL_FILE" + chmod +x "$UTIL_FILE" + case "$key" in + all) + echo "[method_util] Setting all to eligible..." + $UTIL_FILE forceDomainSetAnswer --domain-set 1 --answer 4 + echo "[method_util] Setting Complete..." + echo "[method_util] Checking the status..." + "$UTIL_FILE" getDomainAnswer --all + echo "" + ;; + xcodellm) + echo "[method_util] Setting XcodeLLM to eligible..." + "$UTIL_FILE" forceDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM --answer 4 + echo "[method_util] Setting Complete..." + echo "[method_util] Checking the status..." + "$UTIL_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM + echo "" + ;; + greymatter) + echo "[method_util] Setting Apple Intelligence to eligible..." + "$UTIL_FILE" forceDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER --answer 4 + echo "[method_util] Setting Complete..." + echo "[method_util] Checking the status..." + "$UTIL_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER + echo "" + ;; + *) + echo "[method_util] Unknown key: $key" + show_usage + ;; + esac +} + +method_util_uninstall() { + download_file "$UTIL_URL" "$UTIL_FILE" + chmod +x "$UTIL_FILE" + case "$key" in + all) + echo "[method_util_uninstall] Resetting all..." + $UTIL_FILE resetDomain --all + echo "[method_util_uninstall] Resetting Complete..." + echo "[method_util_uninstall] Checking the status..." + "$UTIL_FILE" getDomainAnswer --all + echo "" + ;; + xcodellm) + echo "[method_util_uninstall] Resetting XcodeLLM..." + "$UTIL_FILE" resetDomain --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM + echo "[method_util_uninstall] Resetting Complete..." + echo "[method_util_uninstall] Checking the status..." + "$UTIL_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM + echo "" + ;; + greymatter) + echo "[method_util_uninstall] Resetting Apple Intelligence..." + "$UTIL_FILE" resetDomain --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER + echo "[method_util_uninstall] Resetting Complete..." + echo "[method_util_uninstall] Checking the status..." + "$UTIL_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER + echo "" + ;; + *) + echo "[method_util_uninstall] Unknown key: $key" + show_usage + ;; + esac +} + +amfi_check() { + echo "[amfi_check] checking boot-args" + local boot_args=$(sudo nvram boot-args 2>/dev/null) + if echo "$boot_args" | grep -q 'amfi_get_out_of_my_way=1'; then + echo "[amfi_check] amfi_get_out_of_my_way=1 is present in boot-args" + echo "[amfi_check] Note: You need to reboot to make boot-args changes take effect" + return 0 + else + echo "[amfi_check] amfi_get_out_of_my_way=1 is not present in boot-args" + return 1 + fi +} + +check_sip_status() { + echo "[check_sip_status] checking SIP status..." + local sip_status=$(csrutil status) + if echo "$sip_status" | grep -q "enabled"; then + echo "[check_sip_status] SIP is enabled" + return 1 + else + echo "[check_sip_status] SIP is disabled" + return 0 + fi +} + +method_util_check() { + if check_sip_status && amfi_check; then + echo "[method_util_check] 🎉 SIP is disabled and amfi_get_out_of_my_way=1 is present in boot-args" + return 0 + else + echo "[method_util_check] Please diable SIP and add amfi_get_out_of_my_way=1 to boot-args" + echo "[method_util_check] Or you can use 'override' method to install" + return 1 + fi +} + +method_override() { + download_file "$OVERRIDE_URL" "$OVERRIDE_FILE" + echo "[method_override] Copying eligibility_overrides.data to each Daemon Container..." + + if ! sudo ls "$DAEMON_CONTAINERS_DIR" > /dev/null 2>&1; then + echo "[method_override] You do not have the permission to read Daemon Container folder $DAEMON_CONTAINERS_DIR" + echo "[method_override] Please considering granting full disk access in System Preferences > Security & Privacy > Full Disk Access to your Terminal app which the script is running on" + echo "[method_override] Or you can follow the instruction on README.md" + exit 1 + fi + + for container in $(sudo ls "$DAEMON_CONTAINERS_DIR"); do + echo "[method_override] Copying for container $container" + dest_dir="${DAEMON_CONTAINERS_DIR}/${container}/Data/Library/Caches/NeverRestore/" + sudo mkdir -p "$dest_dir" + sudo cp "$OVERRIDE_FILE" "$dest_dir" + echo "[method_override] Copied to $dest_dir" + done + + echo ["method_override" killing eligibilityd...] + sudo pkill -9 eligibilityd + sudo launchctl kickstart -k system/com.apple.eligibilityd + download_file "$UTIL_SIP_URL" "$UTIL_SIP_FILE" + chmod +x "$UTIL_SIP_FILE" + echo "[method_override] Checking the status..." + case "$key" in + all) + "$UTIL_SIP_FILE" getDomainAnswer --all + ;; + xcodellm) + "$UTIL_SIP_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM + ;; + greymatter) + "$UTIL_SIP_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER + ;; + *) + echo "[method_override] Unknown key: $key" + show_usage + ;; + esac +} + +method_override_uninstall() { + echo "[method_override_uninstall] Removing eligibility_overrides.data to each Daemon Container..." + + if ! sudo ls "$DAEMON_CONTAINERS_DIR" > /dev/null 2>&1; then + echo "[method_override_uninstall] You do not have the permission to read Daemon Container folder $DAEMON_CONTAINERS_DIR" + echo "[method_override_uninstall] Please considering granting full disk access in System Preferences > Security & Privacy > Full Disk Access to your Terminal app which the script is running on" + echo "[method_override_uninstall] Or you can follow the instruction on README.md" + exit 1 + fi + + for container in $(sudo ls "$DAEMON_CONTAINERS_DIR"); do + echo "[method_override_uninstall] Removing for container $container" + dest_dir="${DAEMON_CONTAINERS_DIR}/${container}/Data/Library/Caches/NeverRestore/" + sudo rm -rf "$dest_dir" + echo "[method_override_uninstall] Copied to $dest_dir" + done + + echo ["method_override_uninstall" killing eligibilityd...] + sudo pkill -9 eligibilityd + sudo launchctl kickstart -k system/com.apple.eligibilityd + download_file "$UTIL_SIP_URL" "$UTIL_SIP_FILE" + chmod +x "$UTIL_SIP_FILE" + echo "[method_override_uninstall] Checking the status..." + case "$key" in + all) + "$UTIL_SIP_FILE" getDomainAnswer --all + ;; + xcodellm) + "$UTIL_SIP_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM + ;; + greymatter) + "$UTIL_SIP_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER + ;; + *) + echo "[method_override_uninstall] Unknown key: $key" + show_usage + ;; + esac +} + +install() { + echo "[install] started" + case "$method" in + util) + if method_util_check; then + method_util + else + exit 1 + fi + ;; + override) + method_override + ;; + *) + echo "[Install] Unknown method: $method" + show_usage + ;; + esac + echo "[install] completed" +} + +uninstall() { + echo "[uninstall] started" + case "$method" in + util) + if method_util_check; then + method_util_uninstall + else + exit 1 + fi + ;; + override) + method_override_uninstall + ;; + *) + echo "[uninstall] Unknown method: $method" + show_usage + ;; + esac + echo "[uninstall] completed" +} + +doctor_check() { + if check_sip_status && amfi_check; then + echo "[doctor_check] 🎉 SIP is disabled and amfi_get_out_of_my_way=1 is present in boot-args" + return 0 + else + echo "[doctor_check] Please diable SIP and add amfi_get_out_of_my_way=1 to boot-args" + return 1 + fi +} + +doctor_action() { + download_file "$UTIL_URL" "$UTIL_FILE" + chmod +x "$UTIL_FILE" + "$UTIL_FILE" getStateDump +} + +doctor() { + if doctor_check; then + doctor_action + else + exit 1 + fi +} + +entrypoint() { + echo "Performing with [action]=$action [method]=$method [key]=$key" + case "$action" in + install) + install + ;; + uninstall) + uninstall + ;; + doctor) + doctor + ;; + version) + echo "Version: 0.2.0" + ;; + *) + echo "Unknown action: $action" + show_usage + ;; + esac + + echo "If you find this script helpful, please consider giving a star to the project." + echo "🌟🌟🌟 https://github.com/Kyle-Ye/XcodeLLMEligible 🌟🌟🌟" +} + +entrypoint \ No newline at end of file diff --git a/override_apple_intelligence.sh b/override_apple_intelligence.sh deleted file mode 100755 index d08dac7..0000000 --- a/override_apple_intelligence.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash - -UTIL_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/eligibility_util" -DOWNLOAD_DIR="/tmp" -UTIL_FILE="${DOWNLOAD_DIR}/eligibility_util" - -download_file() { - local url="$1" - local output_path="$2" - curl -L -o "$output_path" "$url" -} - -method_util() { - echo "Downloading eligibility_util..." - echo "" - download_file "$UTIL_URL" "$UTIL_FILE" - chmod +x "$UTIL_FILE" - echo "Setting Apple Intelligence to eligible..." - "$UTIL_FILE" forceDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER --answer 4 - echo "Setting Complete..." - echo "" - echo "Checking the status..." - "$UTIL_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_GREYMATTER - echo "" -} - -check_sip_status() { - local sip_status=$(csrutil status) - if echo "$sip_status" | grep -q "enabled"; then - echo "SIP is enabled." - echo "" - return 1 - else - echo "SIP is disabled." - echo "" - return 0 - fi -} - -amfi_check() { - local boot_args=$(sudo nvram boot-args 2>/dev/null) - if echo "$boot_args" | grep -q 'amfi_get_out_of_my_way=1'; then - echo "amfi_get_out_of_my_way=1 is present in boot-args." - return 0 - else - echo "amfi_get_out_of_my_way=1 is not present in boot-args." - return 1 - fi -} - -action="install" -if [[ $# -gt 0 ]]; then - action="$1" -fi - -case "$action" in - install) - echo "Performing install action..." - echo "" - if check_sip_status; then - if amfi_check; then - echo "🎉 SIP is disabled and amfi_get_out_of_my_way=1 is present in boot-args." - echo "" - method_util - else - echo "[Error] SIP is disabled but amfi_get_out_of_my_way=1 is not present in boot-args." - exit 1 - fi - else - echo "[Error] SIP is enabled." - exit 1 - fi - echo "Apple Intelligence eligible override script install completed." - echo "If you find this script helpful, please consider giving a star to the project." - echo "🌟🌟🌟 https://github.com/Kyle-Ye/XcodeLLMEligible 🌟🌟🌟" - ;; - *) - echo "Unknown action: $action" - echo "Usage: $0 [install]" - exit 1 - ;; -esac \ No newline at end of file diff --git a/override_xcodellm.sh b/override_xcodellm.sh deleted file mode 100755 index 7893604..0000000 --- a/override_xcodellm.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash - -UTIL_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/eligibility_util" -UTIL_SIP_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/eligibility_util_sip" -OVERRIDE_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/latest/download/eligibility_overrides.data" -DOWNLOAD_DIR="/tmp" -UTIL_FILE="${DOWNLOAD_DIR}/eligibility_util" -UTIL_SIP_FILE="${DOWNLOAD_DIR}/eligibility_util_sip" -OVERRIDES_FILE="${DOWNLOAD_DIR}/eligibility_overrides.data" -DAEMON_CONTAINERS_DIR=~/Library/Daemon\ Containers/ - -download_file() { - local url="$1" - local output_path="$2" - curl -L -o "$output_path" "$url" -} - -method_util() { - echo "Downloading eligibility_util..." - echo "" - download_file "$UTIL_URL" "$UTIL_FILE" - chmod +x "$UTIL_FILE" - echo "Setting XcodeLLM to eligible..." - "$UTIL_FILE" forceDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM --answer 4 - echo "Setting Complete..." - echo "" - echo "Checking the status..." - "$UTIL_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM - echo "" -} - -method_override() { - echo "Downloading eligibility_overrides.data..." - echo "" - download_file "$OVERRIDE_URL" "$OVERRIDES_FILE" - echo "Copying eligibility_overrides.data to each Daemon Container..." - echo "" - if ls "$DAEMON_CONTAINERS_DIR"; then - for dir in "$DAEMON_CONTAINERS_DIR"*/ ; do - if [[ -d "$dir" ]]; then - dest_dir="${dir}Data/Library/Caches/NeverRestore/" - mkdir -p "$dest_dir" - cp "$OVERRIDES_FILE" "$dest_dir" - echo "Copied to $dest_dir" - fi - done - echo "Downloading eligibility_util_sip..." - echo "" - download_file "$UTIL_SIP_URL" "$UTIL_SIP_FILE" - chmod +x "$UTIL_SIP_FILE" - echo "Checking the status..." - "$UTIL_SIP_FILE" getDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM - echo "" - else - echo "You do not have the permission to read Daemon Container folder." - echo "Please considering granting full disk access in System Preferences > Security & Privacy > Full Disk Access to your Terminal app which the script is running on." - echo "Or you can follow the instruction on README.md to copy the files manually via Finder operation." - echo "" - exit 1 - fi -} - -check_sip_status() { - local sip_status=$(csrutil status) - if echo "$sip_status" | grep -q "enabled"; then - echo "SIP is enabled." - echo "" - return 1 - else - echo "SIP is disabled." - echo "" - return 0 - fi -} - -amfi_check() { - local boot_args=$(sudo nvram boot-args 2>/dev/null) - if echo "$boot_args" | grep -q 'amfi_get_out_of_my_way=1'; then - echo "amfi_get_out_of_my_way=1 is present in boot-args." - return 0 - else - echo "amfi_get_out_of_my_way=1 is not present in boot-args." - return 1 - fi -} - -uninstall() { - echo "Uninstalling..." - echo "Removing eligibility_overrides.data from Daemon Containers..." - echo "" - for dir in "$DAEMON_CONTAINERS_DIR"*/ ; do - if [[ -d "$dir" ]]; then - dest_file="${dir}Data/Library/Caches/NeverRestore" - if [[ -d "$dest_file" ]]; then - rm -rf "$dest_file" - echo "Removed $dest_file" - fi - fi - done -} - -action="install" -if [[ $# -gt 0 ]]; then - action="$1" -fi - -case "$action" in - install) - echo "Performing install action..." - echo "" - if check_sip_status; then - if amfi_check; then - echo "🎉 SIP is disabled and amfi_get_out_of_my_way=1 is present in boot-args." - echo "" - method_util - else - echo "[Warning] SIP is disabled but amfi_get_out_of_my_way=1 is not present in boot-args." - echo "Fallback to use not recommended override file method." - echo "" - method_override - fi - else - echo "[Warning] SIP is enabled." - echo "Fallback to use not recommended override file method." - echo "" - method_override - fi - echo "XcodeLLM eligible override script install completed." - echo "If you find this script helpful, please consider giving a star to the project." - echo "🌟🌟🌟 https://github.com/Kyle-Ye/XcodeLLMEligible 🌟🌟🌟" - ;; - uninstall) - uninstall - echo "XcodeLLM eligible override script uninstall completed." - ;; - *) - echo "Unknown action: $action" - echo "Usage: $0 [install|uninstall]" - exit 1 - ;; -esac \ No newline at end of file