diff --git a/Run.sh b/Run.sh index 431c629..0aacc75 100755 --- a/Run.sh +++ b/Run.sh @@ -41,6 +41,11 @@ function del_ServerActors() { del_iniKey 'Engine.GameEngine' ServerActors $1 del_iniKey 'XC_Engine.XC_GameEngine' ServerActors $1 } +function getmodprefix() { + UFile=$(find $OUTPUT_DIR/System -type f -iname "niut*.u" -exec basename {} \;) + BaseName="${UFile%.*}" + echo "$BaseName" +} function install() { rsync -a $SCRIPT_DIR/Help/ $OUTPUT_DIR/Help/ --exclude '.git' rsync -a $SCRIPT_DIR/System/ $OUTPUT_DIR/System/ --exclude '.git' @@ -48,19 +53,14 @@ function install() { echo install ok } function enable() { - NIUTUFile=$(find $OUTPUT_DIR/System -type f -iname "niut*.u" -exec basename {} \;) - NIUTBaseName="${NIUTUFile%.*}" - add_ServerPackage $NIUTBaseName + BaseName="$(getmodprefix)" + add_ServerPackage $BaseName echo enable ok } function disable() { - NIUTUFile=$(find $OUTPUT_DIR/System -type f -iname "niut*.u" -exec basename {} \;) - echo $NIUTUFile - NIUTBaseName="${NIUTUFile%.*}" - echo $NIUTBaseName - - del_ServerPackage $NIUTBaseName + BaseName="$(getmodprefix)" + del_ServerPackage $BaseName echo disable ok } @@ -93,7 +93,7 @@ function config() { } function show_help() { echo - echo "Usage: $0 { install | enable | disable | config } [] [ ]" + echo "Usage: $0 { getmodprefix | install | enable | disable | config } [] [ ]" echo } function check_cfg_file_config() { @@ -133,7 +133,7 @@ function check_cfg_file_gen() { } function check_game_dir() { ### Check if a directory does not exist ### - if [ ! -d $OUTPUT_DIR ] + if [ -z $OUTPUT_DIR ] then echo "incorrect " show_help @@ -141,6 +141,10 @@ function check_game_dir() { fi } case "$1" in + 'getmodprefix') + check_game_dir + getmodprefix + ;; 'install') check_game_dir "$@" install "$@"