From a12257afaff8002f518e73193273185816792b77 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 15 Mar 2013 14:07:09 +0100 Subject: [PATCH] cleanup database creation, change sogo home to /var/lib/sogo and change default shell to /sbin/nologin --- createlinks | 7 ++-- root/etc/e-smith/events/actions/sogo-backup | 2 +- root/etc/e-smith/events/actions/sogo-delete-user | 2 +- root/etc/e-smith/events/actions/sogo-upgrade | 6 ++++ .../sql/init/31sogo_mysql_update_privileges | 1 - .../etc/e-smith/sql/init/31sogo_upgrade | 1 - .../init/{30sogo_mysql_create_database => sogo} | 0 .../lib}/sogo/GNUstep/Defaults/.GNUstepDefaults | 0 .../e-smith/sql/init/30sogo_mysql_create_database | 3 -- .../sql/init/31sogo_mysql_update_privileges | 3 -- .../templates/etc/e-smith/sql/init/31sogo_upgrade | 3 -- .../e-smith/templates/etc/e-smith/sql/init/sogo | 40 ++++++++++++++++++++++ .../smeserver/sogo_mysql_update_privileges.sql | 22 ------------ .../sogo/GNUstep/Defaults/.GNUstepDefaults/10start | 0 .../sogo/GNUstep/Defaults/.GNUstepDefaults/15mysql | 0 .../GNUstep/Defaults/.GNUstepDefaults/16memcached | 0 .../sogo/GNUstep/Defaults/.GNUstepDefaults/20mail | 0 .../Defaults/.GNUstepDefaults/25notifications | 0 .../Defaults/.GNUstepDefaults/30defaultPrefs | 0 .../GNUstep/Defaults/.GNUstepDefaults/35external | 0 .../sogo/GNUstep/Defaults/.GNUstepDefaults/40sieve | 0 .../GNUstep/Defaults/.GNUstepDefaults/45admins | 0 .../GNUstep/Defaults/.GNUstepDefaults/50timezone | 0 .../GNUstep/Defaults/.GNUstepDefaults/55authSource | 0 .../GNUstep/Defaults/.GNUstepDefaults/60various | 0 .../sogo/GNUstep/Defaults/.GNUstepDefaults/99end | 0 .../Defaults/.GNUstepDefaults/template-begin | 0 .../sogo/smeserver/sogo_mysql_create_database.sql | 29 ---------------- .../smeserver/sogo_mysql_update_privileges.sql | 1 - root/usr/share/qpsmtpd/plugins/fix_headers_case | 2 +- .../lib}/sogo/GNUstep/Defaults/.GNUstepDefaults | 0 .../Library/SOGo/Templates/MainUI/SOGoRootPage.wox | 0 32 files changed, 52 insertions(+), 70 deletions(-) create mode 100644 root/etc/e-smith/events/actions/sogo-upgrade delete mode 100644 root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_mysql_update_privileges delete mode 100644 root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_upgrade rename root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/{30sogo_mysql_create_database => sogo} (100%) rename root/etc/e-smith/templates.metadata/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults (100%) delete mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/30sogo_mysql_create_database delete mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_mysql_update_privileges delete mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_upgrade create mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/sogo delete mode 100644 root/etc/e-smith/templates/home/sogo/smeserver/sogo_mysql_update_privileges.sql rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/10start (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/15mysql (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/16memcached (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/20mail (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/25notifications (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/30defaultPrefs (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/35external (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/40sieve (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/45admins (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/50timezone (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/55authSource (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/60various (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/99end (100%) rename root/etc/e-smith/templates/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults/template-begin (100%) delete mode 100644 root/home/sogo/smeserver/sogo_mysql_create_database.sql delete mode 100644 root/home/sogo/smeserver/sogo_mysql_update_privileges.sql rename root/{home => var/lib}/sogo/GNUstep/Defaults/.GNUstepDefaults (100%) rename root/{home => var/lib}/sogo/GNUstep/Library/SOGo/Templates/MainUI/SOGoRootPage.wox (100%) diff --git a/createlinks b/createlinks index c6d2dac..13702e5 100755 --- a/createlinks +++ b/createlinks @@ -5,11 +5,9 @@ use esmith::Build::CreateLinks qw(:all); service_link_enhanced("memcached-sogo", "S55", "7"); service_link_enhanced("sogod", "S85", "7"); -templates2events("/etc/e-smith/sql/init/30sogo_mysql_create_database", qw(email-update bootstrap-console-save)); -templates2events("/etc/e-smith/sql/init/31sogo_mysql_update_privileges", qw(email-update bootstrap-console-save)); -templates2events("/home/sogo/smeserver/sogo_mysql_update_privileges.sql", qw(email-update bootstrap-console-save)); +templates2events("/etc/e-smith/sql/init/sogo", qw(email-update bootstrap-console-save)); templates2events("/etc/cron.d/sogo-alarm", qw(email-update bootstrap-console-save)); -templates2events("/home/sogo/GNUstep/Defaults/.GNUstepDefaults", qw(email-update bootstrap-console-save pre-backup)); +templates2events("/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults", qw(email-update bootstrap-console-save pre-backup)); templates2events("/etc/sysconfig/sogo", qw(email-update bootstrap-console-save)); templates2events("/etc/logrotate.d/sogo", qw(email-update bootstrap-console-save)); @@ -21,6 +19,7 @@ event_link("sogo-delete-backup", "pre-backup", "60"); event_link("sogo-delete-backup", "post-backup", "60"); event_link("sogo-backup", "pre-backup", "70"); event_link("sogo-delete-user", "user-delete", "10"); +event_link("sogo-upgrade", "email-update", "20"); panel_link("sogo", "manager"); diff --git a/root/etc/e-smith/events/actions/sogo-backup b/root/etc/e-smith/events/actions/sogo-backup index aedf906..531499e 100644 --- a/root/etc/e-smith/events/actions/sogo-backup +++ b/root/etc/e-smith/events/actions/sogo-backup @@ -1,4 +1,4 @@ #!/bin/bash -su - sogo -c "/usr/sbin/sogo-tool backup /home/e-smith/db/sogo ALL" > /dev/null 2>&1 +su -l -s /bin/bash sogo -c "/usr/sbin/sogo-tool backup /home/e-smith/db/sogo ALL" > /dev/null 2>&1 diff --git a/root/etc/e-smith/events/actions/sogo-delete-user b/root/etc/e-smith/events/actions/sogo-delete-user index 9733f85..7ea545c 100644 --- a/root/etc/e-smith/events/actions/sogo-delete-user +++ b/root/etc/e-smith/events/actions/sogo-delete-user @@ -12,5 +12,5 @@ if [ -z "$USER" ]; then exit 1 fi -su - sogo -c "/usr/sbin/sogo-tool remove $USER" > /dev/null 2>&1 +su -l -s /bin/bash sogo -c "/usr/sbin/sogo-tool remove $USER" > /dev/null 2>&1 diff --git a/root/etc/e-smith/events/actions/sogo-upgrade b/root/etc/e-smith/events/actions/sogo-upgrade new file mode 100644 index 0000000..2dfd531 --- /dev/null +++ b/root/etc/e-smith/events/actions/sogo-upgrade @@ -0,0 +1,6 @@ +#!/bin/bash + +/usr/bin/getent passwd sogo | grep -q '/home/sogo' +if [ $? -eq 0 ]; then + /usr/sbin/usermod -d /var/lib/sogo -m -s /sbin/nologin -c "SOGo daemon" sogo 2>/dev/null +fi diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_mysql_update_privileges b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_mysql_update_privileges deleted file mode 100644 index 6a29f37..0000000 --- a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_mysql_update_privileges +++ /dev/null @@ -1 +0,0 @@ -PERMS=0540 diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_upgrade b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_upgrade deleted file mode 100644 index 6a29f37..0000000 --- a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/31sogo_upgrade +++ /dev/null @@ -1 +0,0 @@ -PERMS=0540 diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/30sogo_mysql_create_database b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/sogo similarity index 100% rename from root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/30sogo_mysql_create_database rename to root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/sogo diff --git a/root/etc/e-smith/templates.metadata/home/sogo/GNUstep/Defaults/.GNUstepDefaults b/root/etc/e-smith/templates.metadata/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults similarity index 100% rename from root/etc/e-smith/templates.metadata/home/sogo/GNUstep/Defaults/.GNUstepDefaults rename to root/etc/e-smith/templates.metadata/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/30sogo_mysql_create_database b/root/etc/e-smith/templates/etc/e-smith/sql/init/30sogo_mysql_create_database deleted file mode 100644 index f5ef3fb..0000000 --- a/root/etc/e-smith/templates/etc/e-smith/sql/init/30sogo_mysql_create_database +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -exec mysql < /home/sogo/smeserver/sogo_mysql_create_database.sql diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_mysql_update_privileges b/root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_mysql_update_privileges deleted file mode 100644 index e614329..0000000 --- a/root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_mysql_update_privileges +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -exec mysql < /home/sogo/smeserver/sogo_mysql_update_privileges.sql diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_upgrade b/root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_upgrade deleted file mode 100644 index 643584f..0000000 --- a/root/etc/e-smith/templates/etc/e-smith/sql/init/31sogo_upgrade +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -exec /etc/e-smith/events/actions/sogo_upgrade diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/sogo b/root/etc/e-smith/templates/etc/e-smith/sql/init/sogo new file mode 100644 index 0000000..06648a8 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/sogo @@ -0,0 +1,40 @@ +{ +my $db = ${'sogod'}{'DbName'} || 'sogo'; +my $user = ${'sogod'}{'DbUser'} || 'sogo'; +my $pass = ${'sogod'}{'DbPassword'} || 'secret'; + +$OUT .= <<"END"; +/usr/bin/mysql <log(LOGINFO, "SOGo mailer detected, going to fix headers case"); foreach my $header (qw/From To Cc Subject Message-ID Content-Type Date Content-Length Content-Transfer-Encoding/){ - my $value = $self->get_header($transaction,$header) or return DECLINED; + my $value = $self->get_header($transaction,$header) or next; $self->set_header($transaction, $header, $value); } return DECLINED; diff --git a/root/home/sogo/GNUstep/Defaults/.GNUstepDefaults b/root/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults similarity index 100% rename from root/home/sogo/GNUstep/Defaults/.GNUstepDefaults rename to root/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults diff --git a/root/home/sogo/GNUstep/Library/SOGo/Templates/MainUI/SOGoRootPage.wox b/root/var/lib/sogo/GNUstep/Library/SOGo/Templates/MainUI/SOGoRootPage.wox similarity index 100% rename from root/home/sogo/GNUstep/Library/SOGo/Templates/MainUI/SOGoRootPage.wox rename to root/var/lib/sogo/GNUstep/Library/SOGo/Templates/MainUI/SOGoRootPage.wox