The script is not working as per my expectation.
action parameter query âsitecontrolleraddressâ with description âPlease enter Site Controller Address IP value:â
delete __appendfile
appendfile {concatenation â%0d%0aâ of ((lines whose (it as lowercase does not start with âPANACES_SITE_CONTROLLER_ADDRESS=â) of it;âPANACES_SITE_CONTROLLER_ADDRESS=â & parameter âsitecontrolleraddressâ of action) of file â/tmp/scripttest/PanacesAgentGeneric.cfgâ)}
copy â/tmp/scripttest/PanacesAgentGeneric.cfgâ â/tmp/scripttest/PanacesAgentGeneric.cfg.backupâ
move __appendfile â/tmp/scripttest/PanacesAgentGeneric.cfgâ
Its adding one more line entry in the file below.
cat PanacesAgentGeneric.cfg
PANACES_MASTER_SERVER_ADDRESS=10.x.x.x
PANACES_SLAVE_SERVER_ADDRESS=10.x.x.x
PANACES_AGENT_NODE_ADDRESS=10.x.x.x
PANACES_AGENT_NODE_BIND_ADDRESS=
PANACES_SITE_CONTROLLER_ADDRESS= ( this suppose to add IP here )
IS_SERIALCALL_ENABLED=false
PANACES_SITE_CONTROLLER_ADDRESS=10.x.x.x ( instead , its added one more entry in the last line )
My requirement is
if file has already line entry has ( PANACES_SITE_CONTROLLER_ADDRESS= ), use the same input value ( PANACES_SITE_CONTROLLER_ADDRESS= ) & use parameter to append the new IP
If file doesnât have ( PANACES_SITE_CONTROLLER_ADDRESS= ) entry, add new line with new IP .
I need output in the below format ::
cat PanacesAgentGeneric.cfg
PANACES_MASTER_SERVER_ADDRESS=10.x.x.x
PANACES_SLAVE_SERVER_ADDRESS=10.x.x.x
PANACES_AGENT_NODE_ADDRESS=10.x.x.x
PANACES_AGENT_NODE_BIND_ADDRESS=
PANACES_SITE_CONTROLLER_ADDRESS=10.x.x.x
IS_SERIALCALL_ENABLED=false