Initial commit

master
Daniel Berteaud 12 years ago
commit f211f5ede4
  1. 11
      createlinks
  2. 1
      root/etc/e-smith/db/accounts/defaults/owncloud/type
  3. 1
      root/etc/e-smith/db/configuration/defaults/owncloud/status
  4. 1
      root/etc/e-smith/db/configuration/defaults/owncloud/type
  5. 25
      root/etc/e-smith/db/configuration/migrate/OwnCloudDBPassword
  6. 1
      root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/ownclouddb
  7. 84
      root/etc/e-smith/templates/etc/e-smith/sql/init/ownclouddb
  8. 53
      root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98OwnCloud
  9. 13
      root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60owncloud-ssl
  10. 23
      root/etc/e-smith/templates/etc/owncloud/autoconfig.php/10All
  11. 58
      smeserver-owncloud.spec

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

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

@ -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 <<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
# Call owncloud URL, it will trigger the install the first time
wget -O /dev/null --no-check-certificate https://$SystemName.$DomainName/owncloud 2>&1 > /dev/null
# Now Configure owncloud to use LDAP
/usr/bin/mysql <<EOF
USE $db;
REPLACE INTO appconfig (appid, configkey, configvalue) VALUES
('user_ldap', 'ldap_base', '$ldapBase'),
('user_ldap', 'ldap_base_groups', 'ou=Groups,$ldapBase'),
('user_ldap', 'ldap_base_users', 'ou=Users,$ldapBase');
INSERT IGNORE INTO appconfig (appid, configkey, configvalue) VALUES
('user_ldap', 'enabled', 'yes'),
('user_ldap', 'ldap_cache_ttl', '1'),
('user_ldap', 'ldap_display_name', 'uid'),
('user_ldap', 'ldap_email_attr', 'mail'),
('user_ldap', 'ldap_group_display_name', 'cn'),
('user_ldap', 'ldap_group_filter', 'objectClass=mailboxRelatedObject'),
('user_ldap', 'ldap_group_member_assoc_attribute', 'memberUid'),
('user_ldap', 'ldap_host', '127.0.0.1'),
('user_ldap', 'ldap_login_filter', 'uid=%uid'),
('user_ldap', 'ldap_userlist_filter', 'objectClass=sambaSamAccount'),
('user_ldap', 'ldap_uuid_attribute', 'entryuuid'),
('user_ldap', 'types', 'authentication');
UPDATE IGNORE group_user group_user SET uid='admin' where uid='owncloud';
DELETE FROM users where uid='owncloud';
EOF
END
}

@ -0,0 +1,53 @@
{
if (($owncloud{'status'} || 'disabled') eq 'enabled'){
my $access = (($owncloud{'access'} || 'private') eq 'public') ? 'all':"$localAccess $externalSSLAccess";
my $alias = (($owncloud{'AliasOnPrimary'} || 'enabled') eq 'disabled') ?
'':"Alias /owncloud /usr/share/owncloud\n".
"Alias /oc-apps /var/lib/owncloud/apps";
$OUT .=<<"HERE";
# owncloud config
$alias
<Directory /usr/share/owncloud>
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
</Directory>
<Directory /var/lib/owncloud/apps>
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
</Directory>
HERE
}
else {
$OUT .= "# OwnCloud is disabled\n";
}
}

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

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

@ -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 <daniel@firewall-services.com> 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
Loading…
Cancel
Save