linuxgsm.sh 18 KB

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