From a577b0674a025391023fc257efacbaab33fc2df2 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 26 Dec 2017 20:07:45 +0000 Subject: Overwrite autogen instead of exec'ing configs. --- run-instance.sh | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/run-instance.sh b/run-instance.sh index cdb8342..2cdfad9 100755 --- a/run-instance.sh +++ b/run-instance.sh @@ -14,9 +14,8 @@ COMMON="$PREFIX/common" HOME_PREFIX="$PREFIX/home@" FS_GAME="slacker" -# Config directory: as seen by tremded's vfs and the absolute path, respectively. -CONFIG_LOCAL="config" -CONFIG_GLOBAL="$PREFIX/$CONFIG_LOCAL" +# Config directory. +CONFIG_PREFIX="$PREFIX/config/" # Executables. GDB_WRAPPER="$PREFIX/bin/gdb-wrapper2.sh" @@ -56,22 +55,6 @@ function check_dir { [ -d "$1" ] || error "%s '%s' is not a directory\n" "$2" "$1" } -function ensure_link { - if [ -L "$2" ]; then - debug "ensure_link: '%s' already exists\n" "$2" - if [ `readlink "$2"` == "$1" ]; then - return - fi - - debug "ensure_link: ...and points at '%s' instead of '%s'\n" `readlink "$2"` "$1" - unlink "$2" || error "couldn't unlink '%s'\n" "$2" - fi - - mkdir -p `dirname "$2"` || error - ln -s "$1" "$2" || error "linking failed\n" - debug "ensure_link: linked '%s' -> '%s'\n" "$2" "$1" -} - ################### # The entry point # ################### @@ -83,29 +66,28 @@ function ensure_link { I="$1" TREMDED="$TREMDED_PREFIX$I" HOME="$HOME_PREFIX$I" -CONFIG_LOCAL_COMMON="$CONFIG_LOCAL/common.cfg" -CONFIG_LOCAL_INST="$CONFIG_LOCAL/$I.cfg" -CONFIG_GLOBAL_COMMON="$CONFIG_GLOBAL/common.cfg" -CONFIG_GLOBAL_INST="$CONFIG_GLOBAL/$I.cfg" - -# Do some integrity tests and fix missing links. -check_file "$TREMDED" "the tremded" -check_dir "$HOME" "the home directory" -check_file "$CONFIG_GLOBAL_COMMON" "the common config" -check_file "$CONFIG_GLOBAL_INST" "the instance-specific config" -ensure_link "${CONFIG_GLOBAL}" "$HOME/$FS_GAME/$CONFIG_LOCAL" +CONFIG_COMMON="$CONFIG_PREFIX/common.cfg" +CONFIG_INST="$CONFIG_PREFIX/$I.cfg" + +# Do some integrity checks. +check_file "$TREMDED" "the tremded" +check_dir "$HOME" "the home directory" +check_file "$CONFIG_COMMON" "the common config" +check_file "$CONFIG_INST" "the instance-specific config" + +# Server configuration is done by overwiting the autogen. +cat "$CONFIG_COMMON" "$CONFIG_INST" > "$HOME/$FS_GAME/autogen_server.cfg" \ + || error "couldn't overwrite the autogen\n" # cd to HOME (that's where cores will appear) and start the server. cd "$HOME" || error "cannot chdir to %s\n" "$HOME" -#"$GDB_WRAPPER" "$TREMDED" \ -"$TREMDED" \ +"$GDB_WRAPPER" "$TREMDED" \ +exec "$CONFIG_LOCAL_COMMON" \ +set fs_basepath "$COMMON" \ +set fs_homepath "$HOME" \ +set fs_game "$FS_GAME" \ +set com_pipefile "pipe" \ +set dedicated 2 \ - +exec "$CONFIG_LOCAL_INST" \ +map "atcs" \ +nocurses \ "$@" || error "couldn't start the server\n" -- cgit