summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/helpers/__init__.py
blob: dc2492862da78affec558e94d1758ee518439a8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from os import remove
from shutil import copyfile
import sys

from leap.bitmask.vpn.constants import IS_LINUX
from leap.bitmask.vpn import _config

if IS_LINUX:

    helper_to = '/usr/local/sbin/bitmask-root'
    polkit_to = '/usr/share/polkit-1/actions/se.bitmask.bundle.policy'

    def install():
        helper_from = _config.get_bitmask_helper_path()
        polkit_from = _config.get_bitmask_polkit_policy_path()
        copyfile(helper_from, helper_to)
        os.chmod(helper_to, 0744)
        copyfile(polkit_from, polkit_to)

    def uninstall():
        try:
            remove(helper_to)
            remove(polkit_to)
        except:
            raise


def main():
    if sys.argv[-1] == 'install':
        install()
    if sys.argv[-1] == 'uninstall':
        uninstall()


if __name__ == "__main__":
    main()