summarylogtreecommitdiffstats
path: root/b1freearchiver.install
blob: 0919198a3752183de8d1e3c57f5c397172834e0c (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
update_desktop() {

  xdg-icon-resource forceupdate --theme hicolor &>/dev/null
  update-mime-database /usr/share/mime &>/dev/null
  update-desktop-database -q

}

post_install() {

update_desktop

echo "Starting python script for procesing uuid."

python - <<END

CONFIG_DIR = '/etc/xdg/b1.org'
CONFIG_INI = '/etc/xdg/b1.org/B1Manager.conf'

import sys
import os
import uuid
from configparser import RawConfigParser as ConfParser
from configparser import Error

p = ConfParser()
p.optionxform = str

try:
    results = p.read(CONFIG_INI)
except Error as msg:
    if not os.path.exists(CONFIG_DIR):
        os.makedirs(CONFIG_DIR)
    with open('example.cfg', 'w') as configfile:
        configfile.write('[General]\n')
        configfile.write('UID = {%s}\n'%str(uuid.uuid1()))
    sys.exit(0)
else:
    if 'General' in p.sections():
        b1_uuid = p.get('General', 'UID')
    else:
        b1_uuid = None

    if (b1_uuid is not None) and (len(b1_uuid) > 0):
            sys.exit(0)
    else:
        p.add_section('General')
    
    p.set('General', 'UID', '{%s}'%str(uuid.uuid1()))
    if not os.path.exists(CONFIG_DIR):
        os.makedirs(CONFIG_DIR)
    with open(CONFIG_INI, 'w') as configfile:
        p.write(configfile)
    sys.exit(0)

END

}

post_upgrade() {

  update_desktop

}

post_remove() {

  update_desktop

}