aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-04-11 18:45:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-04-11 18:45:51 -0300
commitdeddeb6c9333caeaa09fc7ee3e24fb268faa79d5 (patch)
treec6a94330bde53e6b73603b6a7e3b6307f1064f21 /templates
parentd0499250019785e683b90c09196e7c74e6aa19e2 (diff)
downloadpuppet-ikiwiki-deddeb6c9333caeaa09fc7ee3e24fb268faa79d5.tar.gz
puppet-ikiwiki-deddeb6c9333caeaa09fc7ee3e24fb268faa79d5.tar.bz2
Another major rewrite
Diffstat (limited to 'templates')
-rw-r--r--templates/deploy.sh.erb29
-rw-r--r--templates/refresh.sh.erb19
2 files changed, 35 insertions, 13 deletions
diff --git a/templates/deploy.sh.erb b/templates/deploy.sh.erb
index d971cc1..b851d63 100644
--- a/templates/deploy.sh.erb
+++ b/templates/deploy.sh.erb
@@ -1,19 +1,25 @@
#!/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') %>"
-REPO="$REPO_OWNER@localhost:$NAME"
+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
-fi
-
-if [ ! -e "$CONF/$NAME.setup" ]; then
+elif [ ! -e "$CONF/$NAME.setup" ]; then
echo "No config file for $NAME"
exit 1
fi
@@ -35,6 +41,17 @@ EOF
fi
# Create ikiwiki repository
-ikiwiki-makerepo git $SITE/"$INSTANCE"_src_tmp $SITE/"$INSTANCE"_src
+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
-( cd $SITE/"$INSTANCE"_src && git remote rm origin && git remote add origin $REPO)
diff --git a/templates/refresh.sh.erb b/templates/refresh.sh.erb
index 92c42ca..b5a9bdf 100644
--- a/templates/refresh.sh.erb
+++ b/templates/refresh.sh.erb
@@ -1,37 +1,42 @@
#!/bin/bash
+#
+# Refresh an ikiwiki instance.
+#
+# Parameters
NAME="$1"
WEB_OWNER="$2"
WEB_GROUP="$3"
+WWW_USER="<%= scope.lookupvar('ikiwiki::www_user') %>"
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"
+# Syntax check
if [ -z "$INSTANCE" ]; then
echo "Usage:`basename $0` <site> <instance>"
exit 1
-fi
-
-if [ ! -e "$CONF/$NAME.setup" ]; then
+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 $INSTANCE
+ ikiwiki-deploy $NAME $WEB_OWNER $WEB_GROUP
fi
# Setup
-su $WEB_OWNER -s /bin/bash -c "ikiwiki --setup /etc/ikiwiki/$NAME.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
+chown -R $WEB_OWNER.$WEB_GROUP $SITE/"$INSTANCE"_src $SITE/$INSTANCE
+chown $WEB_OWNER.$WWW_USER $SITE/$INSTANCE/ikiwiki.cgi
+chmod 6550 $SITE/$INSTANCE/ikiwiki.cgi
# Setuid/setgid
chmod 0755 $REPO/hooks/post-update