Skip to content

Commit e060865

Browse files
authored
feat(dev): add nocache if dev-debug is enabled (#4597)
1 parent 182c673 commit e060865

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

lgsm/modules/command_update_linuxgsm.sh

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ check.sh
1515
info_distro.sh
1616
info_game.sh
1717

18+
# Prevent github from using a cached version of the file if dev-debug is enabled.
19+
if [ -f "${rootdir}/.dev-debug" ]; then
20+
nocache="-H \"Cache-Control: no-cache\" -H \"Pragma: no-cache\""
21+
fi
22+
1823
fn_script_log_info "Updating LinuxGSM"
1924

2025
fn_print_dots "Selecting repo"
2126
fn_script_log_info "Selecting repo"
2227
# Select remotereponame
23-
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
28+
29+
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
30+
2431
if [ $? != "0" ]; then
25-
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
32+
curl curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
2633
if [ $? != "0" ]; then
2734
fn_print_fail_nl "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
2835
fn_script_log_fail "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
@@ -39,9 +46,9 @@ fi
3946
# Check linuxsm.sh
4047
echo -en "checking ${remotereponame} linuxgsm.sh...\c"
4148
if [ "${remotereponame}" == "GitHub" ]; then
42-
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
49+
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
4350
else
44-
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
51+
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
4552
fi
4653
if [ $? != "0" ]; then
4754
fn_print_fail_eol_nl
@@ -51,9 +58,9 @@ if [ $? != "0" ]; then
5158
fi
5259

5360
if [ "${remotereponame}" == "GitHub" ]; then
54-
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
61+
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
5562
else
56-
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh"))
63+
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh"))
5764
fi
5865

5966
if [ "${tmp_script_diff}" != "" ]; then
@@ -119,9 +126,9 @@ fi
119126
echo -en "checking ${remotereponame} config _default.cfg...\c"
120127
fn_script_log_info "Checking ${remotereponame} config _default.cfg"
121128
if [ "${remotereponame}" == "GitHub" ]; then
122-
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
129+
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
123130
else
124-
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
131+
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
125132
fi
126133
if [ $? != "0" ]; then
127134
fn_print_fail_eol_nl
@@ -131,9 +138,9 @@ if [ $? != "0" ]; then
131138
fi
132139

133140
if [ "${remotereponame}" == "GitHub" ]; then
134-
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
141+
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
135142
else
136-
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
143+
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
137144
fi
138145

139146
if [ "${config_file_diff}" != "" ]; then
@@ -153,9 +160,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
153160
echo -en "checking ${remotereponame} config ${distroid}-${distroversioncsv}.csv...\c"
154161
fn_script_log_info "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv"
155162
if [ "${remotereponame}" == "GitHub" ]; then
156-
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
163+
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
157164
else
158-
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
165+
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
159166
fi
160167
if [ $? != "0" ]; then
161168
fn_print_fail_eol_nl
@@ -165,9 +172,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
165172
fi
166173

167174
if [ "${remotereponame}" == "GitHub" ]; then
168-
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
175+
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
169176
else
170-
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
177+
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
171178
fi
172179

173180
if [ "${config_file_diff}" != "" ]; then
@@ -191,9 +198,9 @@ if [ -n "${modulesdir}" ]; then
191198
echo -en "checking ${remotereponame} module ${modulefile}...\c"
192199
github_file_url_dir="lgsm/modules"
193200
if [ "${remotereponame}" == "GitHub" ]; then
194-
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
201+
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
195202
else
196-
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
203+
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
197204
fi
198205
if [ $? != 0 ]; then
199206
fn_print_error_eol_nl
@@ -210,9 +217,9 @@ if [ -n "${modulesdir}" ]; then
210217
else
211218
# compare file
212219
if [ "${remotereponame}" == "GitHub" ]; then
213-
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}"))
220+
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}"))
214221
else
215-
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}"))
222+
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}"))
216223
fi
217224

218225
# results

0 commit comments

Comments
 (0)