{= include "templates.util.base_util"; include "lib.profile"; bool is_root_admin = get_is_root_admin(); if (is_root_admin) then ( # Get the template profile string template_profile_name = miscellaneous.create_many_profiles.template_profile_name; string template_profile = "profiles." . template_profile_name; "Creating profiles from template '$template_profile_name'\n"; # Delete the profiles we're about to create, if they exist string profile; foreach profile "miscellaneous.create_many_profiles.profiles" ( string profilename = node_name(profile); string profilepathname = expand("$LOGANALYSISINFO_DIRECTORY") . internal.directory_divider . "profiles" . internal.directory_divider . node_name(profile) . ".cfg"; if (file_exists(profilepathname)) then ( echo("Deleting " . profilepathname); delete_file(profilepathname); write_file(profilepathname, profilename . " = ''"); ); ); # Create the profiles foreach profile "miscellaneous.create_many_profiles.profiles" ( # Duplicate the node string profilename = node_name(profile); echo("Creating profile: " . profilename); string newprofilepath = "profiles." . profilename; (newprofilepath . "") = ""; node newprofile = newprofilepath; save_node(newprofile); duplicate_node(template_profile, newprofile); # Apply any changes if (node_exists(profile . ".changes")) then ( string change; foreach change (profile . ".changes") ( # Set the change in the new profile apply_change(profile, newprofile, change); ) # foreach change ); # if changes save_node(newprofile); # debug_message("New profile: " . node_as_string("profiles." . miscellaneous.create_many_profiles.template_profile_name) . "\n"); ); ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}