remove rt from monitor package.
[monitor.git] / rt3 / monitor-rt3.init
index ee1020a..0e24a11 100644 (file)
@@ -54,6 +54,11 @@ function check_rt_siteconfig ()
 {
        tmp_siteconfig=$(mktemp)
        tmp_initialdata=$(mktemp)
+
+       # TODO: need a better approach for this.
+       for f in $MONITORPATH/rt3/rtconf.d/*.pl ; do 
+               update_config PLC_RT_HOSTNAME $PLC_RT_HOST $f
+       done
        
        # if the templates are newer than the actual config, then replace them.
        if [ $MONITORPATH/rt3/RT_SiteConfig.pm -nt /etc/rt3/RT_SiteConfig.pm ] ;
@@ -65,6 +70,7 @@ function check_rt_siteconfig ()
                # setup RT_SiteConfig.pm
                update_config PLC_NAME "$PLC_NAME" $tmp_siteconfig
                update_config PLC_RT_HOSTNAME $PLC_RT_HOST $tmp_siteconfig
+               update_config PLC_WWW_HOSTNAME $PLC_WWW_HOST $tmp_siteconfig
 
                update_config RT_DB_NAME $RT3_DB_NAME $tmp_siteconfig
                update_config RT_DB_USER $RT3_DB_USER $tmp_siteconfig
@@ -84,6 +90,11 @@ function check_rt_siteconfig ()
        fi
 }
 
+function check_rt_custom ()
+{
+       rsync -qv -az $MONITORPATH/rt3/local/html /usr/share/rt3
+}
+
 function check_rt_pghba ()
 {
        NAME=$RT3_DB_NAME
@@ -122,46 +133,18 @@ function check_rt_init ()
 {
        if [ ! -f /etc/rt3/setup.finished ] ; then
                /usr/sbin/rt-setup-database --action init --dba postgres
-               for f in $MONITORPATH/rt3/rtinit.d/*.pl ; do 
+               for f in $MONITORPATH/rt3/rtconf.d/*.pl ; do 
                        /usr/sbin/rt-setup-database --action insert --dba postgres --datafile $f
                done
-               touch /etc/rt3/setup.finished
 
-       ###Last DB adjustments
-       #set defaultduein to 1 for support queue
-       cat <<EOF | /usr/bin/psql -U postgres -d $RT3_DB_NAME
-UPDATE queues SET defaultduein = 1 WHERE name='support'
-EOF
+               # run initial setup scripts (run only once, or for the first time)
+               for f in $MONITORPATH/rt3/rtsetup.d/*.{pl,py,sh} ; do 
+                       $f
+               done
 
-       #alter acl for Everyone be able to create new tickets in support list
-       #Everyone (groups.id == 3) on support (queues.id == 1 (based on order in initialdata))
-       cat <<EOF | /usr/bin/psql -U postgres -d $RT3_DB_NAME
-INSERT INTO acl (principaltype,principalid,rightname,objecttype,objectid,delegatedby,delegatedfrom) VALUES ('Group',3,'CreateTicket','RT::Queue',1,0,0);
-INSERT INTO acl (principaltype,principalid,rightname,objecttype,objectid,delegatedby,delegatedfrom) VALUES ('Group',3,'ReplyToTicket','RT::Queue',1,0,0);
-EOF
-       #Everyone (groups.id == 3) on monitor ( queues.id == 2 (based on order in initaldata))
-       cat <<EOF | /usr/bin/psql -U postgres -d $RT3_DB_NAME
-INSERT INTO acl (principaltype,principalid,rightname,objecttype,objectid,delegatedby,delegatedfrom) VALUES ('Group',3,'CreateTicket','RT::Queue',2,0,0);
-INSERT INTO acl (principaltype,principalid,rightname,objecttype,objectid,delegatedby,delegatedfrom) VALUES ('Group',3,'ReplyToTicket','RT::Queue',2,0,0);
-EOF
-       #setup custom field values
-       cat <<EOF | /usr/bin/psql -U postgres -d $RT3_DB_NAME
-INSERT INTO objectcustomfields (customfield, objectid, sortorder, creator, lastupdatedby) VALUES (1,1,1,12,12);
-INSERT INTO customfields (name, "type", maxvalues, repeated, pattern, lookuptype, description, sortorder, creator, lastupdatedby,disabled) VALUES ('Problem Category', 'Select',1,0,'(?#Mandatory).','RT::Queue-RT::Ticket','How severe this problem is',0,12,12,0);
-EOF
-       cat <<EOF | /usr/bin/psql -U postgres -d $RT3_DB_NAME
-INSERT INTO customfieldvalues (customfield, name, sortorder, creator, lastupdatedby) VALUES (1,'Critical',0,12,12);
-INSERT INTO customfieldvalues (customfield, name, sortorder, creator, lastupdatedby) VALUES (1,'Major',1,12,12);
-INSERT INTO customfieldvalues (customfield, name, sortorder, creator, lastupdatedby) VALUES (1,'Minor',2,12,12);
-INSERT INTO customfieldvalues (customfield, name, sortorder, creator, lastupdatedby) VALUES (1,'Trivial',3,12,12);
-EOF
-       # give permissions to users to set this field.
-       cat <<EOF | /usr/bin/psql -U postgres -d $RT3_DB_NAME
-INSERT INTO acl (principaltype,principalid,rightname,objecttype,objectid,delegatedby,delegatedfrom) VALUES ('Group',3,'ModifyCustomField','RT::CustomField',1,0,0);
-INSERT INTO acl (principaltype,principalid,rightname,objecttype,objectid,delegatedby,delegatedfrom) VALUES ('Group',3,'SeeCustomField','RT::CustomField',1,0,0);
-EOF
-       fi
+               touch /etc/rt3/setup.finished
 
+       fi
 }
 
 check_rt_sendmail ()
@@ -222,6 +205,7 @@ case "$1" in
                check_rt_aliases
                check_rt_init
                check_rt_sendmail
+               check_rt_custom         # todo: restart httpd if needed.
 
                result "$MESSAGE"
        ;;