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