blob: 3369d3397fac491df49caef8d223706b5fdee2bd (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
pre_install() {
remove_pt ()
{
if [ -e /opt/pt ]; then
echo "Removing old version of Packet Tracer from /opt/pt"
sudo rm -rf /opt/pt
sudo rm -rf /usr/share/applications/cisco-pt7.desktop
sudo rm -rf /usr/share/applications/cisco-ptsa7.desktop
sudo rm -rf /usr/share/icons/hicolor/48x48/apps/pt7.png
fi
if [ -e /opt/packettracer/ ]; then
echo "Removing old version of Packet Tracer from /opt/packettracer/"
sudo rm -rf /opt/packettracer/
sudo rm -rf /usr/share/applications/cisco-pt7.desktop
sudo rm -rf /usr/share/applications/cisco-ptsa7.desktop
sudo rm -rf /usr/share/icons/hicolor/48x48/apps/pt7.png
fi
}
}
post_install() {
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
# update icon and file assocation
sudo xdg-desktop-menu install /usr/share/applications/cisco-pt7.desktop
sudo update-mime-database /usr/share/mime
sudo gtk-update-icon-cache --force /usr/share/icons/gnome
# sets the incoming PTDIR as a system environment variable
# sets the Qt high resolution as a system environment variable
# by modifying /etc/profile
PTDIR="/opt/packettracer/"
# create shortcut
sudo ln -sf $PTDIR/packettracer /usr/bin/packettracer
# check /etc/profile for existance of PT7HOME
PROFILE="/etc/profile"
# error exit if file does not exist or unreadable
if [ ! -f $PROFILE ]; then
exit 1
elif [ ! -r $PROFILE ]; then
exit 2
fi
# read contents
CONTENTS=""
EXPORT_EXISTS=0
PT7HOME_EXISTS=0
PT7HOME_FOUND=0
EXPORT_QT_EXISTS=0
QT_EXISTS=0
QT_FOUND=0
exec 3<&0
exec 0<$PROFILE
while IFS= read -r line
do
# replace existing entries
PT7HOME_FOUND=$(expr match "$line" 'PT7HOME')
if [ "$PT7HOME_FOUND" -gt 0 ]; then
line="PT7HOME=$PTDIR"
PT7HOME_EXISTS=1
fi
QT_FOUND=$(expr match "$line" 'QT_DEVICE_PIXEL_RATIO')
if [ "$QT_FOUND" -gt 0 ]; then
line="QT_DEVICE_PIXEL_RATIO=auto"
QT_EXISTS=1
fi
# check for export statement
if [ $EXPORT_EXISTS -eq 0 ]; then
EXPORT_QT_EXISTS=$(expr match "$line" 'export QT_DEVICE_PIXEL_RATIO')
fi
if [ "$EXPORT_QT_EXISTS" -eq 0 ]; then
EXPORT_QT_EXISTS=$(expr match "$line" 'export QT_DEVICE_PIXEL_RATIO')
fi
#append the line to the contents
CONTENTS="$CONTENTS
$line"
done
exec 0<&3
if [ $PT7HOME_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS
PT7HOME=$PTDIR"
fi
if [ $EXPORT_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS
export PT7HOME"
fi
if [ $QT_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS
QT_DEVICE_PIXEL_RATIO=auto"
fi
if [ $EXPORT_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS
export QT_DEVICE_PIXEL_RATIO"
fi
sudo echo -e "$CONTENTS" | sudo tee /etc/profile > /dev/null
sudo sed '1{/^$/d}' -i /etc/profile > /dev/null
update-desktop-database -q
}
pre_upgrade() {
pre_install
}
post_upgrade() {
post_install
}
post_remove() {
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
sudo xdg-desktop-menu uninstall /usr/share/applications/cisco-pt7.desktop
sudo xdg-desktop-menu uninstall /usr/share/applications/cisco-ptsa7.desktop
sudo update-mime-database /usr/share/mime
sudo gtk-update-icon-cache --force /usr/share/icons/gnome
sudo rm -f /usr/bin/packettracer
# check /etc/profile for existance of PT7HOME
PROFILE="/etc/profile"
# error exit if file does not exist or unreadable
if [ ! -f $PROFILE ]; then
true
elif [ ! -r $PROFILE ]; then
true
fi
# read contents
exec 3<&0
exec 0<$PROFILE
while IFS= read -r line
do
PT7HOME_FOUND=$(expr match "$line" 'PT7HOME')
if [ "$PT7HOME_FOUND" -gt 0 ]; then
continue
fi
QT_FOUND=$(expr match "$line" 'QT_DEVICE_PIXEL_RATIO')
if [ "$QT_FOUND" -gt 0 ]; then
continue
fi
EXPORT_FOUND=$(expr match "$line" 'export PT7HOME')
if [ "$EXPORT_FOUND" -gt 0 ]; then
continue
fi
EXPORT_QT_FOUND=$(expr match "$line" 'export QT_DEVICE_PIXEL_RATIO')
if [ "$EXPORT_QT_FOUND" -gt 0 ]; then
continue
fi
CONTENTS="$CONTENTS
$line"
done
exec 0<&3
sudo echo -e "$CONTENTS" | sudo tee /etc/profile > /dev/null
sudo sed '1{/^$/d}' -i /etc/profile > /dev/null
update-desktop-database -q
}
|