Skip to content

Commit

Permalink
osx: add pkg uninstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Mar 24, 2024
1 parent a3dbc84 commit b5086d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ osx: | dist
cp dist/snclient build-pkg/usr/local/bin/
chmod 755 build-pkg/usr/local/bin/snclient

cp packaging/osx/uninstall.sh build-pkg/usr/local/bin/snclient_uninstall.sh
chmod 755 build-pkg/usr/local/bin/snclient_uninstall.sh

cp dist/snclient.ini dist/server.crt dist/server.key dist/cacert.pem build-pkg/etc/snclient

$(SED) \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ Find a brief overview of what is planned and what is done already:
* [ ] improve configuration
* [ ] add config validator
* [ ] use strong typed config items
* [ ] osx
* [ ] check pkg uninstall
* [X] osx
* [X] check pkg uninstall
* [X] rename packages to avoid confusion: amd64 -> x86-64, 386 -> i386, amd64 -> aarch64

## Not gonna happen
Expand Down
26 changes: 26 additions & 0 deletions packaging/osx/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

if [ "$(id -nu)" -ne "root" ]; then
exit 1
fi

# stop the agent
launchctl unload /Library/LaunchDaemons/com.snclient.snclient.plist

# remove all files
rm -rf /etc/snclient/snclient.ini
rm -rf /etc/snclient/cacert.pem
rm -rf /etc/snclient/server.crt
rm -rf /etc/snclient/server.key
rmdir /etc/snclient >/dev/null 2>&1
rm -rf /var/log/snclient
rm -rf /usr/local/bin/node_exporter
rm -rf /usr/local/bin/snclient
rm -rf /usr/local/share/man/man*/snclient.*
rm -rf /Library/LaunchDaemons/com.snclient.snclient.plist

# remove pkg from pkg database
pkgutil --forget com.snclient.snclient

# remove this script
rm -rf /usr/local/bin/snclient_uninstall.sh

0 comments on commit b5086d2

Please sign in to comment.