Skip to content
Snippets Groups Projects
Unverified Commit 8d274032 authored by Kali Kaneko's avatar Kali Kaneko Committed by meskio
Browse files

[pkg] osx uninstall, autolaunch

parent 0a432c12
No related branches found
No related tags found
No related merge requests found
......@@ -111,6 +111,7 @@ ifeq (${PLATFORM}, darwin)
@cp "${TEMPLATES}/osx/client.up.sh" ${OSX_DATA}/
@cp "${TEMPLATES}/osx/client.down.sh" ${OSX_DATA}/
@cp "${TEMPLATES}/qtinstaller/osx/post-install.py" ${OSX_DATA}/
@cp "${TEMPLATES}/qtinstaller/osx/uninstall.py" ${OSX_DATA}/
@cp "${TEMPLATES}/qtinstaller/osx/se.leap.bitmask-helper.plist" ${OSX_DATA}/
@cp build/bin/${PLATFORM}/bitmask-helper ${OSX_DATA}/
# FIXME our static openvpn build fails with an "Assertion failed at crypto.c". Needs to be fixed!!! - kali
......
......@@ -8,6 +8,7 @@ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
macx {
LIBS += -framework Security
# TODO -- pass the vendor icon here from Makefile.
ICON = branding/assets/riseup/icon.icns
}
......
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>DemoLibVPN-0.0.1</Name>
<Version>0.0.1</Version>
<Title>DemoLibVPN Installer</Title>
<Publisher>LEAP Encryption Access Project</Publisher>
<TargetDir>@ApplicationsDir@/DemoLibVPN.app</TargetDir>
<RunProgram>@TargetDir@/DemoLibVPN.app</RunProgram>
<RunProgramArguments>
</RunProgramArguments>
<StartMenuDir>DemoLibVPN.app</StartMenuDir>
<AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
<!--
<RemoteRepositories>
<Repository>
<Url>http://localhost/repository/</Url>
</Repository>
<Repository>
<Url>http://localhost/repository/</Url>
</Repository>
</RemoteRepositories>
-->
<MaintenanceToolName>Uninstall-DemoLibVPN</MaintenanceToolName>
<!-- osx run -->
<RunProgram>open</RunProgram>
<RunProgramDescription>Start DemoLibVPN now!</RunProgramDescription>
<RunProgramArguments>
<Argument>@TargetDir@</Argument>
</RunProgramArguments>
<WizardStyle>mac</WizardStyle>
<!-- end osx run -->
</Installer>
......@@ -12,6 +12,7 @@ import subprocess
HELPER = "bitmask-helper"
HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist"
_dir = os.path.dirname(os.path.realpath(__file__))
def main():
......@@ -73,13 +74,12 @@ def fixHelperOwner(log):
def copyLaunchDaemon():
plist = "se.leap.bitmask-helper.plist"
path = os.path.join(_dir, plist)
dest = os.path.join('/Library/LaunchDaemons', plist)
_p = _dir.replace("/", "\/")
subprocess.call(["sed", "-i.back", "s/PATH/%s/" % _p, path])
shutil.copy(path, dest)
shutil.copy(path, HELPER_PLIST)
def launchHelper():
out = subprocess.call(["launchctl", "load", "/Library/LaunchDaemons/se.leap.bitmask-helper.plist"])
out = subprocess.call(["launchctl", "load", HELPER_PLIST])
return out == 0
def grantPermissionsOnLogFolder():
......
#!/usr/bin/env python
# Uninstall script for BitmaskVPN.
import os
import shutil
import sys
import subprocess
HELPER = "bitmask-helper"
HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist"
_dir = os.path.dirname(os.path.realpath(__file__))
def main():
log = open(os.path.join('/tmp', 'bitmask-uninstall.log'), 'w')
log.write('Checking for admin privileges...\n')
_id = os.getuid()
log.write("UID: %s\n" % str(_id))
if int(_id) != 0:
err = "error: need to run as root. UID: %s\n" % str(_id)
logErr(log, err)
# failure: sys.exit(1)
log.write('Checking if helper is running')
if isHelperRunning():
log.write("Trying to stop bitmask-helper...\n")
# if this fail, we can check if the HELPER_PLIST is there
ok = unloadHelper()
log.write("success: %s \n" % str(ok))
log.write("Removing LaunchDaemon")
out = removeLaunchDaemon()
log.write("result: %s \n" % str(out))
# all done
log.write('uninstall script: done\n')
sys.exit(0)
def logErr(log, msg):
log.write(msg)
sys.exit(1)
def isHelperRunning():
ps = _getProcessList()
return HELPER in ps
def unloadHelper():
out = subprocess.call(["launchctl", "unload", HELPER_PLIST])
out2 = subprocess.call(["pkill", "-9", "bitmask-helper"]) # just in case
return out == 0
def removeLaunchDaemon():
return subprocess.call(["rm", "-f", HELPER_PLIST])
def _getProcessList():
_out = []
output = subprocess.Popen(["ps", "-ceA"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = output.communicate()
for line in stdout.split('\n'):
cmd = line.split(' ')[-1]
_out.append(cmd.strip())
return _out
if __name__ == "__main__":
main()
......@@ -27,23 +27,44 @@ Component.prototype.createOperations = function ()
}
}
Component.prototype.installationFinished = function()
{
console.log("DEBUG: running installationFinished");
if (installer.isInstaller() && installer.status == QInstaller.Success) {
var argList = ["-a", "@TargetDir@/DemoLibVPN.app"];
try {
installer.execute("touch", ["/tmp/install-finished"]);
installer.execute("open", argList);
} catch(e) {
console.log(e);
}
}
}
function postInstallWindows() {
component.addOperation(
"CreateShortcut",
"@TargetDir@/README.txt",
"@StartMenuDir@/README.lnk",
"workingDirectory=@TargetDir@",
"iconPath=%SystemRoot%/system32/SHELL32.dll",
"iconId=2");
component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "install", "UNDOEXECUTE", "@TargetDir@/helper.exe", "remove");
component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "start", "UNDOEXECUTE", "@TargetDir@/helper.exe", "stop");
console.log("Adding shortcut entries");
component.addElevatedOperation("Mkdir", "@StartMenuDir@");
component.addElevatedOperation("CreateShortcut", "@TargetDir@/demolib-vpn.exe", "@StartMenuDir@/DemoLibVPN.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/icon.ico", "description=Start DemoLibVPN");
// TODO I think this one is not being created because the path doesn't exist yet. We might want to do this by hooking on the installation finished signal instead.
component.addElevatedOperation(
"CreateShortcut",
"@TargetDir@/Uninstall-DemoLibVPN.exe",
"@StartMenuDir@/Uninstall.lnk"
);
}
function postInstallOSX() {
console.log("Post-installation for OSX");
// TODO add UNDOEXECUTE for the uninstaller
component.addElevatedOperation(
"Execute", "{0}",
"@TargetDir@/post-install.py",
"errormessage=There was an error during the post-installation script, things might be broken. Please report this error and attach the post-install.log file.");
"errormessage=There was an error during the post-installation script, things might be broken. Please report this error and attach the post-install.log file.",
"UNDOEXECUTE",
"@TargetDir@/uninstall.py"
);
}
function postInstallLinux() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment