| 1 | #!/bin/sh -x |
| 2 | |
| 3 | # Usage: |
| 4 | # ./createBlog.sh type owner baseurl |
| 5 | # type = user | connected | group-member | group-admin |
| 6 | # * user: this is a blog for a user |
| 7 | # * connected: this is a blog for a group, all connected users can post |
| 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) |
| 13 | # url = full url of the blog (e.g http://group.blog-x.org/). |
| 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 |
| 17 | # http://$owner.base.url/ |
| 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 | |
| 25 | type=$1 |
| 26 | owner=$2 |
| 27 | url=$3 |
| 28 | apache_group=www-data |
| 29 | rootpath=/home/web/blogs |
| 30 | templatepath=dotclear |
| 31 | baseurl=/ |
| 32 | serviceurl="http://blog.polytechnique.org/xorgservice/createBlog" |
| 33 | |
| 34 | die() { |
| 35 | echo $1 |
| 36 | exit 1 |
| 37 | } |
| 38 | |
| 39 | ( wget "$serviceurl?owner=$owner&type=$type&url=$3" -O - 2> /dev/null | grep 'blog created' ) || die "Blog creation failed" |
| 40 | |
| 41 | ( cd $rootpath && mkdir $owner ) || die "Can't create the repository for the blog" |
| 42 | |
| 43 | cd $owner |
| 44 | for i in admin db inc index.php locales plugins themes; do |
| 45 | ln -s $rootpath/$templatepath/$i || die "Can't add path to $i" |
| 46 | done |
| 47 | mkdir -p "$rootpath/$templatepath/public/$owner" |
| 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 |
| 51 | |
| 52 | ( cat <<EOF |
| 53 | RewriteEngine On |
| 54 | RewriteBase $baseurl |
| 55 | RewriteCond %{REQUEST_FILENAME} !-f |
| 56 | RewriteCond %{REQUEST_FILENAME} !-d |
| 57 | RewriteRule (.*) index.php/\$1 |
| 58 | RewriteRule ^index.php\$ index.php/ |
| 59 | SetEnv DC_BLOG_ID $owner |
| 60 | EOF |
| 61 | ) > .htaccess |