Mise à jour de 'Run.sh'

implement 'config' command in Run.sh
This commit is contained in:
2022-07-17 00:20:55 +00:00
parent bcc08474be
commit 32cdf2e412

77
Run.sh
View File

@@ -8,6 +8,9 @@ function add_iniKeyEx() {
# Warning: ugly hack with sed to allow multiple key instances + to remove space around '='
sed -i "s/[[:space:]]*__$(echo $3 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')[[:space:]]*=[[:space:]]*/$(echo $3 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')=/g" $OUTPUT_DIR/System/$1
}
function set_iniKeyEx() {
crudini --set $OUTPUT_DIR/System/$1 $2 __$3 $4
}
# !!Warning!! section is not considered
function del_iniKeyEx() {
sed -i "/[[:space:]]*$(echo $3 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')[[:space:]]*=[[:space:]]*$(echo $4 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/d" $OUTPUT_DIR/System/$1
@@ -15,6 +18,9 @@ function del_iniKeyEx() {
function add_iniKey() {
add_iniKeyEx $CFG_FILE $1 $2 $3
}
function set_iniKey() {
set_iniKeyEx $CFG_FILE $1 $2 $3
}
# !!Warning!! section is not considered
function del_iniKey() {
del_iniKeyEx $CFG_FILE $1 $2 $3
@@ -56,12 +62,56 @@ function disable() {
echo disable ok
}
function config() {
case $# in
5)
OptionKey=$4
OptionValue=$5
;;
4)
OptionKey=$3
OptionValue=$4
;;
*)
echo "Not enough arguments"
show_help
exit 1
;;
esac
NIUT_FileName=$(find $OUTPUT_DIR/System -type f -iname "NIUT*.ini" -exec basename {} \;)
NIUT_BaseFileName="${NIUT%.*}"
case "$OptionKey" in
*)
set_iniKeyEx NIUT.ini "$NIUT_BaseFileName.NIUTMutator" $OptionKey $OptionValue
;;
esac
}
function show_help() {
echo
echo "Usage: $0 { install | enable | disable } <UT99_INSTALL_DIR> [<UT99_CONFIG_FILE>]"
echo
}
function check_cfg_file() {
function check_cfg_file_config() {
if [ $# -eq 4 ]
then
echo "CFG_FILE is unset, setting it to $DEFAULT_CFG_FILE"
CFG_FILE=$DEFAULT_CFG_FILE
elif [ $# -eq 5 ]
then
echo "CFG_FILE is set to '$CFG_FILE'"
else
echo "Wrong number of arguments"
show_help
exit 9999 # die with error code 9999
fi
if [ ! -f $OUTPUT_DIR/System/$CFG_FILE ]
then
echo "$OUTPUT_DIR/System/$CFG_FILE does not exist"
show_help
exit 9999 # die with error code 9999
fi
}
function check_cfg_file_gen() {
if [ -z ${CFG_FILE} ]
then
echo "CFG_FILE is unset, setting it to $DEFAULT_CFG_FILE"
@@ -87,23 +137,28 @@ function check_game_dir() {
}
case "$1" in
'install')
check_game_dir
install
check_game_dir "$@"
install "$@"
;;
'enable')
check_game_dir
check_cfg_file
disable
enable
check_game_dir "$@"
check_cfg_file_gen "$@"
disable "$@"
enable "$@"
;;
'config')
check_game_dir "$@"
check_cfg_file_config "$@"
config "$@"
;;
'disable')
check_game_dir
check_cfg_file
disable
check_game_dir "$@"
check_cfg_file_gen "$@"
disable "$@"
;;
*)
show_help
exit 1
;;
esac
exit 0
exit 0