commit f211f5ede41b088279c1f49353c9750039c42e29 Author: Daniel Berteaud Date: Tue Dec 4 11:48:45 2012 +0100 Initial commit diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..4214fe3 --- /dev/null +++ b/createlinks @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +# Templates to expand +templates2events("/etc/e-smith/sql/init/ownclouddb", qw(bootstrap-console-save webapps-update)); +templates2events("/etc/owncloud/autoconfig.php", qw(bootstrap-console-save webapps-update)); + +# PHP header and footer +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/owncloud/autoconfig.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/owncloud/autoconfig.php/template-end"); diff --git a/root/etc/e-smith/db/accounts/defaults/owncloud/type b/root/etc/e-smith/db/accounts/defaults/owncloud/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/accounts/defaults/owncloud/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/db/configuration/defaults/owncloud/status b/root/etc/e-smith/db/configuration/defaults/owncloud/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/owncloud/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/owncloud/type b/root/etc/e-smith/db/configuration/defaults/owncloud/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/owncloud/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/db/configuration/migrate/OwnCloudDBPassword b/root/etc/e-smith/db/configuration/migrate/OwnCloudDBPassword new file mode 100644 index 0000000..0e5151a --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/OwnCloudDBPassword @@ -0,0 +1,25 @@ +{ + my $rec = $DB->get('owncloud') + || $DB->new_record('owncloud', {type => 'webapp'}); + 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; + 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.metadata/etc/e-smith/sql/init/ownclouddb b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/ownclouddb new file mode 100644 index 0000000..940dcf3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/ownclouddb @@ -0,0 +1 @@ +PERMS=0750 diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/ownclouddb b/root/etc/e-smith/templates/etc/e-smith/sql/init/ownclouddb new file mode 100644 index 0000000..d95b4e5 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/ownclouddb @@ -0,0 +1,84 @@ +{ +use esmith::util; +my $ldapBase = esmith::util::ldapBase ($DomainName); +my $db = $owncloud{'DbName'} || 'owncloud'; +my $user = $owncloud{'DbUser'} || 'owncloud'; +my $pass = $owncloud{'DbPassword'} || 'owncloud'; + + +$OUT .= <<"END"; +#! /bin/sh +if [ ! -d /var/lib/mysql/$db ]; then + # Create the database + /usr/bin/mysql -e 'create database $db' +fi + +# Update the owncloud mysql user and password +/usr/bin/mysql <&1 > /dev/null + +# Now Configure owncloud to use LDAP +/usr/bin/mysql < + Options None + Options +FollowSymLinks + AllowOverride All + # PHP tuning + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/owncloud:/var/lib/owncloud/:/etc/owncloud:/var/log/owncloud.log + php_admin_value memory_limit 512M + php_admin_flag allow_url_fopen on + php_admin_value max_execution_time 3600 + php_admin_value max_post_size 2047M + php_admin_value upload_max_filesize 2047M + php_admin_value upload_tmp_dir /var/lib/owncloud/tmp + php_admin_value session.save_path /var/lib/owncloud/sessions + + # Access restriction + order deny,allow + deny from all + allow from $access + + + + Options None + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/owncloud:/var/lib/owncloud/:/etc/owncloud:/var/log/owncloud.log + php_admin_value memory_limit 512M + php_admin_flag allow_url_fopen on + php_admin_value max_execution_time 3600 + order deny,allow + deny from all + allow from $access + + +HERE + +} +else { + $OUT .= "# OwnCloud is disabled\n"; +} +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60owncloud-ssl b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60owncloud-ssl new file mode 100644 index 0000000..44cc277 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60owncloud-ssl @@ -0,0 +1,13 @@ +{ +my $sslport = $modSSL{'TCPPort'} || '443'; +my $status = $owncloud{'status'} || 'enabled'; +my $alias = $owncloud{'AliasOnPrimary'} || 'enabled'; + +if (($port ne $sslport) && ($status eq 'enabled') && ($alias eq 'enabled')){ + + ## Redirect Web Address to Secure Address + $OUT .= " RewriteEngine on\n"; + $OUT .= " RewriteRule ^/owncloud(/.*|\$) https://%{HTTP_HOST}/owncloud\$1 \[L,R\]\n"; + +} +} diff --git a/root/etc/e-smith/templates/etc/owncloud/autoconfig.php/10All b/root/etc/e-smith/templates/etc/owncloud/autoconfig.php/10All new file mode 100644 index 0000000..1b4c529 --- /dev/null +++ b/root/etc/e-smith/templates/etc/owncloud/autoconfig.php/10All @@ -0,0 +1,23 @@ +{ + +my $dbname = $owncloud{'DbName'} || 'owncloud'; +my $dbuser = $owncloud{'DbUser'} || 'owncloud'; +my $dbpass = $owncloud{'DbPassword'} || 'owncloud'; + +$OUT .=<<"EOF"; + +\$AUTOCONFIG = array ( + 'adminlogin' => 'owncloud', + 'adminpass' => 'owncloud', + 'directory' => '/var/lib/owncloud/data', + 'dbtype' => 'mysql', + 'dbname' => '$dbname', + 'dbuser' => '$dbuser', + 'dbpass' => '$dbpass', + 'dbhost' => '127.0.0.1', + 'dbtableprefix' => '', +); + +EOF + +} diff --git a/smeserver-owncloud.spec b/smeserver-owncloud.spec new file mode 100644 index 0000000..f95fb65 --- /dev/null +++ b/smeserver-owncloud.spec @@ -0,0 +1,58 @@ +# Authority: vip-ire +# Name: Daniel Berteaud + +%define name smeserver-owncloud +%define version 0.0.1 +%define release 1.beta5 +Summary: sme server integration of owncloud +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GNU GPL version 2 +URL: http://www.zabbix.com/ +Group: SMEserver/addon +Source: %{name}-%{version}.tar.gz + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: /var/tmp/%{name}-%{version} +Requires: e-smith-release +Requires: owncloud >= 4.5.3 +Requires: smeserver-webapps-common +AutoReqProv: no + +%description +Integration of owncloud on SME Server + +%changelog +* Tue Dec 4 2012 Daniel Berteaud 0.0.1-1.sme +- 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 + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + + +%postun +#uninstall +if [ $1 = 0 ] ; then + /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf + /usr/bin/sv h /service/httpd-e-smith +fi + +true +