Commit | Line | Data |
---|---|---|
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 |
25 | type=$1 |
26 | owner=$2 | |
27 | url=$3 | |
28 | apache_group=www-data | |
3bc366b1 | 29 | rootpath=/home/web/blogs |
0873522c | 30 | templatepath=dotclear |
3bc366b1 RB |
31 | baseurl=/ |
32 | serviceurl="http://blog.polytechnique.org/xorgservice/createBlog" | |
0873522c FB |
33 | |
34 | die() { | |
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 | ||
43 | cd $owner | |
3bc366b1 | 44 | for 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" |
46 | done | |
58266dd3 | 47 | mkdir -p "$rootpath/$templatepath/public/$owner" |
3bc366b1 RB |
48 | chgrp -R "$apache_group" "$rootpath/$templatepath/public/$owner" |
49 | chmod g+wr "$rootpath/$templatepath/public/$owner" | |
50 | ln -s $rootpath/$templatepath/public/$owner public | |
0873522c FB |
51 | |
52 | ( cat <<EOF | |
58266dd3 | 53 | RewriteEngine On |
1804b740 | 54 | RewriteBase $baseurl |
58266dd3 FB |
55 | RewriteCond %{REQUEST_FILENAME} !-f |
56 | RewriteCond %{REQUEST_FILENAME} !-d | |
57 | RewriteRule (.*) index.php/\$1 | |
58 | RewriteRule ^index.php\$ index.php/ | |
0873522c FB |
59 | SetEnv DC_BLOG_ID $owner |
60 | EOF | |
61 | ) > .htaccess |