-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
executable file
·96 lines (78 loc) · 2.48 KB
/
install.sh
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/bash
path="${HOME}/.local/share"
mkdir -p "$path/loyaltyCardsOpen"
sed -i "s|/usr/local/loyaltycardsopen/|$path/loyaltyCardsOpen/|g" ./loyaltyCards.py
if [ $? -ne 0 ]; then
echo ""
echo "Could not create folder '$path/loyaltyCardsOpen'"
exit
fi
echo ""
echo "Copying download folder to $path/loyaltyCardsOpen"
# remove any existing backup files and ignore any errors
rm "$path/loyaltyCardsOpen/*.bak" 2> /dev/null
# copy the updated files
cp -ruS .bak ./* "$path/loyaltyCardsOpen"
if [ $? -ne 0 ]; then
echo ""
echo "Could not copy download folder to $path/loyaltyCardsOpen"
exit
fi
# offer to copy back the database and config files
if [ -e "$path/loyaltyCardsOpen/loyaltyCardsDb.db.bak" ];then
echo -n "Do you want to restore the loyaltyCards database? (Y/n)? "
read -n 1 ans
echo ""
case $ans in
[N|n])
# do nothing
;;
*)
mv "$path/loyaltyCardsOpen/loyaltyCardsDb.db" "$path/loyaltyCardsOpen/loyaltyCardsDb.db.new"
mv "$path/loyaltyCardsOpen/loyaltyCardsDb.db.bak" "$path/loyaltyCardsOpen/loyaltyCardsDb.db"
if [ $? -ne 0 ]; then
echo ""
echo "Could not recover loyaltyCards database ($path/loyaltyCardsOpen/loyaltyCardsDb.db.bak)"
mv "$path/loyaltyCardsOpen/loyaltyCardsDb.db.new" "$path/loyaltyCardsOpen/loyaltyCardsDb.db"
echo ""
else
rm "$path/loyaltyCardsOpen/loyaltyCardsDb.db.new"
fi
;;
esac
fi
echo ""
echo "Create a new desktop file"
rm -f "$path/applications/loyaltyCards.desktop"
echo "[Desktop Entry]
Name=Loyalty Cards Open
GenericName=Cards DDBB
X-GNOME-FullName=Loyalty Cards Open
Comment=A linux app to save your cards digitally and empty your pockets of cards.
Keywords=Loyalty Cards Open; store cards;
Exec="$path/loyaltyCardsOpen/loyaltyCards.sh"
Terminal=false
StartupNotify=true
Type=Application
Icon=$path/loyaltyCardsOpen/loyaltycardsopen.svg
Categories=GNOME;GTK;Utility;
MimeType=application/python;
Name[en_US]=Loyalty Cards Open
X-Purism-FormFactor=Workstation;Mobile;" > "$path/applications/loyaltyCards.desktop"
if [ $? -ne 0 ]; then
echo ""
echo "Could not create desktop file in to $path/applications"
exit
fi
rm -f "$path/loyaltyCards.sh"
echo "#!/usr/bin/bash
cd '$path/loyaltyCardsOpen'
python3 loyaltyCards.py" > "$path/loyaltyCardsOpen/loyaltyCards.sh"
chmod 0755 "$path/loyaltyCardsOpen/loyaltyCards.sh"
if [ $? -ne 0 ]; then
echo ""
echo "Could not create shell script in to $path/loyaltyCards"
exit
fi
echo ""
echo "Install complete - you may (optionally) remove the download folder"