New PXE menu entry: Deploy Image & Shutdown
-
No, that wouldn’t work. Right now, I’m imaging 100 machines. The way we build our images is we install Windows, get it updated with drivers then we run a script before we upload the image to Fog. The script is just a host rename and domain join, something that Fog client can do but we can’t use it due to the company not wanting us to use it. If a shutdown after imaging can be done as a new menu entry, it would save me from having to register the machines in Fog and starting them from the web UI with the shutdown check box checked. I didn’t know if you could set up the menu entry to schedule a shutdown after the imaging like you can do from the web ui.
-
@psyfer9983 Maybe I didn’t explain my idea well enough.
If you were to register the machine and deploy an image. If you select the check box that says shutdown after deployment the FOG server adds the kernel parameter
shutdown=1
to the instructions FOG tells FOS when booting the target computer.So what I propose is to just force that kernel parameter for every imaging event where you PXE boot the target computer. There is no need to register the target computer, there is no need for the fog client. This command happens in the imaging stage only.
-
Does anyone know if or how to set “shutdown=1” via pxe menu?
-
Testing something. I’ll let you know in about 15 minutes if it worked.
edit: Didn’t work. -
Is this a specific host? Are you wanting this for “every host regardless?”
-
@Tom-Elliott He wants after quick imaging to shutdown the computer, either by asking or just do it.
I thought the easiest way is with a kernel parameter.
-
@george1421 that sounds the easiest to me too. since it sounds like he’s not registering them and managing them in fog anyway. the only tasks it would affect are captures and deploys.
-
@george1421 It definitely is the easiest way, but if it’s specific to “quick imaging” goto:
FOG Configuration Page->iPXE Menu Configuration->fog.deployimage
InBoot Options:
add:shutdown=1
If you want it for ALL tasks (will not impact debug of course):
FOG Configuration Page->FOG Settings->General Settings->FOG_KERNEL_ARGS and add:shutdown=1
-
@Tom-Elliott said in New PXE menu entry: Deploy Image & Shutdown:
@george1421 It definitely is the easiest way, but if it’s specific to “quick imaging” goto:
FOG Configuration Page->iPXE Menu Configuration->fog.deployimage
InBoot Options:
add:shutdown=1
If you want it for ALL tasks (will not impact debug of course):
FOG Configuration Page->FOG Settings->General Settings->FOG_KERNEL_ARGS and add:shutdown=1
I just tried this and it did not work. Still booted to Windows after imaging.
-
@Avaryan Then something wasn’t done correctly. Did you have exactly
shutdown=1
? Code to validate is literally:
[[ $shutdown -eq 1 ]] && poweroff || reboot -f
-
@Avaryan Its important to not have spaces it should be one command
-
@Tom-Elliott Is there a way we can capture if the boot options field is translating into a kernel parameter for the quick image (yes I know its not called quick image any more).
-
@george1421 If they goto http://fogipaddress/fog/service/ipxe/boot.php?mac=<macofhostbooting>
You should see ‘shutdown=1’ in the list of arguments.
-
@Tom-Elliott said in New PXE menu entry: Deploy Image & Shutdown:
@Avaryan Then something wasn’t done correctly. Did you have exactly
shutdown=1
? Code to validate is literally:
[[ $shutdown -eq 1 ]] && poweroff || reboot -f
This is exactly what I have:
http://puu.sh/vT05Q/eae7a8eadc.pngDid not work. It was an unregistered host. Haven’t tried with a registered one.
FOG 1.4.0 Revision 6069.
edit: Deploying image to a different model now. Device is registered (although that shouldn’t matter?). ETA 15 minutes.
-
Right now, the only way I can get the shutdown to work is by adding the “shutdown=1” to the “FOG_KERNEL_ARGS”. It works but its set globally which is not what I’m looking for. I would like everything to function like it should on default settings (unless set when creating a task in the WebUI). I would like to just add a new entry that does the same thing as “Deploy Image” but with a shutdown after deploy. If I could pass the “shutdown=1” to “FOG_KERNEL_ARGS” via new pxe menu entry, this would be great as it would leave everything else as default settings.
FYI, I’m on version 1.3.3
-
@Tom-Elliott said in New PXE menu entry: Deploy Image & Shutdown:
This is what is currently in that PHP file, I don’t see the shutdown.
#!ipxe set fog-ip X.X.X.X set fog-webroot fog set boot-url http://${fog-ip}/${fog-webroot} cpuid --ext 29 && set arch x86_64 || set arch i386 iseq ${platform} efi && set key 0x1b || set key 0x1b iseq ${platform} efi && set keyName ESC || set keyName Escape prompt --key ${key} --timeout 3000 Booting... (Press ${keyName} to access the menu) && goto menuAccess || chain -ar ${boot-url}/service/ipxe/grub.exe --config-file="rootnoverify (hd0);chainloader +1" :menuAccess login params param mac0 ${net0/mac} param arch ${arch} param platform ${platform} param username ${username} param password ${password} param menuaccess 1 param debug 1 isset ${net1/mac} && param mac1 ${net1/mac} || goto bootme isset ${net2/mac} && param mac2 ${net2/mac} || goto bootme :bootme chain -ar http://X.X.X.X/fog/service/ipxe/boot.php##params
-
Adding
shutdown=1
to the Boot Options for the deploy option does not work. Tested on 3 different devices. -
@Avaryan I can understand why (with my limited knowledge of the inner workings of FOG) the way the quick image menu is created. The quick image menu doesn’t call the the kernel load directly but it turns around and calls boot.php again which then creates a new menu for image selection. Its possible that the kernel parameter is getting lost on this second boot.php call.
or the field value for
shutdown=1
is wrong and should be written asparam shutdown 1
instead to be in line with what iPXE is expecting. -
Mind trying this?
wget -O /var/www/fog/lib/fog/bootmenu.class.php https://raw.githubusercontent.com/FOGProject/fogproject/working/packages/web/lib/fog/bootmenu.class.php
TLDR; I’m an idiot though it was meant with good intentions, please try above and let me know if it’s better.
Apparently when I was adding the API, I was trying to ensure the API was stateless and was making adjustments to elements using
$_SESSION
variables. The boot menu script (what I’m asking you to copy) had a few of them for something I implemented a while ago to address this very problem. Not thinking about it when making adjustments, I removed all the relevant bits and didn’t replace them. My initial thoughts were that there wasn’t anything in the boot menu requiring those SESSION elements. I’ve readded these bits and maintained the “stateless” element of the script. While I did re-add these things, my tests are currently limited to simple browser checks calling out to a rather direct url. As such, a test going into deployimage would be extremely useful from a “full” run. -
@Tom-Elliott I’ll test in the morning (8 hours from now) when I get back to my office. Although I could probably connect to VPN and deploy image into a VM.
edit: I ran the script and updated the file on my test server. Can’t access a computer on the correct vlan to deploy an image to. Will continue in the morning.