summarylogtreecommitdiffstats
path: root/xdroid-installer.py
blob: 5fa9f0e29369133e941aece246cd3b30633120f4 (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
37
38
39
#!/usr/bin/python

import os, sys

try:
    import easygui as eg
    dialogs = True
except:
    dialogs = False

uninstaller = '/opt/xdroid/remove-xdroid-launcher'

def install():
    sys.exit(os.system('tar -xzvf /opt/xdroid-installer/xdroid.tar.gz -C /tmp \
                        && /tmp/xDroidInstall-x86_64/install.sh'))

if os.getuid() == 0:
    err = "Don't run this installer as root!"
    if dialogs:
        eg.msgbox(err, "Error!")
        sys.exit(1)
    else:
        raise OSError(err)

if os.path.isfile(uninstaller):

    if dialogs:
        option = eg.choicebox("Do you want to reinstall or uninstall xDroid?", "xDroid Installer",
                            choices=["Reinstall", "Uninstall"])
    else:
        option = "Uninstall"

    if option == "Reinstall":
        install()
    elif option == "Uninstall":
        os.system(uninstaller)

else:
    install()