Custom Fixlet Creation

Hello All,
I want to create the action script with below logic, please help with the action script syntax
 -> Add the parameter in Action script which will ask for the Computer group (While clicking on task action Pop-up should appears which will ask to computer group name to be entered).
 -> Backup the C:\XYZ\File.txt
 -> Append the computer group name at last line of C:\XYZ\File.txt (which was manually entered in pop-up box during take action) .
Thanks in Advance!!

Regards,
Manish Singh

Any suggestions would be appreciated!!

Working on a reply, please stand by…

Try this as a stating point:

action parameter query "ComputerGroup" with description "Please enter the BigFix Computer Group:"
if {exist file "c:\test.old"}
    del c:\test.old
endif
copy c:\test.txt c:\test.old
dos echo "{parameter "ComputerGroup"}" >> c:\test.txt
1 Like

Thanks for your help…
So, same would work for Unix as well just we need change the path and we need to use the wait command.
Please correct me if my understanding is wrong.

Regards,
Manish Singh

The last line of the actionscript will not work on Unix since it is specifically for DOS/Windows. Instead of using dos on that line, use run

Yes correct…
Thanks for your response!!

Hello,

I executed the action but getting output as highlight, Can you please suggest what I need to do next

Regards,
Manish Singh

My first guess is the the file may be starting out with some garbage data in it. Can you delete the file and try creating a fresh one?

Sure!!
Let me give a try, Thanks for your prompt response.

Regards,
Manish Singh

@eredmond @JasonWalker :- I’m using below action script to perform the final testing but seems like computer group is not able to copy in user.allow file.
Please check the below script and let me know if I’m doing any mistake.

action parameter query “Computer Group” with description "Enter the computer group"
appendfile cp -p /etc/opt/quest/vas/users.allow /etc/opt/quest/vas/users.allow.backup.date +%Y%m%d%H%M%S
move __appendfile copy.sh
wait chmod 555 copy.sh
wait bash copy.sh
run echo “{parameter “Computer Group”}” >> "/etc/opt/quest/vas/Backup/users.allow"
appendfile systemctl restart vasd
move __appendfile servicerestart.sh
wait chmod 555 servicerestart.sh
wait bash servicerestart.sh

Regards,
Manish Singh

Does the action “complete” in the console or does it report an error?

Also, if you are able to look at the log on the client you are pushing this to may indicate why it is not appending the user.allow file.

In console it got completed successfully.
Will get the log file from platform team to analyse if any error code is generated.

I would rather create the compute group using the wizard. And create the action on the computer group. That what we have been doing for all the upgrades like resolv.conf in 100’s of unix server and package upgrade.

@eredmond :- In log file also I do not see any error, Please have a look and suggest
Command succeeded delete copy.sh (action:23993)

Command succeeded delete servicerestart.sh (action:23993)

Command succeeded action parameter query “Computer Group” with description “Enter the computer group” (action:23993)

Command succeeded appendfile cp -p /etc/opt/quest/vas/users.allow /etc/opt/quest/vas/users.allow.backup.date +%Y%m%d%H%M%S (action:23993)

Command succeeded (file created) appendfile cp -p /etc/opt/quest/vas/users.allow /etc/opt/quest/vas/users.allow.backup.date +%Y%m%d%H%M%S (action:23993)

Command succeeded appendfile cp -p /etc/opt/quest/vas/users.allow /etc/opt/quest/vas/users.allow.backup.date +%Y%m%d%H%M%S (action:23993)

Command succeeded move __appendfile copy.sh (action:23993)

Command started - wait chmod 555 copy.sh (action:23993)

Command succeeded (Exit Code=0) wait chmod 555 copy.sh (action:23993)

At 12:30:46 +0100 - actionsite (http://XYZ:52311/cgi-bin/bfgather.exe/actionsite)

Command started - wait bash copy.sh (action:23993)

Command succeeded (Exit Code=0) wait bash copy.sh (action:23993)

At 12:30:47 +0100 - actionsite (http://XYZ:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded run echo “GG_FOS” >> “/etc/opt/quest/vas/users.allow” (action:23993)

Command succeeded (file created) appendfile systemctl restart vasd (action:23993)

Command succeeded appendfile systemctl restart vasd (action:23993)

Command succeeded move __appendfile servicerestart.sh (action:23993)

Command started - wait chmod 555 servicerestart.sh (action:23993)

I modified the scrip and now it is working, below script might be helpful for others.
Command succeeded delete copy.sh (action:23993)

delete copy.sh

delete servicerestart.sh

delete users.sh

action parameter query “Computer Group” with description “Enter the computer group”

//if (exists file “/etc/opt/quest/vas/Backup/users.allow”)

//delete “/etc/opt/quest/vas/Backup/users.allow”

//folder create “/etc/opt/quest/vas/Backup”

//move “/etc/opt/quest/vas/users.allow” “/etc/opt/quest/vas/Backup/users.allow”

appendfile cp -p /etc/opt/quest/vas/users.allow /etc/opt/quest/vas/users.allow.backup.date +%Y%m%d%H%M%S

move __appendfile copy.sh

wait chmod 555 copy.sh

wait bash copy.sh

appendfile echo “{parameter “Computer Group”}” >> “/etc/opt/quest/vas/users.allow”

move __appendfile users.sh

wait chmod 555 users.sh

wait bash users.sh

appendfile systemctl restart vasd

move __appendfile servicerestart.sh

wait chmod 555 servicerestart.sh

wait bash servicerestart.sh

So it is working now? That is good news.

1 Like

I think I see what the issue was with this script now…

I think this line

run echo “{parameter “Computer Group”}” >> “/etc/opt/quest/vas/Backup/users.allow”

needed to be

run echo “{parameter “Computer Group”}” >> “/etc/opt/quest/vas/users.allow”

I changed this but still it was not working.
Hence I have use appendfile and stored it in .sh file.
Once again thanks a lot for your help, it was really helpful :slight_smile:

I’m not in a position to check, but I don’t think there is a binary named ‘echo’, I think you’d have to spawn a shell to access the shell’s echo command. Something like

waithidden /bin/sh -c "echo foo > /tmp/file.out"