App-LedgerSMB-Admin

 view release on metacpan or  search on metacpan

bin/lsmb_createdb  view on Meta::CPAN

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
The following options are supported:
 
   --help                   Print this message and exit
   --host hostname          Database Host
   --path /example/path     Path to LedgerSMB installation (required)
   --chart us/chart/General Chart of Accounts path (relative to sql)
   --gifi  ca/gifi/General  Path to GIFI
   --port 5432              Database Port
   --dbname database        Create db with the following name (required)
   --username postgres      Database Superuser to Log In As
   --prompt-password        Prompt for Password (can use PGPASSWORD instead)
|;
 
my ($all, $help, $host, $port, $path, $dbname, $username, $promptpasswd,
  $chart, $gifi);
 
GetOptions('all'               => \$all,
           'help'              => \$help,
           'chart=s'           => \$chart,
           'gifi=s'            => \$gifi,
           'host=s'            => \$host,
           'port=s'            => \$port,
           'username=s'        => \$username,
           'prompt-password'   => \$promptpasswd,
           'path=s'            => \$path,
           'dbname=s'          => \$dbname
);
 
if ($help or !$dbname){
   print $helpmsg;
   exit 0;
}
 
my $passwd;

bin/lsmb_createdb  view on Meta::CPAN

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
App::LedgerSMB::Admin->add_paths($major => $path);
close LSMB;
 
 
## set up db connection
 
my $db = App::LedgerSMB::Admin::Database->new(
   host     => $host,
   port     => $port,
   username => $username,
   password => $password,
   dbname   => $dbname,
);
 
## do the actual work
 
$db->create;
$db->load($major);
$chart =~ s/\.sql$// if $chart;
$gifi =~ s/\.sql$// if $gifi ;
$db->run_file("$path/sql/$chart.sql") if $chart;

bin/lsmb_reload  view on Meta::CPAN

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
   --all                    Reload All Databases
   --help                   Print this message and exit
   --host hostname          Database Host
   --path13 /example/path   Path to LedgerSMB 1.3 installation
   --path14 /example/path2  Path to LedgerSMB 1.4 installation
   --path15 /example/path2  Path to LedgerSMB 1.5 installation
   --port 5432              Database Port
   --dbname database        Reload the specified db, overridden by --all
   --username postgres      Database Superuser to Log In As
   --prompt-password        Prompt for Password (can use PGPASSWORD instead)
|;
 
my ($all, $help, $host, $port, $path13, $path14, $dbname,
    $username, $promptpasswd);
 
GetOptions('all'               => \$all,
           'help'              => \$help,
           'host=s'            => \$host,
           'port=s'            => \$port,
           'username=s'        => \$username,
           'prompt-password'   => \$promptpasswd,
           'path13=s'          => \$path13,
           'path14=s'          => \$path14,
           'path15=s'          => \$path15,
           'dbname=s'          => \$dbname
);
 
if ($help){
   print $helpmsg;
   exit 0;
}

bin/lsmb_reload  view on Meta::CPAN

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
   $lsmbversion->{1.5} = $1;
   warn $lsmbversion->{1.5};
   close LSMB;
}
## set up db connection
 
my $db = App::LedgerSMB::Admin::Database->new(
   host     => $host,
   port     => $port,
   username => $username,
   password => $password,
   dbname   => $dbname,
);
 
## do the actual work
 
