Skip to content

Commit 685cca9

Browse files
authored
feat: change curl default timeout to 3 seconds (#4592)
adjusted to 3 seconds from 10 for a timeout
1 parent a2bea8d commit 685cca9

14 files changed

+65
-60
lines changed

lgsm/modules/alert_discord.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ jsonnoinfo=$(
118118
"value": "${HOSTNAME}",
119119
"inline": true
120120
},
121+
{
122+
"name": "Is my Game Server Online?",
123+
"value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}",
124+
"inline": true
125+
},
121126
{
122127
"name": "Server Time",
123128
"value": "$(date)",
@@ -142,7 +147,7 @@ else
142147
json="${jsoninfo}"
143148
fi
144149

145-
discordsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}")
150+
discordsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}")
146151

147152
if [ -n "${discordsend}" ]; then
148153
fn_print_fail_nl "Sending Discord alert: ${discordsend}"

lgsm/modules/alert_gotify.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ else
3434
fi
3535

3636
fn_print_dots "Sending Gotify alert"
37-
gotifysend=$(curl --connect-timeout 10 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")
37+
gotifysend=$(curl --connect-timeout 3 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")
3838

3939
if [ -n "${gotifysend}" ]; then
4040
fn_print_ok_nl "Sending Gotify alert"

lgsm/modules/alert_ifttt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ else
3434
fi
3535

3636
fn_print_dots "Sending IFTTT alert"
37-
iftttsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
37+
iftttsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
3838

3939
if [ -n "${iftttsend}" ]; then
4040
fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"

lgsm/modules/alert_pushbullet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ else
3636
fi
3737

3838
fn_print_dots "Sending Pushbullet alert"
39-
pushbulletsend=$(curl --connect-timeout 10 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
39+
pushbulletsend=$(curl --connect-timeout 3 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
4040

4141
if [ -n "${pushbulletsend}" ]; then
4242
fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"

lgsm/modules/alert_pushover.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ else
2323
fi
2424

2525
if [ -z "${alerturl}" ]; then
26-
pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
26+
pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
2727
else
28-
pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
28+
pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
2929
fi
3030

3131
if [ -n "${pushoversend}" ]; then

lgsm/modules/alert_rocketchat.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ else
123123
fi
124124

125125
fn_print_dots "Sending Rocketchat alert"
126-
rocketchatsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}")
126+
rocketchatsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}")
127127

128128
if [ -n "${rocketchatsend}" ]; then
129129
fn_print_ok_nl "Sending Rocketchat alert"

lgsm/modules/alert_slack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fi
182182

183183
fn_print_dots "Sending Slack alert"
184184

185-
slacksend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${slackwebhook}")
185+
slacksend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${slackwebhook}")
186186

187187
if [ "${slacksend}" == "ok" ]; then
188188
fn_print_ok_nl "Sending Slack alert"

lgsm/modules/alert_telegram.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ else
4040
fi
4141

4242
fn_print_dots "Sending Telegram alert"
43-
telegramsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")
43+
telegramsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")
4444

4545
if [ -n "${telegramsend}" ]; then
4646
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"

lgsm/modules/command_update_linuxgsm.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ fn_script_log_info "Updating LinuxGSM"
2020
fn_print_dots "Selecting repo"
2121
fn_script_log_info "Selecting repo"
2222
# Select remotereponame
23-
curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
23+
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
2424
if [ $? != "0" ]; then
25-
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
25+
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
2626
if [ $? != "0" ]; then
2727
fn_print_fail_nl "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
2828
fn_script_log_fail "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
@@ -39,9 +39,9 @@ fi
3939
# Check linuxsm.sh
4040
echo -en "checking ${remotereponame} linuxgsm.sh...\c"
4141
if [ "${remotereponame}" == "GitHub" ]; then
42-
curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
42+
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
4343
else
44-
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
44+
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
4545
fi
4646
if [ $? != "0" ]; then
4747
fn_print_fail_eol_nl
@@ -51,9 +51,9 @@ if [ $? != "0" ]; then
5151
fi
5252

5353
if [ "${remotereponame}" == "GitHub" ]; then
54-
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl --connect-timeout 10 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
54+
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
5555
else
56-
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh"))
56+
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh"))
5757
fi
5858

5959
if [ "${tmp_script_diff}" != "" ]; then
@@ -119,9 +119,9 @@ fi
119119
echo -en "checking ${remotereponame} config _default.cfg...\c"
120120
fn_script_log_info "Checking ${remotereponame} config _default.cfg"
121121
if [ "${remotereponame}" == "GitHub" ]; then
122-
curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
122+
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
123123
else
124-
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
124+
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
125125
fi
126126
if [ $? != "0" ]; then
127127
fn_print_fail_eol_nl
@@ -131,9 +131,9 @@ if [ $? != "0" ]; then
131131
fi
132132

133133
if [ "${remotereponame}" == "GitHub" ]; then
134-
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl --connect-timeout 10 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
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"))
135135
else
136-
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
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"))
137137
fi
138138

139139
if [ "${config_file_diff}" != "" ]; then
@@ -153,9 +153,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
153153
echo -en "checking ${remotereponame} config ${distroid}-${distroversioncsv}.csv...\c"
154154
fn_script_log_info "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv"
155155
if [ "${remotereponame}" == "GitHub" ]; then
156-
curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
156+
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
157157
else
158-
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
158+
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
159159
fi
160160
if [ $? != "0" ]; then
161161
fn_print_fail_eol_nl
@@ -165,9 +165,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
165165
fi
166166

167167
if [ "${remotereponame}" == "GitHub" ]; then
168-
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl --connect-timeout 10 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
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"))
169169
else
170-
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
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"))
171171
fi
172172

173173
if [ "${config_file_diff}" != "" ]; then
@@ -191,9 +191,9 @@ if [ -n "${modulesdir}" ]; then
191191
echo -en "checking ${remotereponame} module ${modulefile}...\c"
192192
github_file_url_dir="lgsm/modules"
193193
if [ "${remotereponame}" == "GitHub" ]; then
194-
curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
194+
curl --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
195195
else
196-
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
196+
curl --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
197197
fi
198198
if [ $? != 0 ]; then
199199
fn_print_error_eol_nl
@@ -210,9 +210,9 @@ if [ -n "${modulesdir}" ]; then
210210
else
211211
# compare file
212212
if [ "${remotereponame}" == "GitHub" ]; then
213-
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl --connect-timeout 10 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}"))
213+
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}"))
214214
else
215-
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}"))
215+
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}"))
216216
fi
217217

218218
# results

lgsm/modules/core_dl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ fn_fetch_file() {
390390
fi
391391
# Trap will remove part downloaded files if canceled.
392392
trap fn_fetch_trap INT
393-
curlcmd=(curl --connect-timeout 10 --fail -L -o "${local_filedir}/${local_filename}" --retry 2)
393+
curlcmd=(curl --connect-timeout 3 --fail -L -o "${local_filedir}/${local_filename}" --retry 2)
394394

395395
# if is large file show progress, else be silent
396396
local exitcode=""

0 commit comments

Comments
 (0)