|
|
@@ -14,27 +14,89 @@ githubuser="dgibbs64"
|
|
|
githubrepo="linuxgsm"
|
|
|
githubbranch="$TRAVIS_BRANCH"
|
|
|
|
|
|
+##### Script #####
|
|
|
+
|
|
|
+# Fetches core_dl for file downloads
|
|
|
+fn_fetch_core_dl(){
|
|
|
+github_file_url_dir="lgsm/functions"
|
|
|
+github_file_url_name="${functionfile}"
|
|
|
+filedir="${functionsdir}"
|
|
|
+filename="${github_file_url_name}"
|
|
|
+githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
|
|
|
+# If the file is missing, then download
|
|
|
+if [ ! -f "${filedir}/${filename}" ]; then
|
|
|
+ if [ ! -d "${filedir}" ]; then
|
|
|
+ mkdir -p "${filedir}"
|
|
|
+ fi
|
|
|
+ echo -e " fetching ${filename}...\c"
|
|
|
+ # Check curl exists and use available path
|
|
|
+ curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
|
|
|
+ for curlcmd in ${curlpaths}
|
|
|
+ do
|
|
|
+ if [ -x "${curlcmd}" ]; then
|
|
|
+ break
|
|
|
+ fi
|
|
|
+ done
|
|
|
+ # If curl exists download file
|
|
|
+ if [ "$(basename ${curlcmd})" == "curl" ]; then
|
|
|
+ curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
|
|
|
+ if [ $? -ne 0 ]; then
|
|
|
+ echo -e "\e[0;31mFAIL\e[0m\n"
|
|
|
+ echo "${curlfetch}"
|
|
|
+ echo -e "${githuburl}\n"
|
|
|
+ exit 1
|
|
|
+ else
|
|
|
+ echo -e "\e[0;32mOK\e[0m"
|
|
|
+ fi
|
|
|
+ else
|
|
|
+ echo -e "\e[0;31mFAIL\e[0m\n"
|
|
|
+ echo "Curl is not installed!"
|
|
|
+ echo -e ""
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ chmod +x "${filedir}/${filename}"
|
|
|
+fi
|
|
|
+source "${filedir}/${filename}"
|
|
|
+}
|
|
|
+
|
|
|
+core_dl.sh(){
|
|
|
+# Functions are defined in core_functions.sh.
|
|
|
+functionfile="${FUNCNAME}"
|
|
|
+fn_fetch_core_dl
|
|
|
+}
|
|
|
+
|
|
|
+core_functions.sh(){
|
|
|
+# Functions are defined in core_functions.sh.
|
|
|
+functionfile="${FUNCNAME}"
|
|
|
+fn_fetch_core_dl
|
|
|
+}
|
|
|
+
|
|
|
+core_dl.sh
|
|
|
+core_functions.sh
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
# End of every test will expect the result to either pass or fail
|
|
|
# If the script does not do as intended the whole test will fail
|
|
|
# if excpecting a pass
|
|
|
fn_test_result_pass(){
|
|
|
if [ $? != 0 ]; then
|
|
|
- fn_print_fail "Test Failure"
|
|
|
+ fn_print_fail "Test Failed"
|
|
|
exitcode=1
|
|
|
core_exit.sh
|
|
|
else
|
|
|
- fn_print_ok "Test Pass"
|
|
|
+ fn_print_ok "Test Passed"
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# if excpecting a fail
|
|
|
fn_test_result_fail(){
|
|
|
if [ $? == 0 ]; then
|
|
|
- fn_print_fail "Test Failure"
|
|
|
+ fn_print_fail "Test Failed"
|
|
|
exitcode=1
|
|
|
core_exit.sh
|
|
|
else
|
|
|
- fn_print_ok "Test Pass"
|
|
|
+ fn_print_ok "Test Passed"
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
@@ -89,4 +151,11 @@ echo "Description:"
|
|
|
echo "displaying options messages."
|
|
|
echo ""
|
|
|
./jc2server
|
|
|
-fn_test_result_fail
|
|
|
+fn_test_result_fail
|
|
|
+
|
|
|
+echo "2.0 - install"
|
|
|
+echo "================================="
|
|
|
+echo "Description:"
|
|
|
+echo "install Just Cause 2 server."
|
|
|
+./jc2server auto-install
|
|
|
+fn_test_result_pass
|