summaryrefslogtreecommitdiff
path: root/branding/templates/qtinstaller/osx
diff options
context:
space:
mode:
authorkali <kali@leap.se>2020-10-08 03:04:25 +0200
committerRuben Pollan <meskio@sindominio.net>2020-10-13 19:08:50 +0200
commit4d9d578902aae37d62ea3218efa2b062cb7f893f (patch)
tree39c96fc5d3cb7703e2fbea07e5782fcdb4b4189a /branding/templates/qtinstaller/osx
parentc77ba97502da5c954447abf738ab78108d1b0892 (diff)
[pkg] parametrize win/osx installer
Diffstat (limited to 'branding/templates/qtinstaller/osx')
-rwxr-xr-xbranding/templates/qtinstaller/osx/post-install.py103
-rw-r--r--branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist26
-rwxr-xr-xbranding/templates/qtinstaller/osx/uninstall.py70
3 files changed, 0 insertions, 199 deletions
diff --git a/branding/templates/qtinstaller/osx/post-install.py b/branding/templates/qtinstaller/osx/post-install.py
deleted file mode 100755
index 2c15845..0000000
--- a/branding/templates/qtinstaller/osx/post-install.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env python
-
-# Post installation script for BitmaskVPN.
-# Please note that this installation will install ONE single helper with administrative privileges.
-# This means that, for the time being, you can only install ONE of the BitmaskVPN derivatives at the same time.
-# This might change in the future.
-
-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(_dir, 'post-install.log'), 'w')
- log.write('Checking for admin privileges...\n')
-
- _id = os.getuid()
- if _id != 0:
- err = "error: need to run as root. UID: %s\n" % str(_id)
- logErr(log, err)
-
- # failure: sys.exit(1)
-
- 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))
-
- ok = fixHelperOwner(log)
- log.write("chown helper: %s \n" % str(ok))
-
- log.write("Copy launch daemon...\n")
- copyLaunchDaemon()
-
- log.write("Trying to launch helper...\n")
- out = launchHelper()
- log.write("result: %s \n" % str(out))
-
- grantPermissionsOnLogFolder()
-
- # all done
- log.write('post-install 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 fixHelperOwner(log):
- path = os.path.join(_dir, HELPER)
- try:
- os.chown(path, 0, 0)
- except OSError as exc:
- log.write(str(exc))
- return False
- return True
-
-def copyLaunchDaemon():
- plist = "se.leap.bitmask-helper.plist"
- path = os.path.join(_dir, plist)
- _p = _dir.replace("/", "\/")
- subprocess.call(["sed", "-i.back", "s/PATH/%s/" % _p, path])
- shutil.copy(path, HELPER_PLIST)
-
-def launchHelper():
- out = subprocess.call(["launchctl", "load", HELPER_PLIST])
- return out == 0
-
-def grantPermissionsOnLogFolder():
- helperDir = os.path.join(_dir, 'helper')
- try:
- os.makedirs(helperDir)
- except Exception:
- pass
- os.chown(helperDir, 0, 0)
-
-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()
diff --git a/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist b/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist
deleted file mode 100644
index c333aba..0000000
--- a/branding/templates/qtinstaller/osx/se.leap.bitmask-helper.plist
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>WorkingDirectory</key>
- <string>PATH</string>
- <key>StandardOutPath</key>
- <string>PATH/helper/bitmask-helper.log</string>
- <key>StandardErrorPath</key>
- <string>PATH/helper/bitmask-helper-err.log</string>
- <key>GroupName</key>
- <string>daemon</string>
- <key>RunAtLoad</key>
- <true/>
- <key>SessionCreate</key>
- <true/>
- <key>KeepAlive</key>
- <true/>
- <key>ThrottleInterval</key>
- <integer>5</integer>
- <key>Label</key>
- <string>se.leap.BitmaskHelper</string>
- <key>Program</key>
- <string>PATH/bitmask-helper</string>
-</dict>
-</plist>
diff --git a/branding/templates/qtinstaller/osx/uninstall.py b/branding/templates/qtinstaller/osx/uninstall.py
deleted file mode 100755
index 7aa8a56..0000000
--- a/branding/templates/qtinstaller/osx/uninstall.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/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()