pufferpanel / pufferd

The PufferPanel daemon
https://pufferd.pufferpanel.com
Apache License 2.0
46 stars 15 forks source link

rootdir not replaced for program in environmentVars #73

Closed flyncos closed 5 years ago

flyncos commented 5 years ago

Issue If ${rootdir} is used within an environment variable, it will not be replaced by the correct value when the main program is executed.

Reproduction Load the following (docker) template, install it, and then run it.

{
    "pufferd": {
        "type": "generic",
        "display": "Environment Vars Test",
        "install": {
            "commands": [{
                    "type": "writefile",
                    "text": "echo \"# pre command\"\necho \"ROOTDIR: ${HOME}\"\necho \"MYDATA: ${TESTENV}\"",
                    "target": "preScript_sh"
                },
                {
                    "type": "writefile",
                    "text": "echo \"# main command\"\necho \"ROOTDIR: ${HOME}\"\necho \"MYDATA: ${TESTENV}\"",
                    "target": "mainScript_sh"
                }
            ]
        },
        "run": {
            "stopCode": 2,
            "pre": [{
                    "commands": [
                        "sh preScript_sh"
                    ],
                    "type": "command"
            }],
            "post": [],
            "arguments": [
                "mainScript_sh"
            ],
            "program": "sh",
            "environmentVars": {
                "HOME": "${rootdir}",
                "TESTENV": "${mydata}"
            }
        },
        "environment": {
            "type": "docker",
            "image": "pufferpanel/generic"
        },
        "data": {
            "mydata": {
                "value": "MyTestData",
                "required": true,
                "desc": "Test data",
                "display": "Test Data",
                "internal": false
            }
        }
    }
}

Current behavior:

Starting server
Executing: sh script_sh
# pre command
ROOTDIR: /var/lib/pufferd/servers/e4501a02-74c2-4a95-845f-bc4e2f3a2b49
MYDATA: MyTestData
# main command
ROOTDIR: ${rootdir}
MYDATA: MyTestData
Running post-execution steps

Expected behavior:

Starting server
Executing: sh script_sh
# pre command
ROOTDIR: /var/lib/pufferd/servers/e4501a02-74c2-4a95-845f-bc4e2f3a2b49
MYDATA: MyTestData
# main command
ROOTDIR: /var/lib/pufferd/servers/e4501a02-74c2-4a95-845f-bc4e2f3a2b49
MYDATA: MyTestData
Running post-execution steps

System Info os: debian (9) stretch pufferd: 1.2.7.5 (55ac40b6b894a91fd8cd8758ea6820b96b1bb8a6) pufferpanel: 1.2.4 (6e74bf7b2c63bf61066a2553b8b4241f19b4e96e) docker: 18.09.6, build 481bc77

LordRalex commented 5 years ago

I deprecated rootdir usage, and so it should be rootDir now, to follow camel casing.

I do see how I missed rootdir, but rootDir should work in this case. Can you test using that?

flyncos commented 5 years ago

I do see how I missed rootdir, but rootDir should work in this case. Can you test using that?

Yes, it works with rootDir, thanks and have a nice weekend.