aboutsummaryrefslogtreecommitdiff
path: root/templates/refresh.sh.erb
blob: fea8e1496d7e4870a3985426917581926d4aa76c (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
#!/bin/bash
#
# Refresh an ikiwiki instance.
#

# Parameters
NAME="$1"
OWNER="$2"
GROUP="$3"
CONF="/etc/ikiwiki"
INSTANCE="ikiwiki"
WWW_USER="<%= scope.lookupvar('ikiwiki::www_user') %>"
BASE="<%= scope.lookupvar('ikiwiki::sites_folder') %>"
REPO_OWNER="<%= scope.lookupvar('ikiwiki::git_implementation') %>"
REPO_GROUP="<%= scope.lookupvar('ikiwiki::git_implementation') %>"
REPO="<%= scope.lookupvar('ikiwiki::git_folder') %>/$NAME.git"
SITE="$BASE/$NAME"

# 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

# Deploy if needed
if [ ! -d "$REPO" ]; then
  ikiwiki-deploy $NAME $OWNER $GROUP
fi

# Setup
ikiwiki --setup /etc/ikiwiki/$NAME.setup

# Fix permissions
chown -R $REPO_OWNER.    $REPO
chown -R $OWNER.$GROUP   $SITE/"$INSTANCE"_src $SITE/$INSTANCE
chown $OWNER.$WWW_USER   $SITE/$INSTANCE/ikiwiki.cgi
chmod 6550               $SITE/$INSTANCE/ikiwiki.cgi
chown $OWNER.$REPO_OWNER $REPO/hooks/post-update
chmod 6550               $REPO/hooks/post-update