[rt-devel] contributions helper

Phil Homewood pdh at snapgear.com
Sun Dec 22 21:02:07 EST 2002


Jesse Vincent wrote:
> RT3's initdb does that, except it's hardcoded for a standard datafile.
> I bet it would be < 10 lines to allow it to take a datafile.  I'll take
> a patch.

Untested, as I have yet to dive into RT3, but......
(it's somewhat more than 10 lines of diff on account of moving
some 310 lines from one file to another :-)

This may not even run, let alone do the right thing -- but it's
a starting point...

initdb --datafile=file (default:- $RT::EtcPath/initialdata)
-- 
Phil Homewood, Systems Janitor, www.SnapGear.com
pdh at snapgear.com Ph: +61 7 3435 2810 Fx: +61 7 3891 3630
SnapGear - Custom Embedded Solutions and Security Appliances
-------------- next part --------------
diff -urN rt-2-1-54-orig/etc/initialdata rt-2-1-54/etc/initialdata
--- rt-2-1-54-orig/etc/initialdata	1970-01-01 10:00:00.000000000 +1000
+++ rt-2-1-54/etc/initialdata	2002-12-23 12:01:04.000000000 +1000
@@ -0,0 +1,312 @@
+# Initial data for a fresh RT3 Installation.
+
+my @users = (
+    {  Name     => 'Nobody',
+       RealName => 'Nobody in particular',
+       Comments => 'Do not delete or modify this user. It is integral '
+         . 'to RT\'s internal data structures',
+       Privileged => '0', },
+
+    {  Name         => 'root',
+       Gecos        => 'root',
+       RealName     => 'Enoch Root',
+       Password     => 'password',
+       EmailAddress => "root\@localhost",
+       Comments     => 'SuperUser',
+       Privileged   => '1', } );
+
+my @groups = (
+    { Name        => '',
+      Type        => 'Everyone',                        # loc
+      Domain      => 'SystemInternal',
+      Instance    => '',
+      Description => 'Pseudogroup for internal use',    # loc
+    },
+    { Type        => 'Privileged',                      # loc
+      Domain      => 'SystemInternal',
+      Instance    => '',
+      Name        => '',
+      Description => 'Pseudogroup for internal use',    # loc
+    },
+    { Name        => '',
+      Type        => 'Unprivileged',                    # loc
+      Domain      => 'SystemInternal',
+      Instance    => '',
+      Description => 'Pseudogroup for internal use',    # loc
+    },
+    { Name        => '',
+      Type        => 'Owner',                               # loc
+      Domain      => 'RT::System-Role',
+      Instance    => '',
+      Description => 'SystemRolegroup for internal use',    # loc
+    },
+    { Name        => '',
+      Type        => 'Requestor',                           # loc
+      Domain      => 'RT::System-Role',
+      Instance    => '',
+      Description => 'SystemRolegroup for internal use',    # loc
+    },
+    { Name        => '',
+      Type        => 'Cc',                                  # loc
+      Domain      => 'RT::System-Role',
+      Instance    => '',
+      Description => 'SystemRolegroup for internal use',    # loc
+    },
+    { Name        => '',
+      Type        => 'AdminCc',                             # loc
+      Domain      => 'RT::System-Role',
+      Instance    => '',
+      Description => 'Pseudogroup for internal use',        # loc
+    }, );
+
+my @queues = ( {  Name              => 'General',
+                  Description       => 'The default queue',
+                  CorrespondAddress => "",
+                  CommentAddress    => "", }, );
+
+my @ScripActions = (
+
+    {  Name        => 'AutoreplyToRequestors',               # loc
+       Description =>
+'Always sends a message to the requestors independent of message sender'
+       ,                                                     # loc
+       ExecModule => 'Autoreply',
+       Argument   => 'Requestor' },
+    { Name        => 'Notify Requestors',                    # loc
+      Description => 'Sends a message to the requestors',    # loc
+      ExecModule  => 'Notify',
+      Argument    => 'Requestor' },
+    { Name        => 'Notify Owner as Comment',              # loc
+      Description => 'Sends mail to the owner',              # loc
+      ExecModule  => 'NotifyAsComment',
+      Argument    => 'Owner' },
+    { Name        => 'Notify Owner',                         # loc
+      Description => 'Sends mail to the owner',              # loc
+      ExecModule  => 'Notify',
+      Argument    => 'Owner' },
+    { Name        => 'Notify AdminCcs as Comment',                        # loc
+      Description => 'Sends mail to the administrative Ccs as a comment', # loc
+      ExecModule  => 'NotifyAsComment',
+      Argument    => 'AdminCc' },
+    { Name        => 'Notify AdminCcs',                                   # loc
+      Description => 'Sends mail to the administrative Ccs',              # loc
+      ExecModule  => 'Notify',
+      Argument    => 'AdminCc' },
+
+    { Name        => 'Notify Requestors and Ccs as Comment',              # loc
+      Description => 'Send mail to requestors and Ccs as a comment',      # loc
+      ExecModule  => 'NotifyAsComment',
+      Argument    => 'Requestor,Cc' },
+
+    { Name        => 'Notify Requestors and Ccs',                         # loc
+      Description => 'Send mail to requestors and Ccs',                   # loc
+      ExecModule  => 'Notify',
+      Argument    => 'Requestor,Cc' },
+
+    { Name        => 'Notify Requestors, Ccs and AdminCcs as Comment',    # loc
+      Description => 'Send mail to all watchers as a "comment"',          # loc
+      ExecModule  => 'NotifyAsComment',
+      Argument    => 'All' },
+    { Name        => 'Notify Requestors, Ccs and AdminCcs',               # loc
+      Description => 'Send mail to all watchers',                         # loc
+      ExecModule  => 'Notify',
+      Argument    => 'All' },
+    { Name        => 'Notify Other Recipients as Comment',                # loc
+      Description => 'Sends mail to explicitly listed Ccs and Bccs',      # loc
+      ExecModule  => 'NotifyAsComment',
+      Argument    => 'OtherRecipients' },
+    { Name        => 'Notify Other Recipients',                           # loc
+      Description => 'Sends mail to explicitly listed Ccs and Bccs',      # loc
+      ExecModule  => 'Notify',
+      Argument    => 'OtherRecipients' },
+    { Name        => 'User Defined',                                      # loc
+      Description => 'Perform a user-defined action',                     # loc
+      ExecModule  => 'UserDefined', },
+    {  Name        => 'Create Tickets',                                    # loc
+       Description =>
+         'Create new tickets based on this scrip\'s template',             # loc
+       ExecModule => 'CreateTickets', }, );
+
+my @ScripConditions = (
+    { Name                 => 'On Create',                                # loc
+      Description          => 'When a ticket is created',                 # loc
+      ApplicableTransTypes => 'Create',
+      ExecModule           => 'AnyTransaction', },
+
+    { Name                 => 'On Transaction',                           # loc
+      Description          => 'When anything happens',                    # loc
+      ApplicableTransTypes => 'Any',
+      ExecModule           => 'AnyTransaction', },
+    {
+
+      Name                 => 'On Correspond',                             # loc
+      Description          => 'Whenever correspondence comes in',          # loc
+      ApplicableTransTypes => 'Correspond',
+      ExecModule           => 'AnyTransaction', },
+
+    {
+
+      Name                 => 'On Comment',                                # loc
+      Description          => 'Whenever comments come in',                 # loc
+      ApplicableTransTypes => 'Comment',
+      ExecModule           => 'AnyTransaction' },
+    {
+
+      Name                 => 'On Status Change',                          # loc
+      Description          => 'Whenever a ticket\'s status changes',       # loc
+      ApplicableTransTypes => 'Status',
+      ExecModule           => 'AnyTransaction',
+
+    },
+    {
+
+      Name                 => 'On Owner Change',                           # loc
+      Description          => 'Whenever a ticket\'s owner changes',        # loc
+      ApplicableTransTypes => 'Set',
+      ExecModule           => 'OwnerChange',
+
+    },
+    {
+
+      Name                 => 'On Queue Change',                           # loc
+      Description          => 'Whenever a ticket\'s queue changes',        # loc
+      ApplicableTransTypes => 'Set',
+      ExecModule           => 'QueueChange',
+
+    },
+    {  Name                 => 'On Resolve',                               # loc
+       Description          => 'Whenever a ticket is resolved',            # loc
+       ApplicableTransTypes => 'Status',
+       ExecModule           => 'StatusChange',
+       Argument             => 'resolved'
+
+    },
+
+    {  Name                 => 'User Defined',                             # loc
+       Description          => 'Whenever a user-defined condition occurs', # loc
+       ApplicableTransTypes => 'Any',
+       ExecModule           => 'UserDefined'
+
+    }, );
+
+my @templates = (
+    { Queue       => '0',
+      Name        => 'Blank',                                             # loc
+      Description => 'A blank template',                                  # loc
+      Content     => '', },
+    {  Queue       => '0',
+       Name        => 'Autoreply',                                         # loc
+       Description => 'Default Autoresponse Template',                     # loc
+       Content     => 'Subject: AutoReply: {$Ticket->Subject}
+
+
+Greetings,
+
+This message has been automatically generated in response to the
+creation of a trouble ticket regarding:
+	"{$Ticket->Subject()}", 
+a summary of which appears below.
+
+There is no need to reply to this message right now.  Your ticket has been
+assigned an ID of [{$rtname} #{$Ticket->id()}].
+
+Please include the string:
+
+         [{$rtname} #{$Ticket->id}]
+
+in the subject line of all future correspondence about this issue. To do so, 
+you may reply to this message.
+
+                        Thank you,
+                        {$Ticket->QueueObj->CorrespondAddress()}
+
+-------------------------------------------------------------------------
+{$Transaction->Content()}
+'
+    },
+
+    {  Queue       => '0',
+       Name        => 'Transaction',                     # loc
+       Description => 'Default transaction template',    # loc
+       Content     => '
+
+
+{$Transaction->CreatedAsString}: Request {$Ticket->id} was acted upon.
+Transaction: {$Transaction->Description}
+       Queue: {$Ticket->QueueObj->Name}
+     Subject: {$Transaction->Subject || $Ticket->Subject || "(No subject given)"}
+       Owner: {$Ticket->OwnerObj->Name}
+  Requestors: {$Ticket->RequestorAddresses}
+      Status: {$Ticket->Status}
+ Ticket <URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >
+-------------------------------------------------------------------------
+{$Transaction->Content()}'
+    },
+
+    {
+
+      Queue       => '0',
+      Name        => 'AdminCorrespondence',                      # loc
+      Description => 'Default admin correspondence template',    # loc
+      Content     => '
+
+
+<URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >
+
+{$Transaction->Content()}'
+    },
+
+    {  Queue       => '0',
+       Name        => 'Correspondence',                          # loc
+       Description => 'Default correspondence template',         # loc
+       Content     => '
+
+{$Transaction->Content()}'
+    },
+
+    {  Queue       => '0',
+       Name        => 'AdminComment',                            # loc
+       Description => 'Default admin comment template',          # loc
+       Content     =>
+'Subject: [Comment] {my $s=($Transaction->Subject||$Ticket->Subject); $s =~ s/\\[Comment\\]//g; $comment =~ s/^Re//i; $s;}
+
+
+{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
+This is a comment.  It is not sent to the Requestor(s):
+
+{$Transaction->Content()}
+'
+    },
+
+    {  Queue       => '0',
+       Name        => 'StatusChange',                                      # loc
+       Description => 'Ticket status changed',                             # loc
+       Content     => 'Subject: Status Changed to: {$Transaction->NewValue}
+
+
+{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
+
+{$Transaction->Content()}
+'
+    },
+
+    {
+
+      Queue       => '0',
+      Name        => 'Resolved',                 # loc
+      Description => 'Ticket Resolved',          # loc
+      Content     => 'Subject: Ticket Resolved
+
+According to our records, your request has been resolved. If you have any
+further questions or concerns, please respond to this message.
+'
+    } );
+
+my @acl = (
+    { UserId => 'Nobody',                       # - principalId
+      Right  => 'OwnTicket', },
+
+    { UserId => 'root',                         # - principalid
+      Right  => 'SuperUser', },
+
+);
diff -urN rt-2-1-54-orig/sbin/initdb rt-2-1-54/sbin/initdb
--- rt-2-1-54-orig/sbin/initdb	2002-12-03 11:05:58.000000000 +1000
+++ rt-2-1-54/sbin/initdb	2002-12-23 12:00:34.000000000 +1000
@@ -53,7 +53,7 @@
 
 GetOptions (\%args, 
 		 'prompt-for-dba-password','force', 'debug',
-		'action=s', 'dba=s', 'dba-password=s'
+		'action=s', 'dba=s', 'dba-password=s', 'datafile=s'
 
 );
 
@@ -318,316 +318,15 @@
                              ObjectType    => 'RT::System',
                              ObjectId      => '1' );
 
-my @users = (
-    {  Name     => 'Nobody',
-       RealName => 'Nobody in particular',
-       Comments => 'Do not delete or modify this user. It is integral '
-         . 'to RT\'s internal data structures',
-       Privileged => '0', },
-
-    {  Name         => 'root',
-       Gecos        => 'root',
-       RealName     => 'Enoch Root',
-       Password     => 'password',
-       EmailAddress => "root\@localhost",
-       Comments     => 'SuperUser',
-       Privileged   => '1', } );
-
-my @groups = (
-    { Name        => '',
-      Type        => 'Everyone',                        # loc
-      Domain      => 'SystemInternal',
-      Instance    => '',
-      Description => 'Pseudogroup for internal use',    # loc
-    },
-    { Type        => 'Privileged',                      # loc
-      Domain      => 'SystemInternal',
-      Instance    => '',
-      Name        => '',
-      Description => 'Pseudogroup for internal use',    # loc
-    },
-    { Name        => '',
-      Type        => 'Unprivileged',                    # loc
-      Domain      => 'SystemInternal',
-      Instance    => '',
-      Description => 'Pseudogroup for internal use',    # loc
-    },
-    { Name        => '',
-      Type        => 'Owner',                               # loc
-      Domain      => 'RT::System-Role',
-      Instance    => '',
-      Description => 'SystemRolegroup for internal use',    # loc
-    },
-    { Name        => '',
-      Type        => 'Requestor',                           # loc
-      Domain      => 'RT::System-Role',
-      Instance    => '',
-      Description => 'SystemRolegroup for internal use',    # loc
-    },
-    { Name        => '',
-      Type        => 'Cc',                                  # loc
-      Domain      => 'RT::System-Role',
-      Instance    => '',
-      Description => 'SystemRolegroup for internal use',    # loc
-    },
-    { Name        => '',
-      Type        => 'AdminCc',                             # loc
-      Domain      => 'RT::System-Role',
-      Instance    => '',
-      Description => 'Pseudogroup for internal use',        # loc
-    }, );
-
-my @queues = ( {  Name              => 'General',
-                  Description       => 'The default queue',
-                  CorrespondAddress => "",
-                  CommentAddress    => "", }, );
-
-my @ScripActions = (
-
-    {  Name        => 'AutoreplyToRequestors',               # loc
-       Description =>
-'Always sends a message to the requestors independent of message sender'
-       ,                                                     # loc
-       ExecModule => 'Autoreply',
-       Argument   => 'Requestor' },
-    { Name        => 'Notify Requestors',                    # loc
-      Description => 'Sends a message to the requestors',    # loc
-      ExecModule  => 'Notify',
-      Argument    => 'Requestor' },
-    { Name        => 'Notify Owner as Comment',              # loc
-      Description => 'Sends mail to the owner',              # loc
-      ExecModule  => 'NotifyAsComment',
-      Argument    => 'Owner' },
-    { Name        => 'Notify Owner',                         # loc
-      Description => 'Sends mail to the owner',              # loc
-      ExecModule  => 'Notify',
-      Argument    => 'Owner' },
-    { Name        => 'Notify AdminCcs as Comment',                        # loc
-      Description => 'Sends mail to the administrative Ccs as a comment', # loc
-      ExecModule  => 'NotifyAsComment',
-      Argument    => 'AdminCc' },
-    { Name        => 'Notify AdminCcs',                                   # loc
-      Description => 'Sends mail to the administrative Ccs',              # loc
-      ExecModule  => 'Notify',
-      Argument    => 'AdminCc' },
-
-    { Name        => 'Notify Requestors and Ccs as Comment',              # loc
-      Description => 'Send mail to requestors and Ccs as a comment',      # loc
-      ExecModule  => 'NotifyAsComment',
-      Argument    => 'Requestor,Cc' },
-
-    { Name        => 'Notify Requestors and Ccs',                         # loc
-      Description => 'Send mail to requestors and Ccs',                   # loc
-      ExecModule  => 'Notify',
-      Argument    => 'Requestor,Cc' },
-
-    { Name        => 'Notify Requestors, Ccs and AdminCcs as Comment',    # loc
-      Description => 'Send mail to all watchers as a "comment"',          # loc
-      ExecModule  => 'NotifyAsComment',
-      Argument    => 'All' },
-    { Name        => 'Notify Requestors, Ccs and AdminCcs',               # loc
-      Description => 'Send mail to all watchers',                         # loc
-      ExecModule  => 'Notify',
-      Argument    => 'All' },
-    { Name        => 'Notify Other Recipients as Comment',                # loc
-      Description => 'Sends mail to explicitly listed Ccs and Bccs',      # loc
-      ExecModule  => 'NotifyAsComment',
-      Argument    => 'OtherRecipients' },
-    { Name        => 'Notify Other Recipients',                           # loc
-      Description => 'Sends mail to explicitly listed Ccs and Bccs',      # loc
-      ExecModule  => 'Notify',
-      Argument    => 'OtherRecipients' },
-    { Name        => 'User Defined',                                      # loc
-      Description => 'Perform a user-defined action',                     # loc
-      ExecModule  => 'UserDefined', },
-    {  Name        => 'Create Tickets',                                    # loc
-       Description =>
-         'Create new tickets based on this scrip\'s template',             # loc
-       ExecModule => 'CreateTickets', }, );
-
-my @ScripConditions = (
-    { Name                 => 'On Create',                                # loc
-      Description          => 'When a ticket is created',                 # loc
-      ApplicableTransTypes => 'Create',
-      ExecModule           => 'AnyTransaction', },
-
-    { Name                 => 'On Transaction',                           # loc
-      Description          => 'When anything happens',                    # loc
-      ApplicableTransTypes => 'Any',
-      ExecModule           => 'AnyTransaction', },
-    {
-
-      Name                 => 'On Correspond',                             # loc
-      Description          => 'Whenever correspondence comes in',          # loc
-      ApplicableTransTypes => 'Correspond',
-      ExecModule           => 'AnyTransaction', },
-
-    {
-
-      Name                 => 'On Comment',                                # loc
-      Description          => 'Whenever comments come in',                 # loc
-      ApplicableTransTypes => 'Comment',
-      ExecModule           => 'AnyTransaction' },
-    {
-
-      Name                 => 'On Status Change',                          # loc
-      Description          => 'Whenever a ticket\'s status changes',       # loc
-      ApplicableTransTypes => 'Status',
-      ExecModule           => 'AnyTransaction',
-
-    },
-    {
-
-      Name                 => 'On Owner Change',                           # loc
-      Description          => 'Whenever a ticket\'s owner changes',        # loc
-      ApplicableTransTypes => 'Set',
-      ExecModule           => 'OwnerChange',
-
-    },
-    {
-
-      Name                 => 'On Queue Change',                           # loc
-      Description          => 'Whenever a ticket\'s queue changes',        # loc
-      ApplicableTransTypes => 'Set',
-      ExecModule           => 'QueueChange',
-
-    },
-    {  Name                 => 'On Resolve',                               # loc
-       Description          => 'Whenever a ticket is resolved',            # loc
-       ApplicableTransTypes => 'Status',
-       ExecModule           => 'StatusChange',
-       Argument             => 'resolved'
-
-    },
-
-    {  Name                 => 'User Defined',                             # loc
-       Description          => 'Whenever a user-defined condition occurs', # loc
-       ApplicableTransTypes => 'Any',
-       ExecModule           => 'UserDefined'
-
-    }, );
-
-my @templates = (
-    { Queue       => '0',
-      Name        => 'Blank',                                             # loc
-      Description => 'A blank template',                                  # loc
-      Content     => '', },
-    {  Queue       => '0',
-       Name        => 'Autoreply',                                         # loc
-       Description => 'Default Autoresponse Template',                     # loc
-       Content     => 'Subject: AutoReply: {$Ticket->Subject}
-
-
-Greetings,
-
-This message has been automatically generated in response to the
-creation of a trouble ticket regarding:
-	"{$Ticket->Subject()}", 
-a summary of which appears below.
-
-There is no need to reply to this message right now.  Your ticket has been
-assigned an ID of [{$rtname} #{$Ticket->id()}].
-
-Please include the string:
-
-         [{$rtname} #{$Ticket->id}]
-
-in the subject line of all future correspondence about this issue. To do so, 
-you may reply to this message.
-
-                        Thank you,
-                        {$Ticket->QueueObj->CorrespondAddress()}
-
--------------------------------------------------------------------------
-{$Transaction->Content()}
-'
-    },
-
-    {  Queue       => '0',
-       Name        => 'Transaction',                     # loc
-       Description => 'Default transaction template',    # loc
-       Content     => '
-
-
-{$Transaction->CreatedAsString}: Request {$Ticket->id} was acted upon.
-Transaction: {$Transaction->Description}
-       Queue: {$Ticket->QueueObj->Name}
-     Subject: {$Transaction->Subject || $Ticket->Subject || "(No subject given)"}
-       Owner: {$Ticket->OwnerObj->Name}
-  Requestors: {$Ticket->RequestorAddresses}
-      Status: {$Ticket->Status}
- Ticket <URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >
--------------------------------------------------------------------------
-{$Transaction->Content()}'
-    },
-
-    {
-
-      Queue       => '0',
-      Name        => 'AdminCorrespondence',                      # loc
-      Description => 'Default admin correspondence template',    # loc
-      Content     => '
-
-
-<URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >
-
-{$Transaction->Content()}'
-    },
-
-    {  Queue       => '0',
-       Name        => 'Correspondence',                          # loc
-       Description => 'Default correspondence template',         # loc
-       Content     => '
-
-{$Transaction->Content()}'
-    },
-
-    {  Queue       => '0',
-       Name        => 'AdminComment',                            # loc
-       Description => 'Default admin comment template',          # loc
-       Content     =>
-'Subject: [Comment] {my $s=($Transaction->Subject||$Ticket->Subject); $s =~ s/\\[Comment\\]//g; $comment =~ s/^Re//i; $s;}
-
-
-{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
-This is a comment.  It is not sent to the Requestor(s):
-
-{$Transaction->Content()}
-'
-    },
-
-    {  Queue       => '0',
-       Name        => 'StatusChange',                                      # loc
-       Description => 'Ticket status changed',                             # loc
-       Content     => 'Subject: Status Changed to: {$Transaction->NewValue}
-
-
-{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
-
-{$Transaction->Content()}
-'
-    },
-
-    {
-
-      Queue       => '0',
-      Name        => 'Resolved',                 # loc
-      Description => 'Ticket Resolved',          # loc
-      Content     => 'Subject: Ticket Resolved
-
-According to our records, your request has been resolved. If you have any
-further questions or concerns, please respond to this message.
-'
-    } );
-
-my @acl = (
-    { UserId => 'Nobody',                       # - principalId
-      Right  => 'OwnTicket', },
+# Slurp in stuff to insert from the datafile. Possible things to go in here:-
+# @groups, @users, @acl, @queues, @ScripActions, @ScripConditions, @templates
 
-    { UserId => 'root',                         # - principalid
-      Right  => 'SuperUser', },
+if (!$args{'datafile'}) {
+	$args{'datafile'} = $RT::EtcPath . "/initialdata";
+}
 
-);
+do $args{'datafile'}
+          || die "Couldn't find initial data for import\n" . $@;
 
 print "Creating groups...";
 foreach $item (@groups) {


More information about the Rt-devel mailing list