From c2eb423c1c606c114c5338c3e0dc4bfec20cd088 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 2 Sep 2012 18:46:36 +0200 Subject: [PATCH] premier commit --- createlinks | 7 +++ .../defaults/mozilla-sync/DbName | 1 + .../defaults/mozilla-sync/DbUser | 1 + .../defaults/mozilla-sync/status | 1 + .../configuration/defaults/mozilla-sync/type | 1 + .../migrate/mozilla-sync-database | 27 +++++++++ .../etc/e-smith/sql/init/mozillasyncdb | 43 ++++++++++++++ .../conf/httpd.conf/20LoadModule97py26ModWsgi | 2 + .../etc/httpd/conf/httpd.conf/97MozillaSync | 27 +++++++++ .../mozilla-sync-server.conf/000Setup | 10 ++++ .../mozilla-sync-server.conf/010global | 3 + .../mozilla-sync-server.conf/020captcha | 7 +++ .../mozilla-sync-server.conf/030storage | 20 +++++++ .../mozilla-sync-server.conf/040auth | 14 +++++ .../mozilla-sync-server.conf/050nodes | 10 ++++ .../mozilla-sync-server.conf/060smtp | 6 ++ .../mozilla-sync-server.conf/070cef | 9 +++ smeserver-mozilla-sync-server.spec | 57 +++++++++++++++++++ 18 files changed, 246 insertions(+) create mode 100644 createlinks create mode 100644 root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbName create mode 100644 root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbUser create mode 100644 root/etc/e-smith/db/configuration/defaults/mozilla-sync/status create mode 100644 root/etc/e-smith/db/configuration/defaults/mozilla-sync/type create mode 100644 root/etc/e-smith/db/configuration/migrate/mozilla-sync-database create mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/mozillasyncdb create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule97py26ModWsgi create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/97MozillaSync create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/000Setup create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/010global create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/020captcha create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/030storage create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/040auth create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/050nodes create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/060smtp create mode 100644 root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/070cef create mode 100644 smeserver-mozilla-sync-server.spec diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..d38ccb8 --- /dev/null +++ b/createlinks @@ -0,0 +1,7 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +templates2events("/etc/mozilla-sync-server/mozilla-sync-server.conf", qw(webapps-update bootstrap-console-save)); +templates2events("/etc/e-smith/sql/init/mozillasyncdb", qw(webapps-update bootstrap-console-save)); + diff --git a/root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbName b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbName new file mode 100644 index 0000000..a7aa7ab --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbName @@ -0,0 +1 @@ +mozillasyncdb diff --git a/root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbUser b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbUser new file mode 100644 index 0000000..e527a24 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/DbUser @@ -0,0 +1 @@ +mozillasync diff --git a/root/etc/e-smith/db/configuration/defaults/mozilla-sync/status b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/mozilla-sync/type b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/mozilla-sync/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/db/configuration/migrate/mozilla-sync-database b/root/etc/e-smith/db/configuration/migrate/mozilla-sync-database new file mode 100644 index 0000000..ed42902 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/mozilla-sync-database @@ -0,0 +1,27 @@ +{ + my $rec = $DB->get('mozilla-sync') + || $DB->new_record('mozilla-sync', {type => 'service'}); + my $pw = $rec->prop('DbPassword'); + if (not $pw or length($pw) < 57){ + use MIME::Base64 qw(encode_base64); + + $pw = "not set due to error"; + if ( open( RANDOM, "/dev/urandom" ) ){ + my $buf; + # 57 bytes is a full line of Base64 coding, and contains + # 456 bits of randomness - given a perfectly random /dev/random + if ( read( RANDOM, $buf, 57 ) != 57 ){ + warn("Short read from /dev/random: $!"); + } + else{ + $pw = encode_base64($buf); + chomp $pw; + } + close RANDOM; + } + else{ + warn "Could not open /dev/urandom: $!"; + } + $rec->set_prop('DbPassword', $pw); + } +} diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/mozillasyncdb b/root/etc/e-smith/templates/etc/e-smith/sql/init/mozillasyncdb new file mode 100644 index 0000000..97745ed --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/mozillasyncdb @@ -0,0 +1,43 @@ +{ +my $db = ${'mozilla-sync'}{'DbName'} || 'mozillasyncdb'; +my $user = ${'mozilla-sync'}{'DbUser'} || 'mozillasync'; +my $pass = ${'mozilla-sync'}{'DbPassword'} || 'secret'; + +$OUT .= <<"END"; +#! /bin/sh +if [ ! -d /var/lib/mysql/$db ]; then + /usr/bin/mysql -e 'create database $db' +fi + +/usr/bin/mysql < + Order deny,allow + Deny from all + Allow from $access + SSLRequireSSL on + + WSGIProcessGroup localhost + WSGIPassAuthorization On + + +EOF +} +else{ + $OUT .= "# Mozilla Sync server is disabled"; +} +} diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/000Setup b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/000Setup new file mode 100644 index 0000000..a2b28de --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/000Setup @@ -0,0 +1,10 @@ +{ + +our $db = ${'mozilla-sync'}{'DbName'} || 'mozillasyncdb'; +our $user = ${'mozilla-sync'}{'DbUser'} || 'mozillasync'; +our $pass = ${'mozilla-sync'}{'DbPassword'} || 'secret'; +our $quota = ${'mozilla-sync'}{'UserQuota'} || '102400'; +our $useQuota = ($quota =~ m/^\d+$/) ? 'true':'false'; + + +} diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/010global b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/010global new file mode 100644 index 0000000..9731602 --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/010global @@ -0,0 +1,3 @@ +[global] +clean_shutdown = false + diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/020captcha b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/020captcha new file mode 100644 index 0000000..31b9859 --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/020captcha @@ -0,0 +1,7 @@ + +[captcha] +use = false +public_key = 6Le8OLwSAAAAAK-wkjNPBtHD4Iv50moNFANIalJL +private_key = 6Le8OLwSAAAAAEKoqfc-DmoF4HNswD7RNdGwxRij +use_ssl = false + diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/030storage b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/030storage new file mode 100644 index 0000000..e4e6f73 --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/030storage @@ -0,0 +1,20 @@ + +{ + +$OUT .=<<"EOF"; + +[storage] +backend = syncstorage.storage.sql.SQLStorage +sqluri = mysql://$user:$pass@localhost/$db +standard_collections = false +use_quota = $useQuota +quota_size = $quota +pool_size = 20 +pool_recycle = 3600 +reset_on_return = true +display_config = true +create_tables = true + +EOF + +} diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/040auth b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/040auth new file mode 100644 index 0000000..379d245 --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/040auth @@ -0,0 +1,14 @@ +{ + +$OUT .=<<"EOF"; + +[auth] +backend = services.user.sql.SQLUser +sqluri = mysql://$user:$pass@localhost/$db +pool_size = 20 +pool_recycle = 3600 +create_tables = true + +EOF + +} diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/050nodes b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/050nodes new file mode 100644 index 0000000..07583e4 --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/050nodes @@ -0,0 +1,10 @@ +{ + +$OUT .=<<"EOF"; + +[nodes] +fallback_node = https://$SystemName.$DomainName/mozilla-sync/ + +EOF + +} diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/060smtp b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/060smtp new file mode 100644 index 0000000..0df139e --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/060smtp @@ -0,0 +1,6 @@ + +[smtp] +host = localhost +port = 25 +sender = weave@{$DomainName} + diff --git a/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/070cef b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/070cef new file mode 100644 index 0000000..99372df --- /dev/null +++ b/root/etc/e-smith/templates/etc/mozilla-sync-server/mozilla-sync-server.conf/070cef @@ -0,0 +1,9 @@ + +[cef] +use = true +file = syslog +vendor = mozilla +version = 0 +device_version = 1.3 +product = weave + diff --git a/smeserver-mozilla-sync-server.spec b/smeserver-mozilla-sync-server.spec new file mode 100644 index 0000000..5f5936e --- /dev/null +++ b/smeserver-mozilla-sync-server.spec @@ -0,0 +1,57 @@ +# Authority: vip-ire +# Name: Daniel Berteaud + +%define name smeserver-mozilla-sync-server +%define version 0.0.1 +%define release 0.beta1 +Summary: sme server integration of Firefox Sync Server +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GNU GPL +URL: https://wiki.mozilla.org/Firefox_Sync +Group: SMEserver/addon +Source: %{name}-%{version}.tar.gz + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: /var/tmp/%{name}-%{version} +Requires: e-smith-base >= 5.2.0-56 +Requires: mozilla-sync-server +Requires: python26-wsgiproxy +Requires: python26-mysqldb +Requires: smeserver-webapps-common + +%description +smserver integration of Firefox Sync Server. +The Firefox Sync Server (formelly known as Weave) lets you +sync history, settings, passwords, tabs etc... between several +devices or computers + +%changelog +* Sun Sep 2 2012 Daniel Berteaud 0.0.1 +- Initial release + +%prep +%setup + +%build +perl ./createlinks + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + > %{name}-%{version}-filelist +echo "%doc CHANGELOG.git" >> %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + + +%postun +