New PXE menu entry: Deploy Image & Shutdown
-
@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.
-
@Tom-Elliott said in New PXE menu entry: Deploy Image & Shutdown:
Ok. I’ve done the following.
root@hs-fog:~# wget -O /var/www/fog/lib/fog/bootmenu.class.php https://raw.githu busercontent.com/FOGProject/fogproject/working/packages/web/lib/fog/bootmenu.cla ss.php --2017-05-17 23:03:43-- https://raw.githubusercontent.com/FOGProject/fogproject /working/packages/web/lib/fog/bootmenu.class.php Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.124.1 33 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.124. 133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 62089 (61K) [text/plain] Saving to: ‘/var/www/fog/lib/fog/bootmenu.class.php’ /var/www/fog/lib/fo 100%[===================>] 60.63K --.-KB/s in 0.03s 2017-05-17 23:03:44 (1.97 MB/s) - ‘/var/www/fog/lib/fog/bootmenu.class.php’ save d [62089/62089] root@hs-fog:~# reboot
After reboot I booted to pxe menu with a registered host and deployed an image to it with the modified “Deploy Image” option.
I then went to this address.
http://10.20.21.136/fog/service/ipxe/boot.php?mac=<hostmac>
And got the following results:
#!ipxe set fog-ip 10.20.21.136 set fog-webroot fog set boot-url http://${fog-ip}/${fog-webroot} kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=127000 web=10.20.21.136/fog/ consoleblank=0 rootfstype=ext4 storage=10.20.21.136:/images/ storageip=10.20.21.136 mac=<hostmac> ftp=10.20.21.136 storage=10.20.21.136:/images/ storageip=10.20.21.136 osid=9 irqpoll hostname=<hostname> chkdsk=0 img=Windows10 imgType=n imgPartitionType=all imgid=1 imgFormat=0 PIGZ_COMP=-9 hostearly=1 type=down imgfetch init_32.xz boot
It’s deploying now. I don’t see the
shutdown=1
option in there. -
So, I never did get this to work. I got busy and was unable to reply back while I was at work.
-
@Avaryan I suspect what’s wrong, though I don’t have a good fix coming for it right now :(.
I have to think of a way to pass in extra args and it’s not always the simplest thing.
I think an approach to help address this would be:
Add a new field per each “menu option” that allows you to check “shutdown” or not. This way I can make it pass a variable, theoretically, from one window to the next for that menu item. Just my thoughts though. I don’t have a quick fix quite yet. Sorry -
Not a big deal for me. I’m not even the one who requested this, lol.
-
@Tom-Elliott Thank you for trying. That field per each menu option would be great. As for now, we are setting Fog kernel with shutdown=1 when we need to mass deploy machines before sending them out to the sites and then remove the shutdown setting. Its a little hassle, but hey, it works. I’ll keep an eye out on newer releases to see if you manage to get the shutdown field put in.