# Provisioning script executed twice

**URL:** <https://forum.genieacs.com/t/provisioning-script-executed-twice/2240>\
**Category:** Uncategorized\
**Created:** [December 14, 2021, 11:22am UTC](https://forum.genieacs.com/t/provisioning-script-executed-twice/2240 "2021-12-14T11:22:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![encarta](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@encarta](https://forum.genieacs.com/u/encarta)\
**Post date:** [December 14, 2021, 11:22am UTC](https://forum.genieacs.com/t/provisioning-script-executed-twice/2240/1 "2021-12-14T11:22:11Z")

</div>

I made some test on my development server with simple preset and register a simulator.  
My surprise is that if there are at least one line of setting the value of a parameter or tag are executed, the provisioning script will be executed twice.  
But it will only executed once if there are no value changed.

# Here is my provisioning scripts :

log(“Provisioning”);  
const now = Date.now();  
log(“MN-DEBUG STARTED”);

let myboot = declare(“Events.1\_BOOT”, {value: 1});  
if (myboot.value !== undefined) {  
log(“1 BOOT”);  
}

//let SN=declare(“DeviceID.ID”,{value: 1}).value;  
let SN=declare(“DeviceID.SerialNumber”,{value: 1}).value;

# declare(“Tags.Provisioned”, null, {value: true}); declare(“Tags.Provisioned2”, null, {value: true}); declare(“Tags.Provisioned3”, null, {value: true});

If the device already has all 3 tags, the provisioning only run once. But if there’s at least one Tag not there, the provisioning will run twice for the same event.

# Here is my log says if It doesn’t have all those tags

# 2021-12-14T11:16:03.869Z [INFO] 127.0.0.1 202BC1-BM632w-000000: ACS request; acsRequestId=“17db8a818900000” acsRequestName=“Reboot” 2021-12-14T11:16:03.885Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Inform; cpeRequestId=“adtdwcjr” informEvent=“1 BOOT,M Reboot” informRetryCount=0 2021-12-14T11:16:03.893Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: Provisioning 2021-12-14T11:16:03.893Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: MN-DEBUG STARTED 2021-12-14T11:16:03.894Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: 1 BOOT 2021-12-14T11:16:03.899Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: Provisioning 2021-12-14T11:16:03.899Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: MN-DEBUG STARTED 2021-12-14T11:16:03.901Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: 1 BOOT

# The logs if it has all 3 tags :

# 2021-12-14T11:17:30.604Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Inform; cpeRequestId=“qonhzeui” informEvent=“1 BOOT,M Reboot” informRetryCount=0 2021-12-14T11:17:30.606Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: Provisioning 2021-12-14T11:17:30.606Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: MN-DEBUG STARTED 2021-12-14T11:17:30.609Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: 1 BOOT

# 1 tag is removed from device and, the log :

# 2021-12-14T11:18:43.935Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Inform; cpeRequestId=“7o6d422s” informEvent=“1 BOOT,M Reboot” informRetryCount=0 2021-12-14T11:18:43.937Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: Provisioning 2021-12-14T11:18:43.937Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: MN-DEBUG STARTED 2021-12-14T11:18:43.940Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: 1 BOOT 2021-12-14T11:18:43.945Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: Provisioning 2021-12-14T11:18:43.945Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: MN-DEBUG STARTED 2021-12-14T11:18:43.946Z [INFO] 127.0.0.1 202BC1-BM632w-000000: Script: 1 BOOT

Is this expected behaviors ? If yes, what is the reason behind that ?  
In my opinion, the one preset must be only run once for the matching condition.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/genieacs/original/1X/4f05cf93743b3411bc16ef7cf9437223c1e03d07.png)  
my preset configuration.

---

<div class="post-metadata">

**Author:** ![mths0x5f](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/mths0x5f/32/92_2.png) [@mths0x5f](https://forum.genieacs.com/u/mths0x5f)\
**Post date:** [December 14, 2021, 6:50pm UTC](https://forum.genieacs.com/t/provisioning-script-executed-twice/2240/2 "2021-12-14T18:50:15Z")

</div>

This is expected behavior as GenieACS enforces declarative definitions. This is explicitly stated on documentation: [Provisions — GenieACS Documentation 1.2.8 documentation](https://docs.genieacs.com/en/latest/provisions.html)
