aboutsummaryrefslogtreecommitdiff
path: root/templates/refresh.sh.erb
blob: 41b52967652f2f04a995dd099a0b294bfe37a954 (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
#!/bin/bash

NAME="$1"
INSTANCE="$2"
WEB_OWNER="$3"
WEB_GROUP="$4"
BASE="<%= scope.lookupvar('ikiwiki::sites_folder') %>"
SITE="$BASE/$NAME"
CONF="/etc/ikiwiki"
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

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

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

# Fix permissions
chown -R $REPO_OWNER.$REPO_GROUP $REPO
chown -R $WEB_OWNER.$WEB_GROUP $SITE/"$INSTANCE"_src $SITE/$INSTANCE

# Setuid/setgid
chmod 0755 $REPO/hooks/post-update
chmod 0550 $SITE/$INSTANCE/ikiwiki.cgi