15
15
16
16
# Debugging
17
17
if [ -f " .dev-debug" ]; then
18
- exec 5> dev-debug.log
18
+ exec 5> dev-debug.log
19
19
BASH_XTRACEFD=" 5"
20
20
set -x
21
21
fi
@@ -52,26 +52,44 @@ userinput2="${2}"
52
52
[ -n " ${LGSM_GITHUBBRANCH} " ] && githubbranch=" ${LGSM_GITHUBBRANCH} " || githubbranch=" master"
53
53
54
54
# Check that curl is installed before doing anything
55
- if [ ! " $( command -v curl 2> /dev/null) " ]; then
55
+ if [ ! " $( command -v curl 2> /dev/null) " ]; then
56
56
echo -e " [ FAIL ] Curl is not installed"
57
57
exit 1
58
58
fi
59
59
60
- # Core module that is required first.
61
- core_modules.sh () {
60
+ fn_repo_selector () {
61
+ # Check if GitHub is accessible if not fail over to Bitbucket.
62
+ repocheck=$( curl -s -o /dev/null -w " %{http_code}" " https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/linuxgsm.sh" 2> /dev/null)
63
+ if [ " ${repocheck} " != " 200" ]; then
64
+ echo -e " Selecting repo: GitHub is not accessable. Selecting Bitbucket"
65
+ repocheck=$( curl -s -o /dev/null -w " %{http_code}" " https://bitbucket.org/GameServerManagers/LinuxGSM/master/linuxgsm.sh" 2> /dev/null)
66
+ if [ " ${repocheck} " != " 200" ]; then
67
+ echo -e " Selecting repo: Unable to to access GitHub or Bitbucket repositories"
68
+ exit 1
69
+ else
70
+ remotereponame=" Bitbucket"
71
+ fi
72
+ else
73
+ remotereponame=" GitHub"
74
+ fi
75
+
62
76
# Check that git branch exists.
63
77
if [ " ${remotereponame} " == " GitHub" ]; then
64
- branchexistscheck=$( curl -s -o /dev/null -w " %{http_code}" " https://raw.githubusercontent.com/${githubuser} /${githubrepo} /${githubbranch} /linuxgsm.sh" 1> /dev/null)
78
+ branchexistscheck=$( curl -s -o /dev/null -w " %{http_code}" " https://raw.githubusercontent.com/${githubuser} /${githubrepo} /${githubbranch} /linuxgsm.sh" 2> /dev/null)
65
79
else
66
- branchexistscheck=$( curl -s -o /dev/null -w " %{http_code}" " https://bitbucket.org/${githubuser} /${githubrepo} /raw/${githubbranch} /linuxgsm.sh" 1> /dev/null)
80
+ branchexistscheck=$( curl -s -o /dev/null -w " %{http_code}" " https://bitbucket.org/${githubuser} /${githubrepo} /raw/${githubbranch} /linuxgsm.sh" 2> /dev/null)
67
81
fi
68
82
69
83
if [ " ${branchexistscheck} " != " 200" ]; then
70
84
echo -e " ${githubbranch} branch does not exist. Defaulting to master branch."
71
85
githubbranch=" master"
72
86
fi
73
87
74
- # Fetches the core modules required before passed off to core_dl.sh.
88
+ }
89
+
90
+ # Fetches the core module required before passed off to core_dl.sh.
91
+ core_modules.sh () {
92
+ fn_repo_selector
75
93
modulefile=" ${FUNCNAME[0]} "
76
94
fn_bootstrap_fetch_file_github " lgsm/modules" " core_modules.sh" " ${modulesdir} " " chmodx" " run" " noforcedl" " nomd5"
77
95
}
@@ -226,7 +244,7 @@ fn_install_menu_bash() {
226
244
while read -r line || [[ -n " ${line} " ]]; do
227
245
var=$( echo -e " ${line} " | awk -F " ," ' {print $2 " - " $3}' )
228
246
menu_options+=(" ${var} " )
229
- done < " ${options} "
247
+ done < " ${options} "
230
248
menu_options+=(" Cancel" )
231
249
select option in " ${menu_options[@]} " ; do
232
250
if [ " ${option} " ] && [ " ${option} " != " Cancel" ]; then
@@ -252,7 +270,7 @@ fn_install_menu_whiptail() {
252
270
key=$( echo -e " ${line} " | awk -F " ," ' {print $3}' )
253
271
val=$( echo -e " ${line} " | awk -F " ," ' {print $2}' )
254
272
menu_options+=(" ${val// \" / } " " ${key// \" / } " )
255
- done < " ${options} "
273
+ done < " ${options} "
256
274
OPTION=$( ${menucmd} --title " ${title} " --menu " ${caption} " " ${height} " " ${width} " " ${menuheight} " " ${menu_options[@]} " 3>&1 1>&2 2>&3 )
257
275
if [ $? == 0 ]; then
258
276
eval " $resultvar =\" ${OPTION} \" "
@@ -276,12 +294,12 @@ fn_install_menu() {
276
294
fi
277
295
done
278
296
case " $( basename " ${menucmd} " ) " in
279
- whiptail | dialog)
280
- fn_install_menu_whiptail " ${menucmd} " selection " ${title} " " ${caption} " " ${options} " 40 80 30
281
- ;;
282
- * )
283
- fn_install_menu_bash selection " ${title} " " ${caption} " " ${options} "
284
- ;;
297
+ whiptail | dialog)
298
+ fn_install_menu_whiptail " ${menucmd} " selection " ${title} " " ${caption} " " ${options} " 40 80 30
299
+ ;;
300
+ * )
301
+ fn_install_menu_bash selection " ${title} " " ${caption} " " ${options} "
302
+ ;;
285
303
esac
286
304
eval " $resultvar =\" ${selection} \" "
287
305
}
@@ -364,7 +382,7 @@ if [ "${shortname}" == "core" ]; then
364
382
} | column -s $' \t ' -t | more
365
383
exit
366
384
elif [ " ${userinput} " == " install" ] || [ " ${userinput} " == " i" ]; then
367
- tail -n +1 " ${serverlist} " | awk -F " ," ' {print $1 "," $2 "," $3}' > " ${serverlistmenu} "
385
+ tail -n +1 " ${serverlist} " | awk -F " ," ' {print $1 "," $2 "," $3}' > " ${serverlistmenu} "
368
386
fn_install_menu result " LinuxGSM" " Select game server to install." " ${serverlistmenu} "
369
387
userinput=" ${result} "
370
388
fn_server_info
0 commit comments