aboutsummaryrefslogtreecommitdiff
path: root/templates/deploy.sh.erb
blob: 86150aa3f5810cd99505df3fd7bb0c1a3bcad492 (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
48
#!/bin/bash

NAME="$1"
INSTANCE="$2"
BASE="<%= scope.lookupvar('ikiwiki::sites_folder') %>"
SITE=$BASE/$NAME
CONF="/etc/ikiwiki"
WEB_OWNER="www-data"
WEB_GROUP="www-data"
REPO_OWNER="<%= scope.lookupvar('ikiwiki:git_implementation') %>"
REPO_GROUP="<%= scope.lookupvar('ikiwiki:git_implementation') %>"
REPO="/var/git/repositories/$NAME.git"

if [ -z "$INSTANCE" ]; then
  echo "Usage:`basename $0` <site> <instance>"
  exit 1
fi

if [ ! -e "$CONF/$NAME.setup" ]; then
  echo "No config file for $NAME"
  exit 1
fi

# Setup source folder
mkdir -p $SITE/"$INSTANCE"_src/

# Create initial page
if [ ! -e $SITE/"$INSTANCE"_src/index.mdwn ]; then
  echo > $SITE/"$INSTANCE"_src/index.mdwn <<EOF
Welcome to your new wiki.

All wikis are supposed to have a [[SandBox]], so this one does too.

----

This wiki is powered by [ikiwiki](http://ikiwiki.info).
EOF
fi

# Create ikiwiki instance
if [ ! -d "$REPO" ]; then
  ikiwiki-makerepo git $SITE/"$INSTANCE"_src/ $REPO
  touch $REPO/git-daemon-export-ok
  ( cd $REPO/$NAME.git && git --bare update-server-info )
fi

# Refresh the instance
ikiwiki-refresh $NAME $INSTANCE