forked from simoniz0r/gpgpassman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpminst
executable file
·102 lines (98 loc) · 3.98 KB
/
gpminst
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
97
98
99
100
101
102
#!/bin/bash
# Installs and uninstalls gpgpassman using wget
main () {
case $1 in
install)
read -p "Install gpgpassman to /usr/bin/gpgpassman? Y/N " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "gpgpassman was not installed."
exit 0
fi
wget -O /tmp/gpgpassman https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.sh || { echo "Download failed!" ; exit 0 ; }
if [ -f "/tmp/gpgpassman" ]; then
wget -O /tmp/gpgpassman.png https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.png || { echo "Download failed!" ; exit 0 ; }
if [ -f "/tmp/gpgpassman.png" ]; then
wget -O /tmp/gpgpassman.desktop https://raw.githubusercontent.com/jmfgdev/gpgpassman/master/gpgpassman.desktop || { echo "Download failed!" ; exit 0 ; }
if [ -f "/tmp/gpgpassman.desktop" ]; then
echo "Moving gpgpassman to /usr/bin/gpgpassman"
mv /tmp/gpgpassman /usr/bin/gpgpassman
echo "Making gpgpassman executable"
chmod +x /usr/bin/gpgpassman
echo "Moving gpgpassman icon to /usr/share/icons/gpgpassman.png"
mv /tmp/gpgpassman.png /usr/share/icons/gpgpassman.png
echo "Moving .desktop file to /usr/share/applications/gpgpassman.desktop"
mv /tmp/gpgpassman.desktop /usr/share/applications/gpgpassman.desktop
else
echo ".desktop file download failed; try installing again."
rm -f /tmp/gpgpassman.sh
rm -f /tmp/gpgpassman.png
exit 0
fi
else
echo "Icon download failed; try installing again."
rm -f /tmp/gpgpassman.sh
exit 0
fi
else
echo "gpgpassman download failed; try installing again."
exit 0
fi
;;
uninstall)
read -p "Uninstall gpgpassman from /usr/bin/gpgpassman? Y/N " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "gpgpassman was not uninstalled."
exit 0
fi
if [ -f "/usr/bin/gpgpassman" ]; then
rm -f /usr/bin/gpgpassman
echo "gpgpassman has been removed!"
else
echo "/usr/bin/gpgpassman does not exist!"
fi
if [ -f "/usr/share/icons/gpgpassman.png" ]; then
rm -f /usr/share/icons/gpgpassman.png
echo "gpgpassman.png has been removed!"
else
echo "gpgpassman.png does not exist!"
fi
if [ -f "/usr/share/applications/gpgpassman.desktop" ]; then
rm -f /usr/share/applications/gpgpassman.desktop
echo "gpgpassman.desktop has been removed!"
else
echo "gpgpassman.desktop does not exist!"
fi
exit 0
;;
help)
echo "Usage:"
echo "'sudo ./gpminst install' for installation process"
echo "'sudo ./gpminst uninstall' for uninstallation process"
exit 0
;;
*)
read -p "What would you like to do? install/uninstall "
echo
main "$REPLY"
esac
}
programisinstalled () {
# set to 1 initially
return=1
# set to 0 if not found
type "$1" >/dev/null 2>&1 || { return=0; }
# return value
}
if [ "$EUID" -ne 0 ]; then
echo "gpminst install and uninstall must be ran as root!"
main "help"
exit 0
fi
programisinstalled "wget"
if [ "$return" = "1" ]; then
main "$1"
else
echo "wget is not installed; cannot download gpgpassman."
fi