SDK Script update-config.are

update-config.are
/* DESC: This script can be used to perform a configuration update
 * Copyright (C) 2013 NetModule AG, Switzerland
 */
 
dir = "/config";
url = sprintf("dir://%s", dir);
 
mkdir(dir, S_IRUSR|S_IWUSR|S_IXUSR);
mkdir(sprintf("%s/files", dir), S_IRUSR|S_IWUSR|S_IXUSR);
 
cfg = sprintf("%s/user-config.cfg", dir);
fp = fopen(cfg, "w");
if (!fp) {
    printf("unable to open %s\n", cfg);
    exit(1);
}
fwrite(fp, "config.version=1.1\n");
fwrite(fp, "admin.password=admin01\n");
fwrite(fp, "sdk.status=1\n");
fclose(fp);
 
rc = nb_update_config(url);
printf("update returns %d\n", rc);
 
exit(rc);