-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
244 lines (212 loc) · 6.38 KB
/
update.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/sh
rm -rf ./.flatpak-builder/ ./build-dir/
RELEASE_TXT=$(curl https://cdn.mikrotik.com/routeros/latest-stable.rss | tee latest-stable.rss | awk '
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
content = ""
pubdate = ""
reldate = ""
release = ""
title = ""
}
/<item>/, /<\/item>/ {
if ($0 ~ /<title>.*<\/title>/) title = trim(gensub(/<title>(.*)<\/title>/, "\\1", "g"))
if ($0 ~ /<content:encoded>.*<\/content:encoded>/) content = trim(gensub(/<content:encoded><!\[CDATA\[(.*);\]\]><\/content:encoded>/, "\\1", "g"))
if ($0 ~ /<pubDate>.*<\/pubDate>/) pubdate = trim(gensub(/<pubDate>(.*)<\/pubDate>/, "\\1", "g"))
}
END {
split(title , a)
release = a[2]
split(pubdate, a)
switch (a[3]) {
case /^[Jj][Aa][Nn]/:
a[3] = 1
break
case /^[Ff][Ee][Bb]/:
a[3] = 2
break
case /^[Mm][Aa][Rr]/:
a[3] = 3
break
case /^[Aa][Pp][Rr]/:
a[3] = 4
break
case /^[Mm][Aa][Yy]/:
a[3] = 5
break
case /^[Jj][Uu][Nn]/:
a[3] = 6
break
case /^[Jj][Uu][Ll]/:
a[3] = 7
break
case /^[Aa][Uu][Gg]/:
a[3] = 8
break
case /^[Ss][Ee][Pp]/:
a[3] = 9
break
case /^[O][Cc][Tt]/:
a[3] = 10
break
case /^[Nn][Oo][Vv]/:
a[3] = 11
break
case /^[Dd][Ee][Cc]/:
a[3] = 12
}
reldate = sprintf("%s-%02d-%s", a[4], a[3], a[2])
print "<releases>"
printf("<release version=\"%s\" date=\"%s\">\n", release, reldate)
printf("<description>\n<p>%s</p>\n", gensub(/<br>/, "\\\n\\\n\\\t", "g", content))
printf("</description>\n</release>\n</releases>\n")
}'
)
RELEASE=$(cat latest-stable.rss | awk '
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
release = ""
title = ""
}
/<item>/, /<\/item>/ {
if ($0 ~ /<title>.*<\/title>/) title = trim(gensub(/<title>(.*)<\/title>/, "\\1", "g"))
}
END {
split(title , a)
print a[2]
}'
)
cat << %E%O%T% >./TheDude.metainfo.xml
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>org.flatpak.TheDude</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LicenseRef-proprietary</project_license>
<name>TheDude</name>
<summary>MikroTik The Dude client</summary>
<developer_name>SIA Mikrotīkls</developer_name>
<update_contact>hfxdanc_AT_gmail.com</update_contact>
<description>
<p>This is a build of The Dude client for Microsoft Windows, packaged for Linux as a Flatpak using Wine.</p>
<p>NOTE: This wrapper is not verified by, affiliated with, sponsored or supported by MikroTīk in any way.</p>
<p>
The Dude network monitor is a new application by MikroTik which can dramatically
improve the way you manage your network environment. It will automatically scan all
devices within specified subnets, draw and layout a map of your networks, monitor
services of your devices and alert you in case some service has problems.
</p>
</description>
<launchable type="desktop-id">org.flatpak.TheDude.desktop</launchable>
<url type="homepage">https://mikrotik.com</url>
<url type="help">https://wiki.mikrotik.com/wiki/Manual:The_Dude</url>
<screenshots>
<screenshot type="default">
<caption>Network Layout</caption>
<image>https://i.mt.lv/img/mt/v2/dude/1f.png</image>
</screenshot>
<screenshot>
<caption>Device view</caption>
<image>https://i.mt.lv/img/mt/v2/dude/2f.png</image>
</screenshot>
<screenshot>
<caption>Network worksheet</caption>
<image>https://i.mt.lv/img/mt/v2/dude/3t.png</image>
</screenshot>
</screenshots>
${RELEASE_TXT}
<content_rating type="oars-1.1"/>
</component>
%E%O%T%
cat << %E%O%T% >./dude-installer.sh
#!/bin/sh
CHOICE=\$(zenity --list \\
--hide-header \\
--hide-column=3 \\
--modal \\
--ok-label="Next >" \\
--print-column=3 \\
--radiolist \\
--text="By downloading any files from mikrotik.com, you agree to the following:\n\t<a href=\"https://mikrotik.com/downloadterms.html\">Export Eligibility Requirements and END USER LICENSE</a>" \\
--title="The Dude client" \\
--width=480 \\
--column="Select" \\
--column="Text" \\
--column="VAR" \\
FALSE "I agree with the above terms and conditions" "TRUE" \\
TRUE "I do not accept the agreement" "FALSE")
# If dialog is cancelled insure default of FALSE is enforced
# shellcheck disable=SC2181
[ \$? -ne 0 ] && CHOICE="FALSE"
if [ "\${CHOICE}" != "TRUE" ]; then
exit 1
fi
(PERCENT=5
echo "# Downloading latest-stable (${RELEASE}) The Dude client"
echo "\${PERCENT}"; sleep 1
mkdir -p "\${WINEPREFIX}/drive_c/Program Files/Dude"
curl --location \\
--output "\${WINEPREFIX}/drive_c/Program Files/Dude/dude-install.exe" \\
https://cdn.mikrotik.com/routeros/${RELEASE}/dude-install-${RELEASE}.exe
PERCENT=30
echo "# Downloading Export Eligibility Requirements and END USER LICENSE"
echo "\${PERCENT}"; sleep 1
curl --location \\
--output "\${WINEPREFIX}/drive_c/Program Files/Dude/LICENSE" \\
https://mikrotik.com/downloadterms.html
PERCENT=40
echo "# Running installer"
echo "\${PERCENT}"; sleep 1
wine "\${WINEPREFIX}/drive_c/Program Files/Dude/dude-install.exe" "/S"
PERCENT=70
echo "# Extracting Icons"
echo "\${PERCENT}"; sleep 1
(cd /tmp && 7z e "\${WINEPREFIX}/drive_c/Program Files/Dude/dude.exe" .rsrc/ICON/*)
file /tmp/* | awk '
BEGIN {
cmd = ""
file = ""
size = ""
}
/PNG image data/ {
split(\$0, a, /:/)
file = a[1]
split(\$0, a, /, /)
size = gensub(/ /, "", "g", a[2])
switch (size) {
case /256x256/:
paths[size] = sprintf("~/.local/share/icons/hicolor/%s/apps", size)
files[size] = file
break
}
}
END {
if (length(paths) > 0) {
# remove default icon
cmd = sprintf("rm -f ~/.local/share/icons/hicolor/256x256/apps/%s.png", ENVIRON["FLATPAK_ID"])
system(cmd)
for (size in paths) {
cmd = sprintf("install -d %s", paths[size])
system(cmd)
cmd = sprintf("cp %s %s/%s.png", files[size], paths[size], ENVIRON["FLATPAK_ID"])
system(cmd)
}
}
}'
PERCENT=90
echo "# Set Windows Version to win10"
echo "\${PERCENT}"; sleep 1
wine REG ADD 'HKCU\\Software\\Wine' /v 'Version' /d 'win10' /f
echo "# Installer finished" ) | zenity --progress --title="Installing Application" --width=480
%E%O%T%
flatpak-builder --default-branch=stable \
--verbose \
--force-clean \
--install-deps-from=flathub \
--install \
--user \
./build-dir ./org.flatpak.TheDude.yml
# vi: set noexpandtab:wrap: