premier commit

This commit is contained in:
Daniel Berteaud 2012-09-02 18:46:36 +02:00
commit c2eb423c1c
18 changed files with 246 additions and 0 deletions

7
createlinks Normal file
View File

@ -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));

View File

@ -0,0 +1 @@
mozillasyncdb

View File

@ -0,0 +1 @@
mozillasync

View File

@ -0,0 +1 @@
enabled

View File

@ -0,0 +1 @@
service

View File

@ -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);
}
}

View File

@ -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 <<EOF
USE mysql;
REPLACE INTO user (
host,
user,
password)
VALUES (
'localhost',
'$user',
PASSWORD ('$pass'));
REPLACE INTO db (
host,
db,
user,
select_priv, insert_priv, update_priv, delete_priv,
create_priv, alter_priv, index_priv, drop_priv, create_tmp_table_priv,
grant_priv, lock_tables_priv, references_priv)
VALUES (
'localhost',
'$db',
'$user',
'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y', 'Y', 'Y',
'N', 'Y', 'Y');
FLUSH PRIVILEGES;
EOF
END
}

View File

@ -0,0 +1,2 @@
# Load mod_wsgi for Mozilla Sync Server
LoadModule wsgi_module modules/python26-mod_wsgi.so

View File

@ -0,0 +1,27 @@
{
if ((${'mozilla-sync'}{'status'} || 'disabled') eq 'enabled') {
my $access = ((${'mozilla-sync'}{'access'} || 'private') eq 'public') ? "all":"$localAccess $externalSSLAccess";
$OUT .=<<"EOF";
WSGIDaemonProcess localhost user=www group=www processes=2 threads=25
WSGIScriptAlias /mozilla-sync /usr/share/mozilla-sync-server/mozilla-sync-server.wsgi
WSGISocketPrefix /var/run/mozilla-sync-server.pid
<Location /mozilla-sync/>
Order deny,allow
Deny from all
Allow from $access
SSLRequireSSL on
WSGIProcessGroup localhost
WSGIPassAuthorization On
</Location>
EOF
}
else{
$OUT .= "# Mozilla Sync server is disabled";
}
}

View File

@ -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';
}

View File

@ -0,0 +1,3 @@
[global]
clean_shutdown = false

View File

@ -0,0 +1,7 @@
[captcha]
use = false
public_key = 6Le8OLwSAAAAAK-wkjNPBtHD4Iv50moNFANIalJL
private_key = 6Le8OLwSAAAAAEKoqfc-DmoF4HNswD7RNdGwxRij
use_ssl = false

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,10 @@
{
$OUT .=<<"EOF";
[nodes]
fallback_node = https://$SystemName.$DomainName/mozilla-sync/
EOF
}

View File

@ -0,0 +1,6 @@
[smtp]
host = localhost
port = 25
sender = weave@{$DomainName}

View File

@ -0,0 +1,9 @@
[cef]
use = true
file = syslog
vendor = mozilla
version = 0
device_version = 1.3
product = weave

View File

@ -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 <daniel@firewall-services.com> 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