aboutsummarylogtreecommitdiffstats
path: root/overgrive.install
blob: dd39a8ca0e46cad8370f9a56dadc0d3f2ecd8ed1 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
post_install() {
	gtk-update-icon-cache -q -t -f usr/share/icons/hicolor
    
    # virtual environement to avoid pip changing system packages
    python3 -m venv --system-site-packages /opt/thefanclub/overgrive/venv
    /opt/thefanclub/overgrive/venv/bin/pip3 install --upgrade google-api-python-client

    # Recomplie Schemas for good measure
    if [ -f /usr/bin/glib-compile-schemas ]
    then
        /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas/
    fi

    # Choose cpython interpreter for overgrive and copy correct compiled version and remove folder
    if [ -d /opt/thefanclub/overgrive/__pycache__ ]
    then
        cp /opt/thefanclub/overgrive/__pycache__/$(ls /opt/thefanclub/overgrive/__pycache__ |  grep $(python3 -V | cut -d' ' -f2 | cut -d'.' -f1-2 | sed 's/\.//g')) /opt/thefanclub/overgrive/overgrive
        rm -R /opt/thefanclub/overgrive/__pycache__
        chmod 0755 /opt/thefanclub/overgrive/overgrive
    fi
}

post_upgrade() {
	post_install
}

pre_remove() {
    # stop application if running
	if ( pgrep overgrive > /dev/null )
    then
        pkill -9 ^overgrive
   fi

	# Set English as Shell output language
	LANG=en_US.UTF-8
	export LC_ALL=en_US.UTF-8
	userName=$(eval echo $SUDO_USER) 
	userHome=$(eval echo ~${SUDO_USER})

	if [ -f /tmp/overgrive.lock ]
	then
	   # check if indicator is running 
	   checkFlock=$(cat /tmp/overgrive.lock)

	   if [ ! "$checkFlock" = "" ] 
	   then
	     kill $checkFlock 2>/dev/null || true
	     rm /tmp/overgrive.lock
	   fi
	fi

	if [ -f  "$userHome/.config/autostart/overgrive-autostart.desktop" ]
	then 
	   rm  "$userHome/.config/autostart/overgrive-autostart.desktop"
	fi
	
    if [ -f  "$userHome/.config/autostart/overgrive.desktop" ]
	then 
	   rm  "$userHome/.config/autostart/overgrive.desktop"
	fi


	if [ -f  "/opt/thefanclub/overgrive/overgrive" ]
	then 
	   rm  "/opt/thefanclub/overgrive/overgrive"
	fi
}

post_remove() {
    sudo rm -rf /opt/thefanclub/overgrive/
    
    if [ -z "$(ls -A /opt/thefanclub/)" ]
    then
        sudo rmdir /opt/thefanclub/
    fi

	gtk-update-icon-cache -q -t -f usr/share/icons/hicolor
	update-desktop-database -q
}