Firstrun fix
This commit is contained in:
parent
6ad0cdda31
commit
0c984eec91
13
Database.pm
13
Database.pm
@ -71,15 +71,20 @@ sub create_base {
|
|||||||
my $gpg = $self->{_gpg};
|
my $gpg = $self->{_gpg};
|
||||||
|
|
||||||
# Check dir
|
# Check dir
|
||||||
if ( !( -d $pm_dir ) ) {
|
if ( !( -d $pm_dir ) or !( -e $pm_dir . "db.sqlite" ) ) {
|
||||||
|
|
||||||
|
# Remove old configuration dirrectory
|
||||||
|
print "Remove old dirrectory...\n";
|
||||||
|
my @rm_old_cmd = ( 'rm', '-rf', $pm_dir );
|
||||||
|
system(@rm_old_cmd) == 0 or die "Cannot remove $pm_dir: $!\n";
|
||||||
|
|
||||||
# Create dirrectory
|
# Create dirrectory
|
||||||
print "Creating configuration dirrectory...\n";
|
print "Creating configuration dirrectory...\n";
|
||||||
my @mkdir_cmd = ( "mkdir", "$pm_dir" );
|
my @mkdir_cmd = ( "mkdir", "$pm_dir" );
|
||||||
system(@mkdir_cmd) == 0 or die "Cannot create dir $pm_dir: $!\n";
|
system(@mkdir_cmd) == 0 or die "Cannot create dir $pm_dir: $!\n";
|
||||||
|
|
||||||
my $pass = Password->new();
|
my $pass = Password->new();
|
||||||
my $string = $pass->generate();
|
my $string = $pass->generate();
|
||||||
my $first_sqlite = "/tmp/$string";
|
my $first_sqlite = "/tmp/$string";
|
||||||
|
|
||||||
# Create DB file
|
# Create DB file
|
||||||
@ -87,6 +92,7 @@ sub create_base {
|
|||||||
system(@createdb_cmd) == 0 or die "Cannot create database file: $!\n";
|
system(@createdb_cmd) == 0 or die "Cannot create database file: $!\n";
|
||||||
|
|
||||||
print "Creating database...\n";
|
print "Creating database...\n";
|
||||||
|
|
||||||
# Create table.
|
# Create table.
|
||||||
my $dbh = DBI->connect( "dbi:SQLite:dbname=$first_sqlite", "", "" );
|
my $dbh = DBI->connect( "dbi:SQLite:dbname=$first_sqlite", "", "" );
|
||||||
print "Create database schema\n";
|
print "Create database schema\n";
|
||||||
@ -96,6 +102,7 @@ sub create_base {
|
|||||||
$dbh->do($q_table);
|
$dbh->do($q_table);
|
||||||
|
|
||||||
print "Encrypt database...\n";
|
print "Encrypt database...\n";
|
||||||
|
|
||||||
# Encrypt db
|
# Encrypt db
|
||||||
$gpg->encrypt_db($first_sqlite);
|
$gpg->encrypt_db($first_sqlite);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user