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