blob: 80b1b36d4bca258608191c3f0dba38552005cd7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/bash
#
# Deploy an ikiwiki instance.
#
# Parameters
NAME="$1"
WEB_OWNER="$2"
WEB_GROUP="$3"
INSTANCE="ikiwiki"
BASE="<%= scope.lookupvar('ikiwiki::sites_folder') %>"
SITE=$BASE/$NAME
CONF="/etc/ikiwiki"
REPO_OWNER="<%= scope.lookupvar('ikiwiki::git_implementation') %>"
REMOTE="$REPO_OWNER@localhost:$NAME"
REPO="/var/git/repositories/$NAME.git"
# Syntax check
if [ -z "$INSTANCE" ]; then
echo "Usage:`basename $0` <site> <instance>"
exit 1
elif [ ! -e "$CONF/$NAME.setup" ]; then
echo "No config file for $NAME"
exit 1
fi
# Setup source folder
mkdir -p $SITE/"$INSTANCE"_src_tmp/
# Create initial page
echo "Welcome to your new wiki powered by [ikiwiki](http://ikiwiki.info)." > $SITE/"$INSTANCE"_src_tmp/index.mdwn
# Create ikiwiki repository
ikiwiki-makerepo git $SITE/"$INSTANCE"_src_tmp $REPO
# Clone it again
git clone $REPO $SITE/"$INSTANCE"_src
# Fix remotes
( cd $SITE/"$INSTANCE"_src && git remote rm origin && git remote add origin $REMOTE )
# Fix permissions
chown $REPO_OWNER. $REPO
chown $WEB_OWNER.$WEB_GROUP $SITE/"$INSTANCE"_src
# Cleanup
rm -rf $SITE/"$INSTANCE"_src_tmp
|