if ($all){
  for my $dbhame ($db->list_dbs){
     my $working_db = $db->new($db->export, dbname => $dbname);
     do_reload($working_db) if eval { $working_db->major_version };
  }

lib/App/LedgerSMB/Admin.pm  view on Meta::CPAN

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
The following options are supported:
 
   --all                    Reload All Databases
   --help                   Print this message and exit
   --host hostname          Database Host
   --path13 /example/path   Path to LedgerSMB 1.3 installation
   --path14 /example/path2  Path to LedgerSMB 1.4 installation
   --port 5432              Database Poart
   --dbname database        Reload the specified db, overridden by --all
   --username postgres      Database Superuser to Log In As
   --prompt-password        Prompt for Password (can use PGPASSWORD instead)
 
 
=head2 lsmb_createdb
 
Due to improper errors, this currently does not work properly with LedgerSMB
1.3.  It is expected that it will following the LedgerSMB 1.3.45 release
(forthcoming).
 
The lsmb_reload application provides a command line tool for upgrading or
rebuilding stored procedures and permissions of a LedgerSMB 1.3 or 1.4 database.
 
   --help                   Print this message and exit
   --host hostname          Database Host
   --path /example/path     Path to LedgerSMB installation (required)
   --chart us/chart/General Chart of Accounts path (relative to sql)
   --gifi  ca/gifi/General  Path to GIFI
   --port 5432              Database Poart
   --dbname database        Create db with the following name (required)
   --username postgres      Database Superuser to Log In As
   --prompt-password        Prompt for Password (can use PGPASSWORD instead)
 
=head1 Bundled Libraries
 
=head2 App::LedgerSMB::Admin
 
Provides base version tracking and management routines
 
=head2 App::LedgerSMB::Admin::Database
 
Routines to reload, create, update, backup, and restore databases

lib/App/LedgerSMB/Admin/Database.pm  view on Meta::CPAN

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Upgrading to 1.4 from 1.3, after updating 1.3 instance to latest:
 
  App::LedgerSMB::Admin->add_paths(
     '1.3' => '/usr/local/ledgersmb_1.3',
     '1.4' => '/usr/local/ledgersmb_1.4',
  ); # setting the version paths
  my $db = App::LedgerSMB::Admin::Database->new(
     username  => 'postgres',
     password  => 'secretpassword',
     host      => 'localhost',
     port      => '5432',
     dbname    => 'mycompany',
  );
  if ($db->major_version eq '1.3') {
      $db->reload;
      $db->upgrade_to('1.4');
  }
 
=head1 VERSION

lib/App/LedgerSMB/Admin/Database.pm  view on Meta::CPAN

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
=cut
 
our $VERSION=0.04;
 
=head1 PROPERTIES INHERITED FROM PGObject::Util::DBAdmin
 
Please see the docs for PGObject::Util::DBAdmin.
 
=head2 username
 
=head2 password
 
=head2 host
 
=head2 port
 
=head2 dbname
 
=head1 ADDITIONAL PROPERTIES
 
=head2 version

lib/App/LedgerSMB/Admin/Database/Setting.pm  view on Meta::CPAN

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    my ($self) = @_;
    return $self->database->connect;
}
 
sub _get_prefix { 'setting_' };
 
=head1 SYNOPSIS
 
 my $db = App::LedgerSMB::Admin::Database->new(
      username => 'postgres',
      password => 'secret',
      host     => 'localhost',
      port     => '5432',
 );
 my $setting = App::LedgerSMB::Admin::Database::Setting->new(
     database    => $db,
     setting_key => 'separate_duties');
 my $sep_duties = $setting->value;
 
=head1 PROPERTIES

lib/App/LedgerSMB/Admin/User.pm  view on Meta::CPAN

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    first_name  => 'Chris',
    last_name   => 'Travers',
    is_employee => 0,
    is_person   => 1,
    username    => 'chris',
    temp_pass   => 'foobarbaz',
    country_id  => '232',
    database    => App::LedgerSMB::Admin::Database->new(
                       dbname => 'lsmb13',
                     username => 'postgres',
                     password => 'secret',
                         host => 'localhost',
                         port => '5432',
                   ),
 );
 $user->assign_roles($user->list_roles);
 $user->save;
 
=head1 PROPERTIES
 
=head2 database

lib/App/LedgerSMB/Admin/User.pm  view on Meta::CPAN

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
                   unless eval { $_[0]->isa('App::LedgerSMB::Admin::Database')};
                },
);
 
=head2 username
 
=cut
 
has username => (is => 'ro');
 
=head2 password
 
=cut
 
has password => (is => 'ro');
 
=head2 first_name
 
=cut
 
has first_name => (is => 'ro');
 
=head2 last_name
 
=cut

lib/App/LedgerSMB/Admin/User.pm  view on Meta::CPAN

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
=head2 get
 
=cut
 
dbmethod get => (funcname => 'get_user');
 
=head2 reset_passwd
 
=cut
 
dbmethod reset_password => (funcname => 'save_user');
 
=head1 LICENSE AND COPYRIGHT
 
Copyright 2014 Chris Travers.
 
This program is distributed under the (Revised) BSD License:
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions



( run in 0.373 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )