NILRT systems determine whether to reboot after various package operations
    including but not limited to kernel module installs/removals by checking
    specific file md5sums & timestamps. These files are touched/modified by
    the post-install/post-remove functions of their respective packages.

    The opkg module uses this function to store/update those file timestamps
    and checksums to be used later by the restartcheck module.

def _update_nilrt_restart_state():
    '''
    NILRT systems determine whether to reboot after various package operations
    including but not limited to kernel module installs/removals by checking
    specific file md5sums & timestamps. These files are touched/modified by
    the post-install/post-remove functions of their respective packages.

    The opkg module uses this function to store/update those file timestamps
    and checksums to be used later by the restartcheck module.

    '''
    __salt__['cmd.shell']('stat -c %Y /lib/modules/$(uname -r)/modules.dep >{0}/modules.dep.timestamp'
                          .format(NILRT_RESTARTCHECK_STATE_PATH))
    __salt__['cmd.shell']('md5sum /lib/modules/$(uname -r)/modules.dep >{0}/modules.dep.md5sum'
                          .format(NILRT_RESTARTCHECK_STATE_PATH))

    # We can't assume nisysapi.ini always exists like modules.dep
    nisysapi_path = '/usr/local/natinst/share/nisysapi.ini'
    if os.path.exists(nisysapi_path):
        __salt__['cmd.shell']('stat -c %Y {0} >{1}/nisysapi.ini.timestamp'
                              .format(nisysapi_path, NILRT_RESTARTCHECK_STATE_PATH))
        __salt__['cmd.shell']('md5sum {0} >{1}/nisysapi.ini.md5sum'
                              .format(nisysapi_path, NILRT_RESTARTCHECK_STATE_PATH))

    # Expert plugin files get added to a conf.d dir, so keep track of the total
    # no. of files, their timestamps and content hashes
    nisysapi_conf_d_path = "/usr/lib/{0}/nisysapi/conf.d/experts/".format(
        'arm-linux-gnueabi' if 'arm' in __grains__.get('cpuarch') else 'x86_64-linux-gnu'
    )

    if os.path.exists(nisysapi_conf_d_path):
        with salt.utils.files.fopen('{0}/sysapi.conf.d.count'.format(
                NILRT_RESTARTCHECK_STATE_PATH), 'w') as fcount:
            fcount.write(str(len(os.listdir(nisysapi_conf_d_path))))

        for fexpert in os.listdir(nisysapi_conf_d_path):
            __salt__['cmd.shell']('stat -c %Y {0}/{1} >{2}/{1}.timestamp'
                                  .format(nisysapi_conf_d_path,
                                          fexpert,
                                          NILRT_RESTARTCHECK_STATE_PATH))
            __salt__['cmd.shell']('md5sum {0}/{1} >{2}/{1}.md5sum'
                                  .format(nisysapi_conf_d_path,
                                          fexpert,
                                          NILRT_RESTARTCHECK_STATE_PATH))