aboutsummaryrefslogtreecommitdiff
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
parentd0499250019785e683b90c09196e7c74e6aa19e2 (diff)
downloadpuppet-ikiwiki-deddeb6c9333caeaa09fc7ee3e24fb268faa79d5.tar.gz
puppet-ikiwiki-deddeb6c9333caeaa09fc7ee3e24fb268faa79d5.tar.bz2
Another major rewrite
-rw-r--r--manifests/instance.pp29
-rw-r--r--templates/deploy.sh.erb29
-rw-r--r--templates/refresh.sh.erb19
3 files changed, 51 insertions, 26 deletions
diff --git a/manifests/instance.pp b/manifests/instance.pp
index 8b4e13f..5dee2fd 100644
--- a/manifests/instance.pp
+++ b/manifests/instance.pp
@@ -10,7 +10,8 @@ define ikiwiki::instance(
$protocol = 'https',
$owner = $name,
$group = $name,
- $home = "/home/$owner"
+ $home = "/home/$owner",
+ $create_ssh_key = false
) {
$desc = $description ? {
@@ -67,20 +68,22 @@ define ikiwiki::instance(
}
}
- if !defined(File["${home}/.ssh"]) {
- file { "${home}/.ssh":
- ensure => directory,
- owner => $owner,
- group => $group,
- mode => 0700,
+ if $create_ssh_key == true {
+ if !defined(File["${home}/.ssh"]) {
+ file { "${home}/.ssh":
+ ensure => directory,
+ owner => $owner,
+ group => $group,
+ mode => 0700,
+ }
}
- }
- if !defined(File["${ikiwiki::sites_folder}/${name}"]) {
- file { "${ikiwiki::sites_folder}/${name}":
- ensure => directory,
- owner => root,
- group => root,
+ if !defined(File["${ikiwiki::sites_folder}/${name}"]) {
+ file { "${ikiwiki::sites_folder}/${name}":
+ ensure => directory,
+ owner => root,
+ group => root,
+ }
}
}
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