update for new config file syntax, new adminsuidsetup
[freeside.git] / bin / fs-setup
index 22891ec..4e64f1b 100755 (executable)
 # ivan@sisd.com 98-sep-4
 #
 # fix radius attributes ivan@sisd.com 98-sep-27
+#
+# $Log: fs-setup,v $
+# Revision 1.5  1998-11-15 09:43:03  ivan
+# update for new config file syntax, new adminsuidsetup
+#
+# Revision 1.4  1998/10/22 15:51:23  ivan
+# also varchar with no length specified - postgresql fix broke mysql.
+#
+# Revision 1.3  1998/10/22 15:46:28  ivan
+# now smallint is illegal, so remove that too.
+#
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -41,8 +52,11 @@ use FS::UID qw(adminsuidsetup datasrc);
 use FS::Record;
 use FS::cust_main_county;
 
+my $user = shift or die &usage;
+FS::UID::getsecrets $user;
+
 #needs to match FS::Record
-my($dbdef_file) = "/var/spool/freeside/dbdef.". datasrc;
+my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc;
 
 ###
 
@@ -68,7 +82,7 @@ my($char_d) = 80; #default maxlength for text fields
 
 #my(@date_type)  = ( 'timestamp', '', ''     );
 my(@date_type)  = ( 'int', 'NULL', ''     );
-my(@perl_type) = ( 'varchar', 'NULL', ''   ); 
+my(@perl_type) = ( 'varchar', 'NULL', 255  ); 
 my(@money_type);
 if (datasrc =~ m/Pg/) { #Pg can't do decimal(10,2)
   @money_type = ( 'money',   '', '' );
@@ -143,13 +157,14 @@ foreach (qw(svc_acct svc_acct_sm svc_domain)) {
 
 #important
 $dbdef->save($dbdef_file);
-FS::Record::reload_dbdef;
+FS::Record::reload_dbdef($dbdef_file);
 
 ###
 # create 'em
 ###
 
-my($dbh)=adminsuidsetup;
+my($dbh)=adminsuidsetup $user;
+warn $dbh;
 
 #create tables
 $|=1;
@@ -190,6 +205,10 @@ SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP
 
 $dbh->disconnect or die $dbh->errstr;
 
+sub usage {
+  die "Usage:\n  fs-setup user\n"; 
+}
+
 ###
 # Now it becomes an object.  much better.
 ###
@@ -206,7 +225,7 @@ sub tables_hash_hack {
         'agentnum', 'int',            '',     '',
         'agent',    'varchar',           '',     $char_d,
         'typenum',  'int',            '',     '',
-        'freq',     'smallint',       'NULL', '',
+        'freq',     'int',       'NULL', '',
         'prog',     @perl_type,
       ],
       'primary_key' => 'agentnum',
@@ -415,7 +434,7 @@ sub tables_hash_hack {
         'pkg',        'varchar',   '',   $char_d,
         'comment',    'varchar',   '',   $char_d,
         'setup',      @perl_type,
-        'freq',       'smallint', '', '',  #billing frequency (months)
+        'freq',       'int', '', '',  #billing frequency (months)
         'recur',      @perl_type,
       ],
       'primary_key' => 'pkgpart',