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/).
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).
29 echo "Usage: $0 -t TYPE -o OWNER -u URL
32 TYPE = user | connected | group-member | group-admin is the type of the blog
33 OWNER if the owner of the blog (user hruid or group diminutif)
34 URL is the URL of the blog
47 TEMP
=`getopt -n $0 -o ht:o:u: -- "$@"`
51 if [ $RET != 0 ]; then
69 if [[ "${TYPE}" != "user" && "${TYPE}" != "group-member" && "${TYPE}" != "group-admin" && "${TYPE}" != "connected" ]]; then
70 echo -e
"ERROR: TYPE must be one of: user | group-member | group-admin | connected\n";
81 if ! echo "${URL}" |
grep -E
"^https?://[^/]+/" > /dev
/null
; then
82 echo -e
"ERROR: URL must be a full URL, e.g 'http://www.example.org/'\n";
92 echo -e
"ERROR: Invalid argument '$1'\n"
98 if [[ "x${TYPE}" == "x" ||
"x${OWNER}" == "x" ||
"x${URL}" == "x" ]]; then
99 echo -e
"ERROR: Missing one of -t, -o or -u options.\n"
103 BASEURL
=`echo "${URL}" | sed -r 's,https?://[^/]+/,/,'`
105 echo "Creating blog with :
112 apache_group
=www-data
113 rootpath
=/home
/web
/blogs
114 templatepath
=dotclear
116 serviceurl
="http://blog.polytechnique.org/xorgservice/createBlog"
118 CALLED
="$serviceurl?owner=${OWNER}&type=${TYPE}&url=${URL}&baseurl=${BASEURL}"
119 echo "Calling $CALLED"
120 ( wget
"$CALLED" -O
- 2> /dev
/null |
grep 'blog created' ) || die
"Blog creation failed"
122 ( cd $rootpath && mkdir
-p
$OWNER ) || die
"Can't create the repository for the blog ($rootpath/$OWNER)"
125 for i
in admin db inc index.php locales plugins themes
; do
126 ln -s
$rootpath/$templatepath/$i || die
"Can't add path to $i"
128 mkdir
-p
"$rootpath/$templatepath/public/$OWNER"
129 chgrp
-R
"$apache_group" "$rootpath/$templatepath/public/$OWNER"
130 chmod g
+wr
"$rootpath/$templatepath/public/$OWNER"
131 ln -s
$rootpath/$templatepath/public
/$OWNER public
135 RewriteBase ${BASEURL}
136 RewriteCond %{REQUEST_FILENAME} !-f
137 RewriteCond %{REQUEST_FILENAME} !-d
138 RewriteRule (.*) index.php/\$1
139 RewriteRule ^index.php\$ index.php/
140 SetEnv DC_BLOG_ID $OWNER