linuxgsm.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. #!/bin/bash
  2. # Project: Linux Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2020 Daniel Gibbs
  5. # Purpose: Linux Game Server Management Script
  6. # Contributors: https://linuxgsm.com/contrib
  7. # Documentation: https://docs.linuxgsm.com
  8. # Website: https://linuxgsm.com
  9. # DO NOT EDIT THIS FILE
  10. # LinuxGSM configuration is no longer edited here
  11. # To update your LinuxGSM config go to:
  12. # lgsm/config-lgsm
  13. # https://docs.linuxgsm.com/configuration/linuxgsm-config
  14. # Debugging
  15. if [ -f ".dev-debug" ]; then
  16. exec 5>dev-debug.log
  17. BASH_XTRACEFD="5"
  18. set -x
  19. fi
  20. version="v21.3.0"
  21. shortname="core"
  22. gameservername="core"
  23. commandname="CORE"
  24. rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
  25. selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
  26. sessionname=$(echo "${selfname}" | cut -f1 -d".")
  27. lgsmdir="${rootdir}/lgsm"
  28. logdir="${rootdir}/log"
  29. lgsmlogdir="${logdir}/lgsm"
  30. steamcmddir="${HOME}/.steam/steamcmd"
  31. serverfiles="${rootdir}/serverfiles"
  32. functionsdir="${lgsmdir}/functions"
  33. tmpdir="${lgsmdir}/tmp"
  34. datadir="${lgsmdir}/data"
  35. lockdir="${lgsmdir}/lock"
  36. serverlist="${datadir}/serverlist.csv"
  37. serverlistmenu="${datadir}/serverlistmenu.csv"
  38. configdir="${lgsmdir}/config-lgsm"
  39. configdirserver="${configdir}/${gameservername}"
  40. configdirdefault="${lgsmdir}/config-default"
  41. userinput="${1}"
  42. userinput2="${2}"
  43. ## GitHub Branch Select
  44. # Allows for the use of different function files
  45. # from a different repo and/or branch.
  46. githubuser="GameServerManagers"
  47. githubrepo="LinuxGSM"
  48. githubbranch="master"
  49. # Core function that is required first.
  50. core_functions.sh(){
  51. functionfile="${FUNCNAME[0]}"
  52. fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
  53. }
  54. # Bootstrap
  55. # Fetches the core functions required before passed off to core_dl.sh.
  56. fn_bootstrap_fetch_file(){
  57. remote_fileurl="${1}"
  58. remote_fileurl_backup="${2}"
  59. remote_fileurl_name="${3}"
  60. remote_fileurl_backup_name="${4}"
  61. local_filedir="${5}"
  62. local_filename="${6}"
  63. chmodx="${7:-0}"
  64. run="${8:-0}"
  65. forcedl="${9:-0}"
  66. md5="${10:-0}"
  67. # Download file if missing or download forced.
  68. if [ ! -f "${local_filedir}/${local_filename}" ]||[ "${forcedl}" == "forcedl" ]; then
  69. # If backup fileurl exists include it.
  70. if [ -n "${remote_fileurl_backup}" ]; then
  71. # counter set to 0 to allow second try
  72. counter=0
  73. remote_fileurls_array=( remote_fileurl remote_fileurl_backup )
  74. else
  75. # counter set to 1 to not allow second try
  76. counter=1
  77. remote_fileurls_array=( remote_fileurl )
  78. fi
  79. for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
  80. if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
  81. fileurl="${remote_fileurl}"
  82. fileurl_name="${remote_fileurl_name}"
  83. elif [ "${remote_fileurl_array}" == "remote_fileurl_backup" ]; then
  84. fileurl="${remote_fileurl_backup}"
  85. fileurl_name="${remote_fileurl_backup_name}"
  86. fi
  87. counter=$((counter+1))
  88. if [ ! -d "${local_filedir}" ]; then
  89. mkdir -p "${local_filedir}"
  90. fi
  91. # Trap will remove part downloaded files if canceled.
  92. trap fn_fetch_trap INT
  93. # Larger files show a progress bar.
  94. echo -en "fetching ${fileurl_name} ${local_filename}...\c"
  95. curlcmd=$(curl --connect-timeout 10 -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}" 2>&1)
  96. local exitcode=$?
  97. # Download will fail if downloads a html file.
  98. if [ -f "${local_filedir}/${local_filename}" ]; then
  99. if [ -n "$(head "${local_filedir}/${local_filename}" | grep "DOCTYPE" )" ]; then
  100. rm "${local_filedir:?}/${local_filename:?}"
  101. local exitcode=2
  102. fi
  103. fi
  104. # On first try will error. On second try will fail.
  105. if [ "${exitcode}" != 0 ]; then
  106. if [ ${counter} -ge 2 ]; then
  107. echo -e "FAIL"
  108. if [ -f "${lgsmlog}" ]; then
  109. fn_script_log_fatal "Downloading ${local_filename}"
  110. fn_script_log_fatal "${fileurl}"
  111. fi
  112. core_exit.sh
  113. else
  114. echo -e "ERROR"
  115. if [ -f "${lgsmlog}" ]; then
  116. fn_script_log_error "Downloading ${local_filename}"
  117. fn_script_log_error "${fileurl}"
  118. fi
  119. fi
  120. else
  121. echo -en "OK"
  122. sleep 0.3
  123. echo -en "\033[2K\\r"
  124. if [ -f "${lgsmlog}" ]; then
  125. fn_script_log_pass "Downloading ${local_filename}"
  126. fi
  127. # Make file executable if chmodx is set.
  128. if [ "${chmodx}" == "chmodx" ]; then
  129. chmod +x "${local_filedir}/${local_filename}"
  130. fi
  131. # Remove trap.
  132. trap - INT
  133. break
  134. fi
  135. done
  136. fi
  137. if [ -f "${local_filedir}/${local_filename}" ]; then
  138. # Execute file if run is set.
  139. if [ "${run}" == "run" ]; then
  140. # shellcheck source=/dev/null
  141. source "${local_filedir}/${local_filename}"
  142. fi
  143. fi
  144. }
  145. fn_bootstrap_fetch_file_github(){
  146. github_file_url_dir="${1}"
  147. github_file_url_name="${2}"
  148. # If master branch will currently running LinuxGSM version to prevent "version mixing". This is ignored if a fork.
  149. if [ "${githubbranch}" == "master" ]&&[ "${githubuser}" == "GameServerManager" ]&&[ "${commandname}" != "UPDATE-LGSM" ]; then
  150. remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${version}/${github_file_url_dir}/${github_file_url_name}"
  151. remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${version}/${github_file_url_dir}/${github_file_url_name}"
  152. else
  153. remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  154. remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  155. fi
  156. remote_fileurl_name="GitHub"
  157. remote_fileurl_backup_name="Bitbucket"
  158. local_filedir="${3}"
  159. local_filename="${github_file_url_name}"
  160. chmodx="${4:-0}"
  161. run="${5:-0}"
  162. forcedl="${6:-0}"
  163. md5="${7:-0}"
  164. # Passes vars to the file download function.
  165. fn_bootstrap_fetch_file "${remote_fileurl}" "${remote_fileurl_backup}" "${remote_fileurl_name}" "${remote_fileurl_backup_name}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
  166. }
  167. # Installer menu.
  168. fn_print_center() {
  169. columns=$(tput cols)
  170. line="$*"
  171. printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
  172. }
  173. fn_print_horizontal(){
  174. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
  175. }
  176. # Bash menu.
  177. fn_install_menu_bash() {
  178. local resultvar=$1
  179. title=$2
  180. caption=$3
  181. options=$4
  182. fn_print_horizontal
  183. fn_print_center "${title}"
  184. fn_print_center "${caption}"
  185. fn_print_horizontal
  186. menu_options=()
  187. while read -r line || [[ -n "${line}" ]]; do
  188. var=$(echo -e "${line}" | awk -F "," '{print $2 " - " $3}')
  189. menu_options+=( "${var}" )
  190. done < "${options}"
  191. menu_options+=( "Cancel" )
  192. select option in "${menu_options[@]}"; do
  193. if [ "${option}" ]&&[ "${option}" != "Cancel" ]; then
  194. eval "$resultvar=\"${option/%\ */}\""
  195. fi
  196. break
  197. done
  198. }
  199. # Whiptail/Dialog menu.
  200. fn_install_menu_whiptail() {
  201. local menucmd=$1
  202. local resultvar=$2
  203. title=$3
  204. caption=$4
  205. options=$5
  206. height=${6:-40}
  207. width=${7:-80}
  208. menuheight=${8:-30}
  209. IFS=","
  210. menu_options=()
  211. while read -r line; do
  212. key=$(echo -e "${line}" | awk -F "," '{print $3}')
  213. val=$(echo -e "${line}" | awk -F "," '{print $2}')
  214. menu_options+=( "${val//\"}" "${key//\"}" )
  215. done < "${options}"
  216. OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
  217. if [ $? == 0 ]; then
  218. eval "$resultvar=\"${OPTION}\""
  219. else
  220. eval "$resultvar="
  221. fi
  222. }
  223. # Menu selector.
  224. fn_install_menu() {
  225. local resultvar=$1
  226. local selection=""
  227. title=$2
  228. caption=$3
  229. options=$4
  230. # Get menu command.
  231. for menucmd in whiptail dialog bash; do
  232. if [ "$(command -v "${menucmd}")" ]; then
  233. menucmd=$(command -v "${menucmd}")
  234. break
  235. fi
  236. done
  237. case "$(basename "${menucmd}")" in
  238. whiptail|dialog)
  239. fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30;;
  240. *)
  241. fn_install_menu_bash selection "${title}" "${caption}" "${options}";;
  242. esac
  243. eval "$resultvar=\"${selection}\""
  244. }
  245. # Gets server info from serverlist.csv and puts in to array.
  246. fn_server_info(){
  247. IFS=","
  248. server_info_array=($(grep -aw "${userinput}" "${serverlist}"))
  249. shortname="${server_info_array[0]}" # csgo
  250. gameservername="${server_info_array[1]}" # csgoserver
  251. gamename="${server_info_array[2]}" # Counter Strike: Global Offensive
  252. }
  253. fn_install_getopt(){
  254. userinput="empty"
  255. echo -e "Usage: $0 [option]"
  256. echo -e ""
  257. echo -e "Installer - Linux Game Server Managers - Version ${version}"
  258. echo -e "https://linuxgsm.com"
  259. echo -e ""
  260. echo -e "Commands"
  261. echo -e "install\t\t| Select server to install."
  262. echo -e "servername\t| Enter name of game server to install. e.g $0 csgoserver."
  263. echo -e "list\t\t| List all servers available for install."
  264. exit
  265. }
  266. fn_install_file(){
  267. local_filename="${gameservername}"
  268. if [ -e "${local_filename}" ]; then
  269. i=2
  270. while [ -e "${local_filename}-${i}" ] ; do
  271. (( i++ ))
  272. done
  273. local_filename="${local_filename}-${i}"
  274. fi
  275. cp -R "${selfname}" "${local_filename}"
  276. sed -i -e "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${local_filename}"
  277. sed -i -e "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${local_filename}"
  278. echo -e "Installed ${gamename} server as ${local_filename}"
  279. echo -e ""
  280. if [ ! -d "${serverfiles}" ]; then
  281. echo -e "./${local_filename} install"
  282. else
  283. echo -e "Remember to check server ports"
  284. echo -e "./${local_filename} details"
  285. fi
  286. echo -e ""
  287. exit
  288. }
  289. # Prevent LinuxGSM from running as root. Except if doing a dependency install.
  290. if [ "$(whoami)" == "root" ]; then
  291. if [ "${userinput}" == "install" ]||[ "${userinput}" == "auto-install" ]||[ "${userinput}" == "i" ]||[ "${userinput}" == "ai" ]; then
  292. if [ "${shortname}" == "core" ]; then
  293. echo -e "[ FAIL ] Do NOT run this script as root!"
  294. exit 1
  295. fi
  296. elif [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]; then
  297. echo -e "[ FAIL ] Do NOT run this script as root!"
  298. exit 1
  299. else
  300. core_functions.sh
  301. check_root.sh
  302. fi
  303. fi
  304. # LinuxGSM installer mode.
  305. if [ "${shortname}" == "core" ]; then
  306. # Download the latest serverlist. This is the complete list of all supported servers.
  307. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "nochmodx" "norun" "forcedl" "nomd5"
  308. if [ ! -f "${serverlist}" ]; then
  309. echo -e "[ FAIL ] serverlist.csv could not be loaded."
  310. exit 1
  311. fi
  312. if [ "${userinput}" == "list" ]||[ "${userinput}" == "l" ]; then
  313. {
  314. tail -n +1 "${serverlist}" | awk -F "," '{print $2 "\t" $3}'
  315. } | column -s $'\t' -t | more
  316. exit
  317. elif [ "${userinput}" == "install" ]||[ "${userinput}" == "i" ]; then
  318. tail -n +1 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
  319. fn_install_menu result "LinuxGSM" "Select game server to install." "${serverlistmenu}"
  320. userinput="${result}"
  321. fn_server_info
  322. if [ "${result}" == "${gameservername}" ]; then
  323. fn_install_file
  324. elif [ "${result}" == "" ]; then
  325. echo -e "Install canceled"
  326. else
  327. echo -e "[ FAIL ] menu result does not match gameservername"
  328. echo -e "result: ${result}"
  329. echo -e "gameservername: ${gameservername}"
  330. fi
  331. elif [ "${userinput}" ]; then
  332. fn_server_info
  333. if [ "${userinput}" == "${gameservername}" ]||[ "${userinput}" == "${gamename}" ]||[ "${userinput}" == "${shortname}" ]; then
  334. fn_install_file
  335. else
  336. echo -e "[ FAIL ] unknown game server"
  337. fi
  338. else
  339. fn_install_getopt
  340. fi
  341. # LinuxGSM server mode.
  342. else
  343. core_functions.sh
  344. if [ "${shortname}" != "core-dep" ]; then
  345. # Load LinuxGSM configs.
  346. # These are required to get all the default variables for the specific server.
  347. # Load the default config. If missing download it. If changed reload it.
  348. if [ ! -f "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" ]; then
  349. mkdir -p "${configdirdefault}/config-lgsm/${gameservername}"
  350. fn_fetch_config "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "_default.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  351. fi
  352. if [ ! -f "${configdirserver}/_default.cfg" ]; then
  353. mkdir -p "${configdirserver}"
  354. echo -en "copying _default.cfg...\c"
  355. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  356. if [ $? != 0 ]; then
  357. echo -e "FAIL"
  358. exit 1
  359. else
  360. echo -e "OK"
  361. fi
  362. else
  363. function_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg")
  364. if [ "${function_file_diff}" != "" ]; then
  365. fn_print_warn_nl "_default.cfg has altered. reloading config."
  366. echo -en "copying _default.cfg...\c"
  367. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  368. if [ $? != 0 ]; then
  369. echo -e "FAIL"
  370. exit 1
  371. else
  372. echo -e "OK"
  373. fi
  374. fi
  375. fi
  376. fi
  377. # Load the IP details before the first config is loaded.
  378. check_ip.sh
  379. # Configs have to be loaded twice to allow start startparameters to pick up all vars
  380. # shellcheck source=/dev/null
  381. source "${configdirserver}/_default.cfg"
  382. # Load the common.cfg config. If missing download it.
  383. if [ ! -f "${configdirserver}/common.cfg" ]; then
  384. fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
  385. # shellcheck source=/dev/null
  386. source "${configdirserver}/common.cfg"
  387. else
  388. # shellcheck source=/dev/null
  389. source "${configdirserver}/common.cfg"
  390. fi
  391. # Load the secrets-common.cfg config. If missing download it.
  392. if [ ! -f "${configdirserver}/secrets-common.cfg" ]; then
  393. fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-common-template.cfg" "${configdirserver}" "secrets-common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
  394. # shellcheck source=/dev/null
  395. source "${configdirserver}/secrets-common.cfg"
  396. else
  397. # shellcheck source=/dev/null
  398. source "${configdirserver}/secrets-common.cfg"
  399. fi
  400. # Load the instance.cfg config. If missing download it.
  401. if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
  402. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  403. # shellcheck source=/dev/null
  404. source "${configdirserver}/${selfname}.cfg"
  405. else
  406. # shellcheck source=/dev/null
  407. source "${configdirserver}/${selfname}.cfg"
  408. fi
  409. # Load the secrets-instance.cfg config. If missing download it.
  410. if [ ! -f "${configdirserver}/secrets-${selfname}.cfg" ]; then
  411. fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-instance-template.cfg" "${configdirserver}" "secrets-${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  412. # shellcheck source=/dev/null
  413. source "${configdirserver}/secrets-${selfname}.cfg"
  414. else
  415. # shellcheck source=/dev/null
  416. source "${configdirserver}/secrets-${selfname}.cfg"
  417. fi
  418. # Reloads start parameter to ensure all vars in startparameters are set.
  419. # Will reload the last defined startparameter.
  420. fn_reload_startparameters(){
  421. # reload Wurm config.
  422. if [ "${shortname}" == "wurm" ]; then
  423. # shellcheck source=/dev/null
  424. source "${servercfgfullpath}"
  425. fi
  426. # reload startparameters.
  427. if grep -qE "^[[:blank:]]*startparameters=" "${configdirserver}/secrets-${selfname}.cfg"; then
  428. eval startparameters="$(sed -nr 's/^ *startparameters=(.*)$/\1/p' "${configdirserver}/secrets-${selfname}.cfg")"
  429. elif grep -qE "^[[:blank:]]*startparameters=" "${configdirserver}/${selfname}.cfg"; then
  430. eval startparameters="$(sed -nr 's/^ *startparameters=(.*)$/\1/p' "${configdirserver}/${selfname}.cfg")"
  431. elif grep -qE "^[[:blank:]]*startparameters=" "${configdirserver}/secrets-common.cfg"; then
  432. eval startparameters="$(sed -nr 's/^ *startparameters=(.*)$/\1/p' "${configdirserver}/secrets-common.cfg")"
  433. elif grep -qE "^[[:blank:]]*startparameters=" "${configdirserver}/common.cfg"; then
  434. eval startparameters="$(sed -nr 's/^ *startparameters=(.*)$/\1/p' "${configdirserver}/common.cfg")"
  435. elif grep -qE "^[[:blank:]]*startparameters=" "${configdirserver}/_default.cfg"; then
  436. eval startparameters="$(sed -nr 's/^ *startparameters=(.*)$/\1/p' "${configdirserver}/_default.cfg")"
  437. fi
  438. # reload preexecutable.
  439. if grep -qE "^[[:blank:]]*preexecutable=" "${configdirserver}/secrets-${selfname}.cfg"; then
  440. eval preexecutable="$(sed -nr 's/^ *preexecutable=(.*)$/\1/p' "${configdirserver}/secrets-${selfname}.cfg")"
  441. elif grep -qE "^[[:blank:]]*preexecutable=" "${configdirserver}/${selfname}.cfg"; then
  442. eval preexecutable="$(sed -nr 's/^ *preexecutable=(.*)$/\1/p' "${configdirserver}/${selfname}.cfg")"
  443. elif grep -qE "^[[:blank:]]*preexecutable=" "${configdirserver}/secrets-common.cfg"; then
  444. eval preexecutable="$(sed -nr 's/^ *preexecutable=(.*)$/\1/p' "${configdirserver}/secrets-common.cfg")"
  445. elif grep -qE "^[[:blank:]]*preexecutable=" "${configdirserver}/common.cfg"; then
  446. eval preexecutable="$(sed -nr 's/^ *preexecutable=(.*)$/\1/p' "${configdirserver}/common.cfg")"
  447. elif grep -qE "^[[:blank:]]*preexecutable=" "${configdirserver}/_default.cfg"; then
  448. eval preexecutable="$(sed -nr 's/^ *preexecutable=(.*)$/\1/p' "${configdirserver}/_default.cfg")"
  449. fi
  450. # For legacy configs that still use parms= 15.03.21
  451. if grep -qE "^[[:blank:]]*parms=" "${configdirserver}/secrets-${selfname}.cfg"; then
  452. eval parms="$(sed -nr 's/^ *parms=(.*)$/\1/p' "${configdirserver}/secrets-${selfname}.cfg")"
  453. elif grep -qE "^[[:blank:]]*parms=" "${configdirserver}/${selfname}.cfg"; then
  454. eval parms="$(sed -nr 's/^ *parms=(.*)$/\1/p' "${configdirserver}/${selfname}.cfg")"
  455. elif grep -qE "^[[:blank:]]*parms=" "${configdirserver}/secrets-common.cfg"; then
  456. eval parms="$(sed -nr 's/^ *parms=(.*)$/\1/p' "${configdirserver}/secrets-common.cfg")"
  457. elif grep -qE "^[[:blank:]]*parms=" "${configdirserver}/common.cfg"; then
  458. eval parms="$(sed -nr 's/^ *parms=(.*)$/\1/p' "${configdirserver}/common.cfg")"
  459. elif grep -qE "^[[:blank:]]*parms=" "${configdirserver}/_default.cfg"; then
  460. eval parms="$(sed -nr 's/^ *parms=(.*)$/\1/p' "${configdirserver}/_default.cfg")"
  461. fi
  462. if [ -n "${parms}" ]; then
  463. startparameters="${parms}"
  464. fi
  465. }
  466. # Load the linuxgsm.sh in to tmpdir. If missing download it.
  467. if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then
  468. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5"
  469. fi
  470. # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off.
  471. fn_ansi_loader
  472. # Prevents running of core_exit.sh for Travis-CI.
  473. if [ "${travistest}" != "1" ]; then
  474. getopt=$1
  475. core_getopt.sh
  476. fi
  477. fi