This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpt730_centos8_install.sh
168 lines (135 loc) · 4.08 KB
/
pt730_centos8_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
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
#!/bin/bash
# Install dependencies
sudo dnf -y install epel-release
sudo dnf -y install https://rpmfind.net/linux/opensuse/distribution/leap/15.2/repo/oss/x86_64/libjpeg8-8.1.2-lp152.7.3.x86_64.rpm double-conversion.x86_64 git qt5-qtwebkit qt5-qtmultimedia qt5-qtsvg qt5-qtscript libpng12
git clone https://github.com/sincorchetes/packettracer
cd packettracer ./bootstrap.sh
sudo cp libcrypto.so.1.0.0 /lib64
# Configure links for libs
sudo ln -s /lib64/libicui18n.so.65.1 /lib64/libicui18n.so.60
sudo ln -s /lib64/libicuuc.so.65.1 /lib64/libicuuc.so.60
sudo ln -s /lib64/libdouble-conversion.so.3.1.5 /lib64/libdouble-conversion.so.1
# Extract from offical package
ar -x PacketTracer_730_amd64.deb data.tar.xz
tar -xvf data.tar.xz
# Taken from the official package
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
}
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/local/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 0
elif [ ! -r $PROFILE ]; then
exit 0
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\n$line"
done
exec 0<&3
# My append
sudo cp -r opt/* /opt
sudo cp -r usr/* /usr
cd /opt/pt
# Taken from the official package
sudo echo -e "$CONTENTS" > /etc/profile
# update icon and file assocation
sudo xdg-desktop-menu install /usr/share/applications/cisco-pt7.desktop
sudo xdg-desktop-menu install /usr/share/applications/cisco-ptsa7.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/pt"
# create shortcut
sudo ln -sf $PTDIR/packettracer /usr/local/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_EXISTS=`expr match "$line" 'export PT7HOME'`
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\n$line"
done
exec 0<&3
if [ $PT7HOME_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS\nPT7HOME=$PTDIR"
fi
if [ $EXPORT_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS\nexport PT7HOME"
fi
if [ $QT_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS\nQT_DEVICE_PIXEL_RATIO=auto"
fi
if [ $EXPORT_EXISTS -eq 0 ]; then
CONTENTS="$CONTENTS\nexport QT_DEVICE_PIXEL_RATIO"
fi
sudo echo -e "$CONTENTS" > /etc/profile
exit 0