]> gitweb.fluxo.info Git - puppet-ikiwiki.git/commitdiff
Another major rewrite
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 11 Apr 2013 21:45:51 +0000 (18:45 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 11 Apr 2013 21:45:51 +0000 (18:45 -0300)
manifests/instance.pp
templates/deploy.sh.erb
templates/refresh.sh.erb

index 8b4e13ff575ebd4985d54f47a7784449eb04f89c..5dee2fdf71122dc587fbedefbfffaa28365f1a05 100644 (file)
@@ -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,
+          }
         }
       }
 
index d971cc14f4a7d98bd5e0d92653ce1c1adc4d1226..b851d632a18caf7a307f222faf41f3ac654928aa 100644 (file)
@@ -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)
index 92c42cace95698b10010898b7bf3b918820d34a3..b5a9bdf5df169202e29f120e4e4e9a8c34ced0f6 100644 (file)
@@ -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