Automatically Update Links When Opening a Master Document?

How can I make LibreOffice automatically update links when I open a Master Document template, and not ask me whether I want to update links? I want to open the master document template in headless mode and export a pdf of the resulting document.

Does setting to Always in the dialogue Tools > Options > LibreOffice Writer > Update Links when Loading help?

No, it doesn’t affect the updating of links in master documents, but thanks for the suggestion.

I wonder, then, whether it is possible to write a macro to be executed within LibreOffice when running headless, such that it does what I would do via the user interface to open a master document, update its links, and export a pdf.

FWIW, I can not supply the code to close LibO in headless mode

sub ask()
dim oDoc as object, sText as string
dim args(0) as new com.sun.star.beans.PropertyValue

oDoc = thiscomponent
' you can take filename from oDoc.URL, and adapt
' in that case convertToUrl is superfluous,

If HasUnoInterfaces(oDoc, "com.sun.star.util.XLinkUpdate") Then 
	oDoc.updateLinks()

    args(0).Name = "FilterName"
    args(0).Value = "writer_pdf_Export"
    sText =convertToUrl( "/home/user/" & "updatedLinks" & ".pdf")
    oDoc.storeToURL( sText , args )

	oDoc.close(True)
endif


end sub

Thank you, that is hopeful.

Explored headless mode for linux OS. Prepare LO for not asking updates: with and empty writer document Tools > LibreOffice writer > update Links when loading > never. Close LO
From a terminal start LO in headless mode

soffice --headless --accept=“socket,host=localhost,port=2002;urp;StarOffice.ServiceManager”

In a separate terminal run the next python program

python3 programFileName.py

# adapted from :http://christopher5106.github.io/office/2015/12/06/openoffice-libreoffice-automate-your-office-tasks-with-python-macros.html
#soffice --headless --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
import uno
from com.sun.star.beans import PropertyValue

def dictToProperty(values):
    # call: arg as { 'FilterName': 'writer_pdf_Export' , "foo" : False/True? }
    ps = tuple([PropertyValue(Name=n, Value=v) for n, v in values.items()])
    return ps

# get the uno component context from the PyUNO runtime
localContext = uno.getComponentContext()

# create the UnoUrlResolver
resolver = localContext.ServiceManager.createInstanceWithContext(
				"com.sun.star.bridge.UnoUrlResolver", localContext )

## connect to the running office
try:
    ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
    smgr = ctx.ServiceManager
except:
    print("error in socket ")
    
# get the central desktop object
sUser = "/home/user/"
StarDesktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)

sText = uno.systemPathToFileUrl( sUser +  "ask_links_python.odm")
oDoc = StarDesktop.loadComponentFromURL(sText , "_blank", 0, ())

oDoc.updateLinks()

args = dictToProperty({"FilterName" : "writer_pdf_Export"})
sText = uno.systemPathToFileUrl( sUser + "updatedLinks" + ".pdf")
oDoc.storeToURL( sText , args )

oDoc.close(True)

StarDesktop.terminate()


Thank you. I see that I have a lot to learn about LO macro writing!