#!/usr/bin/perl -w # package RT; use strict; use vars qw($VERSION $Handle $Nobody $SystemUser $item); use lib "!!CHANGE ME TO YOUR RT LIB DIRECTORY!!"; use lib "!!CHANGE ME TO YOUR RT ETC DIRECTORY!!"; #This drags in RT's config.pm use config; use Carp; use RT::Handle; use RT::User; use RT::CurrentUser; #connect to the db $RT::Handle = new RT::Handle($RT::DatabaseType); $RT::Handle->Connect(); #Put together a current user object so we can create a User object my $CurrentUser = new RT::CurrentUser(); #now that we bootstrapped that little bit, we can use the standard RT cli # helpers to do what we need use RT::Interface::CLI qw(CleanEnv LoadConfig DBConnect GetCurrentUser GetMessageContent); #Clean out all the nasties from the environment CleanEnv(); #Load etc/config.pm and drop privs LoadConfig(); #Connect to the database and get RT::SystemUser and RT::Nobody loaded DBConnect(); $CurrentUser->LoadByName('RT_System'); # {{{ ScripActions my @ScripActions = ( { Name => 'AutoAssign', Description => 'Automatically assigns a ticket to a permitted user if they are the first reply', ExecModule => 'AutoAssign', Argument => '', }, ); # }}} print "Creating ScripActions..."; use RT::ScripAction; for $item (@ScripActions) { my $new_entry = new RT::ScripAction($CurrentUser); my $return = $new_entry->Create(%$item); print $return."."; } print "done.\n"; $RT::Handle->Disconnect(); 1;