# New rule engine startup - rule initialisation

**URL:** <https://community.openhab.org/t/new-rule-engine-startup-rule-initialisation/18622>\
**Category:** Scripts & Rules\
**Tags:** rules, paperui, ere\
**Created:** [December 22, 2016, 12:41pm UTC](https://community.openhab.org/t/new-rule-engine-startup-rule-initialisation/18622 "2016-12-22T12:41:32Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![mattwire](https://community.openhab.org/user_avatar/community.openhab.org/mattwire/32/71431_2.png) [@mattwire](https://community.openhab.org/u/mattwire)\
**Post date:** [September 4, 2017, 4:16pm UTC](https://community.openhab.org/t/new-rule-engine-startup-rule-initialisation/18622/13 "2017-09-04T16:16:56Z")

</div>

Got this problem too with openhab2 build #1020. My “fix” is a php script based on @Kev_Marlow suggestion:

```auto
<?php

function curlPost($url) {
  // Set a one-minute timeout for this script
  set_time_limit(60);

  $options = array(
    CURLOPT_RETURNTRANSFER => TRUE, // return web page
    CURLOPT_HEADER => FALSE, // don't return headers
    CURLOPT_POST => TRUE,
    CURLOPT_HTTPHEADER => array("Accept: application/json"),
  );

  $session = curl_init($url);
  curl_setopt_array($session, $options);

  // Tell curl that this is the body of the POST
  curl_setopt($session, CURLOPT_POSTFIELDS, $data);

  // $output contains the output string
  $output = curl_exec($session);
}

function curlPut($url, $data) {
  // Set a one-minute timeout for this script
  set_time_limit(60);

  $options = array(
    CURLOPT_RETURNTRANSFER => TRUE, // return web page
    CURLOPT_HEADER => FALSE, // don't return headers
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => array("Content-Type: application/json", "Accept: application/json"),
  );

  $session = curl_init($url);
  curl_setopt_array($session, $options);

  // Tell curl that this is the body of the POST
  curl_setopt($session, CURLOPT_POSTFIELDS, $data);

  // $output contains the output string
  $output = curl_exec($session);
}

function curlGet($url) {
  // Set a one-minute timeout for this script
  set_time_limit(60);

  $options = array(
    CURLOPT_RETURNTRANSFER => TRUE, // return web page
    CURLOPT_HEADER => FALSE, // don't return headers
    CURLOPT_HTTPGET => TRUE,
    CURLOPT_HTTPHEADER => array("Accept: application/json"),
  );

  $session = curl_init($url);
  curl_setopt_array($session, $options);

  // $output contains the output string
  $output = curl_exec($session);
  return $output;
}

$output = curlGet("http://openhab:8080/rest/rules");
if (preg_match_all('/"uid"\:\"(.*?)\"/', $output, $matches)) {
  foreach ($matches[1] as $rule) {
    curlPut("http://openhab:8080/rest/rules/" . $rule . "/config", "{}");
  }
}

```

---

_[View the full topic](https://community.openhab.org/t/new-rule-engine-startup-rule-initialisation/18622)._
