kaimallea / csgo

A containerized dedicated server for Counter-Strike: Global Offensive
The Unlicense
243 stars 58 forks source link

Easy way to disable sourcemod plugins? #63

Open fuzzy76 opened 2 years ago

fuzzy76 commented 2 years ago

Is there a way to disable sourcemod plugins without relying on the storage volume being kept? nextmap blocks using the builtin map vote at the end of the turns.

Soren90 commented 1 year ago

Hello,

I see that this issue is pretty old, but better late than never, right?

It seems like there is no built in function to do this for now. I think the easiest way for you (without coding) is to wipe the file manage_plugins.sh and build the container from the Dockerfile

If you want to be able to toggle this in the environment variables, I would do something like this in manage_plugins.sh and then set environment variable MODS_ENABLED=0:

export MODS_ENABLED="${MODS_ENABLED:-1}"

if [ "$MODS_ENABLED" = "1" ]; then
    echo "Installing plugins..."

    mkdir -p "$CSGO_DIR/csgo"
    IFS=' ' read -ra PLUGIN_URLS <<< "$(echo "$INSTALL_PLUGINS" | tr "\n" " ")"
    for URL in "${PLUGIN_URLS[@]}"; do
      install_plugin "$URL"
    done

    echo "Finished installing plugins."

    # Add steam ids to sourcemod admin file
    mkdir -p "$CSGO_DIR/csgo/addons/sourcemod/configs"
    IFS=',' read -ra STEAMIDS <<< "$SOURCEMOD_ADMINS"
    for id in "${STEAMIDS[@]}"; do
        echo "\"$id\" \"99:z\"" >> "$CSGO_DIR/csgo/addons/sourcemod/configs/admins_simple.ini"
    done

    PLUGINS_ENABLED_DIR="$CSGO_DIR/csgo/addons/sourcemod/plugins"
    PLUGINS_DISABLED_DIR="$CSGO_DIR/csgo/addons/sourcemod/plugins/disabled"
    RETAKES_PLUGINS="retakes.smx retakes-instadefuse.smx retakes_autoplant.smx retakes-hud.smx retakes_standardallocator.smx"
    PUGSETUP_PLUGINS="pugsetup.smx pugsetup_teamnames.smx pugsetup_damageprint.smx"

    # Disable Retakes by default so that we have a working and predictable state without plugins conflict
    if [[ -f "$PLUGINS_ENABLED_DIR"/retakes.smx ]]; then
      mv "$PLUGINS_ENABLED_DIR"/retakes*.smx "$PLUGINS_DISABLED_DIR"/
    fi

    if [ "$RETAKES" = "1" ]; then
      if [[ -f "$PLUGINS_ENABLED_DIR"/pugsetup.smx ]]; then
        (cd "$PLUGINS_ENABLED_DIR" && mv pugsetup*.smx "$PLUGINS_DISABLED_DIR")
        echo "Disabled PugSetup plugins"
      fi
      # shellcheck disable=SC2086
      (cd "$PLUGINS_DISABLED_DIR" && mv $RETAKES_PLUGINS "$PLUGINS_ENABLED_DIR")
      echo "Enabled Retakes plugins"
    else
      if [[ -f "$PLUGINS_DISABLED_DIR"/pugsetup.smx ]]; then
        # shellcheck disable=SC2086
        (cd "$PLUGINS_DISABLED_DIR" && mv $PUGSETUP_PLUGINS "$PLUGINS_ENABLED_DIR")
        echo "Enabled PugSetup plugins"
      fi
    fi
fi

Please note that I haven't tested this code. But that is how I would start :)

Soren90 commented 1 year ago

I just noticed that I created a pull request long ago to fix exactly this. But it never got implemented. This might be something you could use?

https://github.com/kaimallea/csgo/pull/43/commits/dd82b1c0f88f69cea8f265c4d6431062c6cc7043