Reboot machine within shell script

Hi,

I am working on a shell script in which i have to run some kind of command then reboot then continue with further commands, Kindly suggest how can we achieve this in current scenario, My Fixlet is getting failed when I add restart in between of my shell script and after reboot Fixlet is also getting failed and post reboot commands also not getting execute.

Here is the described solution, please refer to @JasonWalker’s post.

Reboot and wait - Usage and Config - BigFix Forum

Thanks @vk.khurava but the solution has recommended to use baseline to run part1, reboot, part2.

I am looking for the solution where I can add the reboot in middle of my single Fixlet and after the reboot it should continue for further execution of part2. Single Fixlet solution instead of Baseline. Pls advice.

Unfortunately the way that a fixlet works, it wouldn’t start at the second part of a single fixlet after a reboot, it would re-run the whole script again after the reboot. There are however things you could do to make this work. For example you could put in your relevance OR exists file \part1completed.dat then at the beginning of your actionscript put an if statement before your part one task and say if NOT exists file \part1completed.dat and then take the action for part one only if that dat file doesn’t exist. You would also have that first reboot within that initial if statement. That way if the part1completed.dat file already exists it will skip it and move to part 2. You would need to make sure to delete the part1completed.dat at the end of your script though. Doing it this way with a single task you could run into a scenario where you would have to have it set to reapply (Like a policy) or else it wouldn’t reapply after the reboot.

Have you considered using a baseline for this?

No we did not apply baseline method but I know baseline method will work…

I’m pretty sure the baseline method is the only thing that will work.

If the machine reboots in the middle of running an action, and the reboot wasn’t triggered by the ActionScript ‘restart’ command, that action will be marked as Failed.

Just wondering if as a single fixlet something along the line of this might be viable

Relevance clause
((undesired state logic for 1st part of action) and (not exists setting "Part1RebootTriggered" whose (value of it = "True") of client)) or ((undesired state logic for 2nd part of action) and (exists setting "Part1RebootTriggered" whose (value of it = "True") of client) and (not pending restart "Part1Complete"))

Action

if {not exists setting "Part1RebootTriggered" whose (value of it = "True") of client}
	[your part 1 remediation command here]
	if {logic to validate remediation has completed}
		setting "Part1RebootTriggered"="True" on "{now}" for client
		action requires restart Part1Complete
		run cmd.exe /c "shutdown /r "
	endif
else
	[your part 2 remediation command here]
	setting delete "Part1RebootTriggered" on "{now}" for client
endif
1 Like