Run configure hook only after installation

Hello I have defined a configure hook which checks if certain user-defined ports are available before snap service is started for the first time installation. I have a snap service defined with refresh-mode set to endure, install-mode set to disable and daemon set to simple. Since I don’t want the service to stop during refresh, configure hook runs after every refresh and finds the port already allocated thereby failing the snap upgrade. Is there a way to run configure hook only during first time installation since my service should always keep running and never stopped?

Sounds as though an install hook is what you want

But without configure hook I can’t pass config variables (user-defined ports) after installation.