Skip to content

Removing WORKSHOP_ITEM results in stray mod files #45

Description

@jahnooska

Is your feature request related to a problem? Please describe

When a mod is added to WORKSHOP_ITEMS and removed at a later date, a stray installation of the mod is left in the workshop install directory of the server.

Describe the solution you'd like

If a mod installation exists in the workshop install directory, but is not present in WORKSHOP_ITEMS, it should be deleted when the container starts.

Describe alternatives you've considered

Implementing a mod cleanup in server monitoring could address this outside of the container, but would requiring parsing in the environment.

Additional context

I've implemented a fix in my own build of your container on init.sh like so:

# Remove unused mods from workshop directory
if [ -n "$WORKSHOP_ITEMS" ]; then
    MODS_CLEANED=$(echo "$WORKSHOP_ITEMS" | tr -d ';' | tr '\n' ' ')
    MODS_ARRAY=($(echo "$WORKSHOP_ITEMS" | tr ';' '\n' | grep -v '^$'))
    WORKSHOP_DIR="/project-zomboid/steamapps/workshop/content/108600"
    if [ -d "$WORKSHOP_DIR" ]; then
        for dir in "$WORKSHOP_DIR"/*; do
            if [ -d "$dir" ]; then
                mod_id=$(basename "$dir")
                found=0
                for active_mod in "${MODS_ARRAY[@]}"; do
                    if [ "$mod_id" = "$active_mod" ]; then
                        found=1
                        break
                    fi
                done
                if [ $found -eq 0 ]; then
                    LogAction "Removing unused mod directory: $dir"
                    rm -rf "$dir"
                fi
            fi
        done
    fi
fi

Feature Report Checklist

  • I am willing to implement this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions