noobient / killinuxfloor

noobient's Killing Floor 2 Linux Server Installer and Manager
MIT License
17 stars 4 forks source link

Investigate possibility of pushing webadmin changes to own config #31

Open bviktor opened 5 years ago

bviktor commented 5 years ago

https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes

yum install inotify-tools

Then

inotifywait -m -e modify foo.txt

If only I could log the changes...

inotifywait --quiet --monitor --event modify FILE | while read; do
    # trim the trailing space from inotifywait output
    REPLY=${REPLY% }
    filename=${REPLY%% *}
    # do whatever you want with the $filename
done
bviktor commented 5 years ago

Maybe we should save the default files everytime we run killinuxfloor reset, then when inotify says there's a change, make a diff, and apply the diff to the My-* files?

bviktor commented 5 years ago

But then what about map cycles? We store them in a custom file... duh.

bviktor commented 5 years ago

Maybe we should make them read-only in webadmin, much like bans?

bviktor commented 5 years ago

Nah, instead, we should make everything editable in webadmin. Then we don't have to deal with command line at all. But then we gotta find a way to make the 2 "default" cycles immutable.

bviktor commented 5 years ago

default_maplist.html

    cycleId = "<%maplistidx%>";
    document.getElementById("simpleEditBtn").hidden = true;
    if (cycleId <= 1)
    {
        document.getElementById("mlactions.save").hidden = true;
        document.getElementById("mlactions.delete").hidden = true;
        document.getElementById("jsmlctrls").hidden = true;
        document.getElementById("jsmapcycle").readOnly = true;

        //var element = document.getElementById("jsmapcycle");
        //element.classList.remove("ui-sortable");

        /* remove the delete buttons reactively
         * ugly, but this way we can avoid touching js files */
        [].forEach.call(document.querySelectorAll('.deleteButton'), function (el)
        {
            el.style.visibility = 'hidden';
        });

        //[].forEach.call(document.querySelectorAll('.ui-droppable'), function (el)
        //{
        //    el.classList.remove("ui-droppable");
        //});
    }
bviktor commented 5 years ago

Still needs work, gotta disable drag-n-drop somehow.

bviktor commented 5 years ago

The responsible code in default_maplist_editor.js:

    /* cycle map reordering */
    _jsmapcycle.sortable({
        axis: "y",
        containment: "parent",
        cancel: ".deleteButton",
        start: function(ev, ui) {
            $(ui.helper).addClass('dragging');
        },
        stop: function(ev, ui) {
            $(ui.helper).removeClass('dragging');
        }
    });

    /* cycle map dropping */
    $('#jsmapcycle').parent().droppable({
        accept: "li.mapEntry",
        hoverClass: "dropHover",
        activeClass: "droppable",
        drop: function(ev, ui) {
            var item = $('.entry', ui.draggable).text();
            item = createMapListEntry(item);
            getDeleteMe(item);
            setupRndLimitEditor($(item));
            _jsmapcycle.append(item);
            _jsmapcycle.sortable("refresh");
            _jsmapcycle.sortable("refreshPositions");
        }
    });

Without these it works perfectly, but this is, again, JS, so you can't patch it, coz it's served as gzip...

But in the meanwhile I realized it's not even a problem, because the save button is already hidden, so apart from UI glitches, nothing wrong can happen.

bviktor commented 5 years ago

Uh, this may not necessarily work because there are several keys with multiple values and crudini just won't work with those :(