Welcome to the PufferPanel community forums! If you need help please register an account and post in the Support category.

Trying to get a server to launch a python script pre launch

  • I have tried to edit the <server_id>.json file to get my Garry's Mod to run a python script which updates the workshop content that the clients have to download. I have tried to add a new editible field for the edit server bit on pufferpanel and added the command to run in the pre[] section. Here is the json i have edited:

    I have attempted to add a new field section (collectionid) here:

    "map": {
            "desc": "Map to load by default",
            "display": "Map",
            "internal": false,
            "required": true,
            "value": "ttt_minecraft_haven",
            "userEdit": false
    	  "collectionid": {
            "desc": "Workshop Collection ID",
            "display": "Collection Id",
            "internal": false,
            "required": false,
            "value": "1283432484",
            "userEdit": false
          "maxplayers": {
            "desc": "Max players allowed on server",
            "display": "Max Players",
            "internal": false,
            "required": true,
            "value": "20",
            "userEdit": false

    and this is the pre section in run:

    "pre": [
    		"python /srv/lib/server_stuff/server_startup_scripts/garrysmod/workshop_updater2.0.py ${collectionid} /var/lib/pufferd/servers/${name}/garrysmod/lua/autorun/server/workshop.lua"

    I restarted the pufferd service and now pufferpanel says this when i do sudo service pufferd status:
    pufferd[14968]: json: cannot unmarshal string into Go struct field RunObject.pre of type map[string]interface {}

    Any help into getting this to work would be great :)

  • The structure for pre follows how install works.

    You need:

    "pre": [ {
        "type": "command",
        "commands": ["python /srv/lib/server_stuff/server_startup_scripts/garrysmod/workshop_updater2.0.py ${collectionid} ${rootDir}/garrysmod/lua/autorun/server/workshop.lua"]

    For reference, ${name} is not a value we populate (although I see usages for why we might want to), and ${rootdir} actually points to the root directory of the server (so would cover the /var/lib/pufferd/server/name/).

  • Ah yeah, just solved the pre sturcture issue i was having, although i didn't know about the ${rootdir}, i'll use that instead

    Thanks :)

  • Commands also do run in the server's root, so you might have been able to just pass garrysmod/lua/autorun/server/workshop.lua to your python script if it knows where it's running from.

Log in to reply