aboutsummaryrefslogtreecommitdiff
path: root/templates/refresh.sh.erb
blob: 92c42cace95698b10010898b7bf3b918820d34a3 (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"
WEB_OWNER="$2"
WEB_GROUP="$3"
BASE="<%= scope.lookupvar('ikiwiki::sites_folder') %>"
SITE="$BASE/$NAME"
CONF="/etc/ikiwiki"
INSTANCE="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
su $WEB_OWNER -s /bin/bash -c "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