4 # ./createBlog.sh type owner
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/).
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/
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/
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).
25 # The blog will be created at :
27 # It will be available at
28 # http://dev.blog-x.org/~$USER/$owner
33 echo "Usage: $0 -t TYPE -o OWNER
36 TYPE = user | connected | group-member | group-admin is the type of the blog
37 OWNER if the owner of the blog (user hruid or group diminutif)
50 TEMP
=`getopt -n $0 -o ht:o: -- "$@"`
54 if [ $RET != 0 ]; then
71 if [[ "${TYPE}" != "user" && "${TYPE}" != "group-member" && "${TYPE}" != "group-admin" && "${TYPE}" != "connected" ]]; then
72 echo -e
"ERROR: TYPE must be one of: user | group-member | group-admin | connected\n";
86 echo -e
"ERROR: Invalid argument '$1'\n"
92 if [[ "x${TYPE}" == "x" ||
"x${OWNER}" == "x" ]]; then
93 echo -e
"ERROR: Missing one of -t or -o options.\n"
97 URL
="http://dev.blog-x.org/~${USER}/${OWNER}/"
98 BASEURL
=`echo "${URL}" | sed -r 's,http://[^/]+/,/,'`
100 echo "Creating blog with :
107 apache_group
=www-data
108 rootpath
=${HOME}/dev
/blogs
/
109 templatepath
=dotclear
111 serviceurl
="http://dev.blog-x.org/default/xorgservice/createBlog"
113 CALLED
="$serviceurl?owner=${OWNER}&type=${TYPE}&url=${URL}&baseurl=${BASEURL}"
114 echo "Calling $CALLED"
115 ( wget
"$CALLED" -O
- 2> /dev
/null |
grep 'blog created' ) || die
"Blog creation failed"
117 ( cd $rootpath && mkdir
-p
$OWNER ) || die
"Can't create the repository for the blog ($rootpath/$OWNER)"
120 for i
in admin db inc index.php locales plugins themes
; do
121 ln -s
$rootpath/$templatepath/$i || die
"Can't add path to $i"
123 mkdir
-p
"$rootpath/$templatepath/public/$OWNER"
124 chgrp
-R
"$apache_group" "$rootpath/$templatepath/public/$OWNER"
125 chmod g
+wr
"$rootpath/$templatepath/public/$OWNER"
126 ln -s
$rootpath/$templatepath/public
/$OWNER public
130 RewriteBase ${BASEURL}
131 RewriteCond %{REQUEST_FILENAME} !-f
132 RewriteCond %{REQUEST_FILENAME} !-d
133 RewriteRule (.*) index.php/\$1
134 RewriteRule ^index.php\$ index.php/
135 SetEnv DC_BLOG_ID $OWNER