1515
1616# Debugging
1717if [ -f " .dev-debug" ]; then
18- exec 5> dev-debug.log
18+ exec 5> dev-debug.log
1919 BASH_XTRACEFD=" 5"
2020 set -x
2121fi
@@ -52,26 +52,44 @@ userinput2="${2}"
5252[ -n " ${LGSM_GITHUBBRANCH} " ] && githubbranch=" ${LGSM_GITHUBBRANCH} " || githubbranch=" master"
5353
5454# 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
5656 echo -e " [ FAIL ] Curl is not installed"
5757 exit 1
5858fi
5959
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+
6276 # Check that git branch exists.
6377 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)
6579 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)
6781 fi
6882
6983 if [ " ${branchexistscheck} " != " 200" ]; then
7084 echo -e " ${githubbranch} branch does not exist. Defaulting to master branch."
7185 githubbranch=" master"
7286 fi
7387
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
7593 modulefile=" ${FUNCNAME[0]} "
7694 fn_bootstrap_fetch_file_github " lgsm/modules" " core_modules.sh" " ${modulesdir} " " chmodx" " run" " noforcedl" " nomd5"
7795}
@@ -226,7 +244,7 @@ fn_install_menu_bash() {
226244 while read -r line || [[ -n " ${line} " ]]; do
227245 var=$( echo -e " ${line} " | awk -F " ," ' {print $2 " - " $3}' )
228246 menu_options+=(" ${var} " )
229- done < " ${options} "
247+ done < " ${options} "
230248 menu_options+=(" Cancel" )
231249 select option in " ${menu_options[@]} " ; do
232250 if [ " ${option} " ] && [ " ${option} " != " Cancel" ]; then
@@ -252,7 +270,7 @@ fn_install_menu_whiptail() {
252270 key=$( echo -e " ${line} " | awk -F " ," ' {print $3}' )
253271 val=$( echo -e " ${line} " | awk -F " ," ' {print $2}' )
254272 menu_options+=(" ${val// \" / } " " ${key// \" / } " )
255- done < " ${options} "
273+ done < " ${options} "
256274 OPTION=$( ${menucmd} --title " ${title} " --menu " ${caption} " " ${height} " " ${width} " " ${menuheight} " " ${menu_options[@]} " 3>&1 1>&2 2>&3 )
257275 if [ $? == 0 ]; then
258276 eval " $resultvar =\" ${OPTION} \" "
@@ -276,12 +294,12 @@ fn_install_menu() {
276294 fi
277295 done
278296 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+ ;;
285303 esac
286304 eval " $resultvar =\" ${selection} \" "
287305}
@@ -364,7 +382,7 @@ if [ "${shortname}" == "core" ]; then
364382 } | column -s $' \t ' -t | more
365383 exit
366384 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} "
368386 fn_install_menu result " LinuxGSM" " Select game server to install." " ${serverlistmenu} "
369387 userinput=" ${result} "
370388 fn_server_info
0 commit comments