summarylogtreecommitdiffstats
path: root/xdroid-installer.py
blob: c9ac977771c31116ba7e6ce6510075ccfd65f1c5 (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
40
41
42
#!/usr/bin/python

import os, sys

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

uninstaller = '/opt/xdroid/remove-xdroid-launcher'
reinstall = 'Upgrade/Reinstall'
uninstall = 'Uninstall'

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("You have xDroid installed already. What do you want to do next?", 
                            title="xDroid Installer",
                            choices=[reinstall, uninstall])
    else:
        option = uninstall

    if option == reinstall:
        install()
    elif option == uninstall:
        os.system(uninstaller)

else:
    install()