summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b329f7)
raw | patch | inline | side by side (parent: 0b329f7)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 2 Jan 2008 14:07:53 +0000 (14:07 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 2 Jan 2008 14:07:53 +0000 (14:07 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8176 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/DBsqlite.pm | [deleted file] | patch | blob | history |
gosa-si/debian/gosa-si-client.dirs | patch | blob | history | |
gosa-si/debian/gosa-si-client.postinst | [new file with mode: 0644] | patch | blob |
gosa-si/debian/gosa-si-server.dirs | patch | blob | history | |
gosa-si/debian/gosa-si-server.install | patch | blob | history | |
gosa-si/debian/gosa-si-server.postinst | [new file with mode: 0644] | patch | blob |
gosa-si/debian/rules | patch | blob | history | |
gosa-si/modules/DBsqlite.pm | [new file with mode: 0644] | patch | blob |
diff --git a/gosa-si/DBsqlite.pm b/gosa-si/DBsqlite.pm
--- a/gosa-si/DBsqlite.pm
+++ /dev/null
@@ -1,243 +0,0 @@
-package DBsqlite;
-
-
-use strict;
-use warnings;
-use DBI;
-use Data::Dumper;
-
-
-
-sub new {
- my $object = shift;
- my $db_name = shift;
-
- my $obj_ref = {};
- bless($obj_ref,$object);
- my $dbh = DBI->connect("dbi:SQLite:dbname=$db_name");
- $obj_ref->{dbh} = $dbh;
-
- return($obj_ref);
-}
-
-
-sub create_table {
- my $object = shift;
- my $table_name = shift;
- my $col_names_ref = shift;
- my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name (".join(', ', @{$col_names_ref}).")";
- $object->{dbh}->do($sql_statement);
- return 0;
-}
-
-
-
-sub add_dbentry {
-
- my $obj = shift;
- my $arg = shift;
-
- # if dbh not specified, return errorflag 1
- my $table = $arg->{table};
- if (not defined $table) {
- return 1;
- }
-
- # incrementing running id
- if (not exists $arg->{id}) {
- my $max_id = @{@{$obj->{dbh}->selectall_arrayref("SELECT MAX(id) FROM $table")}[0]}[0];
- if (not defined $max_id) {
- $max_id = 0;
- }
- $arg->{id} = $max_id + 1;
- }
-
-
- # fetch column names of table
- my $col_names = $obj->get_table_columns($table);
-
- # assign values to column name variables
- my @add_list;
- foreach my $col_name (@{$col_names}) {
- if (exists $arg->{$col_name}) {
- push(@add_list, $arg->{$col_name});
- } else {
- my $default_val = "none";
- if ($col_name eq "timestamp") {
- $default_val = "19700101000000";
- }
- push(@add_list, $default_val);
- }
-
- }
-
- # check wether id does not exists in table, otherwise return errorflag 2
- my $res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table WHERE id='$arg->{id}'")};
- if ($res != 0) {
- return 2;
- }
-
- my $sql_statement = " INSERT INTO $table VALUES ('".join("', '", @add_list)."') ";
- print " INSERT INTO $table VALUES ('".join("', '", @add_list)."')\n";
- $obj->{dbh}->do($sql_statement);
-
- return 0;
-
-}
-
-sub change_dbentry {
- my $obj = shift;
- my $arg = shift;
-
- # check completeness of function parameter
- # extract table statement from arg hash
- my $table = $arg->{table};
- if (not defined $table) {
- return 1;
- } else {
- delete $arg->{table};
- }
- # extract where parameter from arg hash
- my $restric_pram = $arg->{where};
- if (not defined $restric_pram) {
- return 2;
- } else {
- delete $arg->{'where'};
- }
- # extrac where value from arg hash
- my $restric_val = $arg->{$restric_pram};
- if (not defined $restric_val) {
- return 3;
- } else {
- delete $arg->{$restric_pram};
- }
-
- # check wether table has all specified columns
- my $columns = {};
- my @res = @{$obj->{dbh}->selectall_arrayref("pragma table_info('$table')")};
- foreach my $column (@res) {
- $columns->{@$column[1]} = "";
- }
- my @pram_list = keys %$arg;
- foreach my $pram (@pram_list) {
- if (not exists $columns->{$pram}) {
- return 4;
- }
- }
-
-
- # select all changes
- my @change_list;
- my $sql_part;
-
- while (my($pram, $val) = each(%{$arg})) {
- push(@change_list, "$pram='$val'");
- }
-
- if (not@change_list) {
- return 5;
- }
-
- $obj->{dbh}->do("UPDATE $table SET ".join(', ',@change_list)." WHERE $restric_pram='$restric_val'");
- return 0;
-}
-
-
-sub del_dbentry {
- my $obj = shift;
- my $arg = shift;
-
- # check completeness of function parameter
- # extract table statement from arg hash
- my $table = $arg->{table};
- if (not defined $table) {
- return 1;
- } else {
- delete $arg->{table};
- }
- # extract where parameter from arg hash
- my $restric_pram = $arg->{where};
- if (not defined $restric_pram) {
- return 2;
- } else {
- delete $arg->{'where'};
- }
- # extrac where value from arg hash
- my $restric_val = $arg->{$restric_pram};
- if (not defined $restric_val) {
- return 3;
- } else {
- delete $arg->{$restric_pram};
- }
-
- # check wether entry exists
- my $res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table WHERE $restric_pram='$restric_val'")};
- if ($res == 0) {
- return 4;
- }
-
- $obj->{dbh}->do("DELETE FROM $table WHERE $restric_pram='$restric_val'");
-
- return 0;
-}
-
-
-sub get_table_columns {
- my $obj = shift;
- my $table = shift;
-
- my @columns;
- my @res = @{$obj->{dbh}->selectall_arrayref("pragma table_info('$table')")};
- foreach my $column (@res) {
- push(@columns, @$column[1]);
- }
-
- return \@columns;
-}
-
-sub select_dbentry {
- my $obj = shift;
- my $arg = shift;
-
- # check completeness of function parameter
- # extract table statement from arg hash
- my $table = $arg->{table};
- if (not defined $table) {
- return 1;
- } else {
- delete $arg->{table};
- }
-
- # collect select statements
- my @select_list;
- my $sql_part;
- while (my ($pram, $val) = each %{$arg}) {
- push(@select_list, "$pram = '$val'");
- }
-
- my $sql_statement = "SELECT * FROM 'jobs' WHERE ".join(' AND ', @select_list);
- my $answer = $obj->{dbh}->selectall_arrayref($sql_statement);
- return $answer;
-}
-
-
-sub show_table {
- my $obj = shift;
- my $table_name = shift;
- my @res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table_name")};
- my @answer;
- foreach my $hit (@res) {
- push(@answer, "hit: ".join(', ', @{$hit}));
- }
- return join("\n", @answer);
-}
-
-
-sub exec_statement {
- my $obj = shift;
- my $sql_statement = shift;
- my @res = @{$obj->{dbh}->selectall_arrayref($sql_statement)};
- return \@res;
-}
-
-1;
index fc22b1cec7ab9cfb443d3168ac71fd1840cf6922..e524ee14c4053521289ec01cbd011ad51144953b 100644 (file)
etc/gosa-si
usr/sbin
+etc/gosa-si/client/events
diff --git a/gosa-si/debian/gosa-si-client.postinst b/gosa-si/debian/gosa-si-client.postinst
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#DEBHELPER#
+
+# We exit unless the package is being configured
+case "$1" in
+ abort*upgrade) exit 0;;
+ abort*remove) exit 0;;
+ abort*deconfigure) exit 0;;
+ configure) ;;
+ *) exit 0;
+esac
+
+[ ! -d /etc/gosa-si/client/events ] && install -d -o root -g root -m 750 /etc/gosa-si/client/events
+
index 08f1b093872f7fa5957c013d065a595c2e4682b5..9103800e97a082f75b0ad3c1159447d945576bc9 100644 (file)
usr/sbin
etc/gosa-si
+etc/gosa-si/server/events
index 52992a51e9c2b2e4a53e0941af57ba6386b4e312..d147f8b7525d59b4c50b04f3faf1ee3013b63452 100644 (file)
server.conf etc/gosa-si
bus.conf etc/gosa-si
modules/ServerPackages.pm usr/share/perl5/GOSA
+modules/DBsqlite.pm usr/share/perl5/GOSA
+modules/GosaPackages.pm usr/share/perl5/GOSA
+modules/GosaSupportDaemon.pm usr/share/perl5/GOSA
diff --git a/gosa-si/debian/gosa-si-server.postinst b/gosa-si/debian/gosa-si-server.postinst
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#DEBHELPER#
+
+# We exit unless the package is being configured
+case "$1" in
+ abort*upgrade) exit 0;;
+ abort*remove) exit 0;;
+ abort*deconfigure) exit 0;;
+ configure) ;;
+ *) exit 0;
+esac
+
+[ ! -d /etc/gosa-si/server/events ] && install -d -o root -g root -m 750 /etc/gosa-si/server/events
diff --git a/gosa-si/debian/rules b/gosa-si/debian/rules
index bbc97a9e1508e94c493ddd18e57e8f4376b626af..d74e36f0e4e81166bf898265bd8f557afd459fa5 100755 (executable)
--- a/gosa-si/debian/rules
+++ b/gosa-si/debian/rules
dh_installchangelogs
#dh_installdebconf
dh_installinit --init-script=gosa-si
- install -d -o root -g root -m 750 debian/gosa-si-server/etc/gosa-si/modules
dh_link
dh_strip
dh_compress
diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm
--- /dev/null
@@ -0,0 +1,243 @@
+package DBsqlite;
+
+
+use strict;
+use warnings;
+use DBI;
+use Data::Dumper;
+
+
+
+sub new {
+ my $object = shift;
+ my $db_name = shift;
+
+ my $obj_ref = {};
+ bless($obj_ref,$object);
+ my $dbh = DBI->connect("dbi:SQLite:dbname=$db_name");
+ $obj_ref->{dbh} = $dbh;
+
+ return($obj_ref);
+}
+
+
+sub create_table {
+ my $object = shift;
+ my $table_name = shift;
+ my $col_names_ref = shift;
+ my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name (".join(', ', @{$col_names_ref}).")";
+ $object->{dbh}->do($sql_statement);
+ return 0;
+}
+
+
+
+sub add_dbentry {
+
+ my $obj = shift;
+ my $arg = shift;
+
+ # if dbh not specified, return errorflag 1
+ my $table = $arg->{table};
+ if (not defined $table) {
+ return 1;
+ }
+
+ # incrementing running id
+ if (not exists $arg->{id}) {
+ my $max_id = @{@{$obj->{dbh}->selectall_arrayref("SELECT MAX(id) FROM $table")}[0]}[0];
+ if (not defined $max_id) {
+ $max_id = 0;
+ }
+ $arg->{id} = $max_id + 1;
+ }
+
+
+ # fetch column names of table
+ my $col_names = $obj->get_table_columns($table);
+
+ # assign values to column name variables
+ my @add_list;
+ foreach my $col_name (@{$col_names}) {
+ if (exists $arg->{$col_name}) {
+ push(@add_list, $arg->{$col_name});
+ } else {
+ my $default_val = "none";
+ if ($col_name eq "timestamp") {
+ $default_val = "19700101000000";
+ }
+ push(@add_list, $default_val);
+ }
+
+ }
+
+ # check wether id does not exists in table, otherwise return errorflag 2
+ my $res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table WHERE id='$arg->{id}'")};
+ if ($res != 0) {
+ return 2;
+ }
+
+ my $sql_statement = " INSERT INTO $table VALUES ('".join("', '", @add_list)."') ";
+ print " INSERT INTO $table VALUES ('".join("', '", @add_list)."')\n";
+ $obj->{dbh}->do($sql_statement);
+
+ return 0;
+
+}
+
+sub change_dbentry {
+ my $obj = shift;
+ my $arg = shift;
+
+ # check completeness of function parameter
+ # extract table statement from arg hash
+ my $table = $arg->{table};
+ if (not defined $table) {
+ return 1;
+ } else {
+ delete $arg->{table};
+ }
+ # extract where parameter from arg hash
+ my $restric_pram = $arg->{where};
+ if (not defined $restric_pram) {
+ return 2;
+ } else {
+ delete $arg->{'where'};
+ }
+ # extrac where value from arg hash
+ my $restric_val = $arg->{$restric_pram};
+ if (not defined $restric_val) {
+ return 3;
+ } else {
+ delete $arg->{$restric_pram};
+ }
+
+ # check wether table has all specified columns
+ my $columns = {};
+ my @res = @{$obj->{dbh}->selectall_arrayref("pragma table_info('$table')")};
+ foreach my $column (@res) {
+ $columns->{@$column[1]} = "";
+ }
+ my @pram_list = keys %$arg;
+ foreach my $pram (@pram_list) {
+ if (not exists $columns->{$pram}) {
+ return 4;
+ }
+ }
+
+
+ # select all changes
+ my @change_list;
+ my $sql_part;
+
+ while (my($pram, $val) = each(%{$arg})) {
+ push(@change_list, "$pram='$val'");
+ }
+
+ if (not@change_list) {
+ return 5;
+ }
+
+ $obj->{dbh}->do("UPDATE $table SET ".join(', ',@change_list)." WHERE $restric_pram='$restric_val'");
+ return 0;
+}
+
+
+sub del_dbentry {
+ my $obj = shift;
+ my $arg = shift;
+
+ # check completeness of function parameter
+ # extract table statement from arg hash
+ my $table = $arg->{table};
+ if (not defined $table) {
+ return 1;
+ } else {
+ delete $arg->{table};
+ }
+ # extract where parameter from arg hash
+ my $restric_pram = $arg->{where};
+ if (not defined $restric_pram) {
+ return 2;
+ } else {
+ delete $arg->{'where'};
+ }
+ # extrac where value from arg hash
+ my $restric_val = $arg->{$restric_pram};
+ if (not defined $restric_val) {
+ return 3;
+ } else {
+ delete $arg->{$restric_pram};
+ }
+
+ # check wether entry exists
+ my $res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table WHERE $restric_pram='$restric_val'")};
+ if ($res == 0) {
+ return 4;
+ }
+
+ $obj->{dbh}->do("DELETE FROM $table WHERE $restric_pram='$restric_val'");
+
+ return 0;
+}
+
+
+sub get_table_columns {
+ my $obj = shift;
+ my $table = shift;
+
+ my @columns;
+ my @res = @{$obj->{dbh}->selectall_arrayref("pragma table_info('$table')")};
+ foreach my $column (@res) {
+ push(@columns, @$column[1]);
+ }
+
+ return \@columns;
+}
+
+sub select_dbentry {
+ my $obj = shift;
+ my $arg = shift;
+
+ # check completeness of function parameter
+ # extract table statement from arg hash
+ my $table = $arg->{table};
+ if (not defined $table) {
+ return 1;
+ } else {
+ delete $arg->{table};
+ }
+
+ # collect select statements
+ my @select_list;
+ my $sql_part;
+ while (my ($pram, $val) = each %{$arg}) {
+ push(@select_list, "$pram = '$val'");
+ }
+
+ my $sql_statement = "SELECT * FROM 'jobs' WHERE ".join(' AND ', @select_list);
+ my $answer = $obj->{dbh}->selectall_arrayref($sql_statement);
+ return $answer;
+}
+
+
+sub show_table {
+ my $obj = shift;
+ my $table_name = shift;
+ my @res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table_name")};
+ my @answer;
+ foreach my $hit (@res) {
+ push(@answer, "hit: ".join(', ', @{$hit}));
+ }
+ return join("\n", @answer);
+}
+
+
+sub exec_statement {
+ my $obj = shift;
+ my $sql_statement = shift;
+ my @res = @{$obj->{dbh}->selectall_arrayref($sql_statement)};
+ return \@res;
+}
+
+1;