0216615da5230241adc64bd7c08d8bdabcada1ed
[freeside.git] / FS / FS / InitHandler.pm
1 package FS::InitHandler;
2
3 # this leaks memory under graceful restarts and i wouldn't use it on any
4 # modern server.  useful for very slow machines with memory to spare, just
5 # always do a full restart
6
7 use strict;
8 use vars qw($DEBUG);
9 use FS::UID qw(adminsuidsetup);
10 use FS::Record;
11
12 $DEBUG = 1;
13
14 sub handler {
15
16   use Date::Format;
17   use Date::Parse;
18   use Tie::IxHash;
19   use HTML::Entities;
20   use IO::Handle;
21   use IO::File;
22   use String::Approx;
23   use HTML::Widgets::SelectLayers 0.02;
24   #use FS::UID;
25   #use FS::Record;
26   use FS::Conf;
27   use FS::CGI;
28   use FS::Msgcat;
29   
30   use FS::agent;
31   use FS::agent_type;
32   use FS::domain_record;
33   use FS::cust_bill;
34   use FS::cust_bill_pay;
35   use FS::cust_credit;
36   use FS::cust_credit_bill;
37   use FS::cust_main;
38   use FS::cust_main_county;
39   use FS::cust_pay;
40   use FS::cust_pkg;
41   use FS::cust_refund;
42   use FS::cust_svc;
43   use FS::nas;
44   use FS::part_bill_event;
45   use FS::part_pkg;
46   use FS::part_referral;
47   use FS::part_svc;
48   use FS::pkg_svc;
49   use FS::port;
50   use FS::queue;
51   use FS::raddb;
52   use FS::session;
53   use FS::svc_acct;
54   use FS::svc_acct_pop;
55   use FS::svc_acct_sm;
56   use FS::svc_domain;
57   use FS::svc_forward;
58   use FS::svc_www;
59   use FS::type_pkgs;
60   use FS::part_export;
61   use FS::part_export_option;
62   use FS::export_svc;
63   use FS::msgcat;
64
65   warn "[FS::InitHandler] handler called\n" if $DEBUG;
66
67   #this is sure to be broken on freebsd
68   $> = $FS::UID::freeside_uid;
69
70   open(MAPSECRETS,"<$FS::UID::conf_dir/mapsecrets")
71     or die "can't read $FS::UID::conf_dir/mapsecrets: $!";
72
73   my %seen;
74   while (<MAPSECRETS>) {
75     next if /^\s*(#|$)/;
76     /^([\w\-\.]+)\s(.*)$/
77       or do { warn "strange line in mapsecrets: $_"; next; };
78     my($user, $datasrc) = ($1, $2);
79     next if $seen{$datasrc}++;
80     warn "[FS::InitHandler] preloading $datasrc for $user\n" if $DEBUG;
81     adminsuidsetup($user);
82   }
83
84   close MAPSECRETS;
85
86   #lalala probably broken on freebsd
87   ($<, $>) = ($>, $<);
88   $< = 0;
89
90 }
91
92 1;