Migrating to php 5.3
[dotclear.git] / createBlog.sh
CommitLineData
58266dd3 1#!/bin/sh -x
0873522c 2
3bc366b1
RB
3# Usage:
4# ./createBlog.sh type owner baseurl
5# type = user | group-member | group-admin
6# * user: this is a blog for a user
7# * group-member: this is a blog for a group, all the members of the group can post
8# * group-admin: this is a blog for a group, only group admins can post
9# owner = name of the owner
10# * user blog: forlife of the owner of the blog
11# * group blog: 'diminutif' of the group (from X.net database)
1804b740 12# url = full url of the blog (e.g http://group.blog-x.org/).
3bc366b1
RB
13
14# WARNING: The script generates a .htaccess. The rewrite base might be edited to match
15# the installation. Default value is based on a blog-farm of the form
1804b740 16# http://$owner.base.url/
3bc366b1
RB
17
18# Once the blog has been installed and the .htaccess set-up, you can go on the administration
19# page of the blog at baseurl/admin/
20#
21# Their, go to the section 'Widget' and add (by drag-n-drop) the widgets 'Auth X.org' and 'Copyright'.
22# (should be set up by default in near future).
23
0873522c
FB
24type=$1
25owner=$2
26url=$3
27apache_group=www-data
3bc366b1 28rootpath=/home/web/blogs
0873522c 29templatepath=dotclear
3bc366b1
RB
30baseurl=/
31serviceurl="http://blog.polytechnique.org/xorgservice/createBlog"
0873522c
FB
32
33die() {
34 echo $1
35 exit 1
36}
37
58266dd3 38( wget "$serviceurl?owner=$owner&type=$type&url=$3" -O - 2> /dev/null | grep 'blog created' ) || die "Blog creation failed"
0873522c
FB
39
40( cd $rootpath && mkdir $owner ) || die "Can't create the repository for the blog"
41
42cd $owner
3bc366b1 43for i in admin db inc index.php locales plugins themes; do
0873522c
FB
44 ln -s $rootpath/$templatepath/$i || die "Can't add path to $i"
45done
58266dd3 46mkdir -p "$rootpath/$templatepath/public/$owner"
3bc366b1
RB
47chgrp -R "$apache_group" "$rootpath/$templatepath/public/$owner"
48chmod g+wr "$rootpath/$templatepath/public/$owner"
49ln -s $rootpath/$templatepath/public/$owner public
0873522c
FB
50
51( cat <<EOF
58266dd3 52RewriteEngine On
1804b740 53RewriteBase $baseurl
58266dd3
FB
54RewriteCond %{REQUEST_FILENAME} !-f
55RewriteCond %{REQUEST_FILENAME} !-d
56RewriteRule (.*) index.php/\$1
57RewriteRule ^index.php\$ index.php/
0873522c
FB
58SetEnv DC_BLOG_ID $owner
59EOF
60) > .htaccess