make macos uninstaller actually kill and uninstall lokinet (#1484)

* macos fluff

* make uninstaller work, the uninstall script needs to be called with /usr/bin/sudo to work because god know why it needs that even though it's already root.
* add logrotation
* make the uninstall script kill all the things

* revert

* use correct regular expression

* remove logrotate configs rename logrotate config file name to be more descriptive
This commit is contained in:
Jeff 2020-11-18 17:06:48 -05:00 committed by GitHub
parent e62f04c601
commit b18546086a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 20 deletions

View File

@ -54,6 +54,7 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app
# copy files that will be later moved by the postinstall script to proper locations
install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh
${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist
${CMAKE_SOURCE_DIR}/contrib/macos/lokinet-newsyslog.conf
DESTINATION "extra/"
COMPONENT lokinet)

View File

@ -0,0 +1 @@
/var/log/lokinet.log 644 5 5M $D0 J

View File

@ -1,4 +1,6 @@
#!/bin/sh
#!/bin/bash
set -x
test `whoami` == root || exit 1
# this is for dns tomfoolery
scutil_query()
@ -26,22 +28,20 @@ SERVICE_NAME=`scutil_query Setup:/Network/Service/$SERVICE_GUID \
# tell dns to be "empty" so that it's reset
networksetup -setdnsservers "$SERVICE_NAME" empty
# kill the gui
killall LokinetGUI
# shut off exit if it's up
pgrep lokinet$ && /opt/lokinet/bin/lokinet-vpn --down
# Prevent restarting on exit
[ -e /var/lib/lokinet ] && touch /var/lib/lokinet/suspend-launchd-service
# kill it
killall lokinet || true
# Give it some time to shut down before we bring launchd into this
sleep 2
# make sure it's dead
killall -9 lokinet || true
touch /var/lib/lokinet/suspend-launchd-service
# kill the gui and such
killall LokinetGUI
killall lokinet
# if the launch daemon is there kill it
[ -e /Library/LaunchDaemons/network.loki.lokinet.daemon.plist ] && (
launchctl stop network.loki.lokinet.daemon ;
launchctl unload /Library/LaunchDaemons/network.loki.lokinet.daemon.plist
)
/bin/launchctl stop network.loki.lokinet.daemon
/bin/launchctl unload /Library/LaunchDaemons/network.loki.lokinet.daemon.plist
# kill it and make sure it's dead
killall -9 lokinet
rm -rf /Library/LaunchDaemons/network.loki.lokinet.daemon.plist
rm -rf /Applications/Lokinet/
@ -49,4 +49,4 @@ rm -rf /Applications/LokinetGUI.app
rm -rf /var/lib/lokinet
rm -rf /usr/local/lokinet/
rm -rf /opt/lokinet
rm -f /etc/newsyslog.d/lokinet.conf

View File

@ -18,6 +18,10 @@ mv /opt/lokinet/extra/network.loki.lokinet.daemon.plist /Library/LaunchDaemons/
chown $CHOWN /Library/LaunchDaemons/network.loki.lokinet.daemon.plist
chmod 640 /Library/LaunchDaemons/network.loki.lokinet.daemon.plist
mv /opt/lokinet/extra/lokinet-newsyslog.conf /etc/newsyslog.d/lokinet.conf
chown $CHOWN /etc/newsyslog.d/lokinet.conf
chmod 640 /etc/newsyslog.d/lokinet.conf
# clean up by removing 'extra/' (so long as it's empty)
rmdir /opt/lokinet/extra/

View File

@ -33,11 +33,12 @@ int uninstall()
AuthorizationRef authorizationRef;
OSStatus status;
status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef);
char* tool = "/opt/lokinet/bin/lokinet_uninstall.sh";
char* args[] = {nullptr};
FILE* pipe = NULL;
status = AuthorizationCreate(nullptr, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef);
if(status != 0)
return status;
char* tool = "/bin/sh";
char* args[] = {"/opt/lokinet/bin/lokinet_uninstall.sh", nullptr};
FILE* pipe = stdout;
return AuthorizationExecuteWithPrivileges(authorizationRef, tool, kAuthorizationFlagDefaults, args, &pipe);
}