[tt]-U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m
-U flash:w:"$WORKSPACE_LOC"/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex:i
-U lock:w:0x2f:m
[/tt]
That works to "configure, erases&unlock, set fuses, program bootloader, lock."
You can only retain the bootloader by programming WITH the bootloader; the bootloader has the ability to erase/reprogram a single page at a time, but ISP programming requires that you erase the entire chip (including the bootloader) before you can progam anything new. (That's SPI-based ISP. I'm not sure about JTAG.)