Skip to content

Instantly share code, notes, and snippets.

@wancw
Last active July 4, 2023 09:34
Show Gist options
  • Save wancw/61c629b78bad206816ae4b58913a7cd8 to your computer and use it in GitHub Desktop.
Save wancw/61c629b78bad206816ae4b58913a7cd8 to your computer and use it in GitHub Desktop.
移除 macOS 健保卡元件

檔案說明

  • removeNHIICC.sh : 移除健保卡元件與相關設定,須以 root (sudo) 權限執行。
  • postinstall.sh : 官方「MAC 元件移除安裝檔」的 script 內容(2020)
launchctl unload /Library/LaunchDaemons/NHIICC.plist
# or "killall macHC"
security remove-trusted-cert -d /Library/StartupItems/NHIICC/cert/NHIServerCert.crt
security delete-certificate -c NHI.Self.Server.Cert
rm -r /Library/StartupItems/NHIICC
rm /Library/LaunchDaemons/NHIICC.plist
rm -r /usr/local/share/NHIICC
rm -r /Users/Shared/share/NHIICC
rmdir /Users/Shared/share
pkgutil --forget com.NHI.pkg.macInstall
sed -i .bak -e '/iccert\.nhi\.gov\.tw/d' /etc/hosts
#!/bin/bash
sudo killall macHC;
sudo rm -R /usr/local/share/NHIICC
sudo rm -R /Users/Shared/share/NHIICC
sudo rm /Library/StartupItems/NHIICC/NHIICC
sudo rm /Library/StartupItems/NHIICC/StartupParameters.plist
sudo rm /Library/LaunchDaemons/NHIICC.plist
@10chu
Copy link

10chu commented Aug 28, 2022

Thanks, your script has been really helpful. Here are a few updates as I ran it in August 2022

removeHHIICC.sh

NHIICC.plist has been replaced by the two new plists below

#launchctl unload /Library/LaunchDaemons/NHIICC.plist
launchctl remove tw.gov.nhi.nhiicc.plist
launchctl remove tw.gov.nhi.nhiicc2019.plist

security remove-trusted-cert -d /Library/StartupItems/NHIICC/cert/NHIServerCert.crt
security delete-certificate -c NHI.Self.Server.Cert

rm -r /Library/StartupItems/NHIICC

NHIICC.plist has been removed by the two new plists below

#rm /Library/LaunchDaemons/NHIICC.plist
rm /Library/LaunchDaemons/tw.gov.nhi.nhiicc.plist
rm /Library/LaunchDaemons/tw.gov.nhi.nhiicc2019.plist
rm -r /usr/local/share/NHIICC

Run the pkgutil --files command to list all the files installed by the package

pkgutil --files gov.nhi.macHC
rm -r /Users/Shared/share/NHIICC
rm -r /Users/Shared/share

The package name has been changed to gov.nhi.macHC

#pkgutil --forget com.NHI.pkg.macInstall
pkgutil --forget gov.nhi.macHC

The following is no longer needed

#sed -i .bak -e '/iccert.nhi.gov.tw/d' /etc/hosts

@wancw
Copy link
Author

wancw commented Aug 29, 2022

@10chu Thanks for the update, I will make a new version later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment