diff options
-rw-r--r-- | manifests/init.pp | 28 | ||||
-rw-r--r-- | templates/deploy.sh.erb | 13 | ||||
-rw-r--r-- | templates/ikiwiki.setup.erb | 6 |
3 files changed, 31 insertions, 16 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index c024e3e..b2ec307 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -15,7 +15,13 @@ class ikiwiki { mode => 755, } - define instance($base_url = false, $ensure = 'present') { + define instance($base_url = false, $ensure = 'present', $description = false, + $adminuser = 'yourname', $adminemail = 'me@example.org', $instance = 'ikiwiki') { + + $desc = $decription ? { + false => $name, + default => $description, + } $ikiwiki_base = $base_url ? { false => $domain, @@ -38,13 +44,13 @@ class ikiwiki { refreshonly => true, } - exec { "/usr/local/sbin/ikiwiki-deploy $name": - unless => "/bin/sh -c '[ -f ${apache_sites_folder}/${name}/ikiwiki_src/index.mdw ]'", + exec { "/usr/local/sbin/ikiwiki-deploy $name $instance": + unless => "/bin/sh -c '[ -f ${apache_sites_folder}/${name}/${instance}_src/index.mdw ]'", user => root, } - if !defined(File["${apache_sites_folder}/${name}/ikiwiki_src"]) { - file { "${apache_sites_folder}/${name}/ikiwiki_src": + if !defined(File["${apache_sites_folder}/${name}/${instance}_src"]) { + file { "${apache_sites_folder}/${name}/${instance}_src": ensure => directory, owner => gitosis, group => gitosis, @@ -54,8 +60,8 @@ class ikiwiki { } } - if !defined(File["${apache_sites_folder}/${name}/ikiwiki"]) { - file { "${apache_sites_folder}/${name}/ikiwiki": + if !defined(File["${apache_sites_folder}/${name}/${instance}"]) { + file { "${apache_sites_folder}/${name}/${instance}": ensure => directory, owner => gitosis, group => gitosis, @@ -71,6 +77,14 @@ class ikiwiki { group => root, } } + + file { "${apache_sites_folder}/${name}/${instance}_src/.ikiwiki": + ensure => directory, + owner => www-data, + group => www-data, + recurse => true, + require => File["${apache_sites_folder}/${name}/${instance}_src"], + } } } } diff --git a/templates/deploy.sh.erb b/templates/deploy.sh.erb index 66c0f10..69785d0 100644 --- a/templates/deploy.sh.erb +++ b/templates/deploy.sh.erb @@ -1,14 +1,15 @@ #!/bin/bash NAME="$1" +INSTANCE="$2" BASE="<%= apache_sites_folder %>" SITE=$BASE/$NAME CONF="/etc/ikiwiki" OWNER="gitosis" GROUP="gitosis" -if [ -z "$NAME" ]; then - echo "Usage:`basename $0` <site>" +if [ -z "$INSTANCE" ]; then + echo "Usage:`basename $0` <site> <instance>" fi if [ ! -e "$CONF/$NAME" ]; then @@ -16,10 +17,10 @@ if [ ! -e "$CONF/$NAME" ]; then fi # Setup source folder -mkdir -p $SITE/ikiwiki_src/ +mkdir -p $SITE/"$INSTANCE"_src/ # Create initial page -echo > $SITE/ikiwiki_src/index.mdw <<EOF +echo > $SITE/"$INSTANCE"_src/index.mdw <<EOF Welcome to your new wiki. All wikis are supposed to have a [[SandBox]], so this one does too. @@ -30,10 +31,10 @@ This wiki is powered by [ikiwiki](http://ikiwiki.info). EOF # Create ikiwiki instance -ikiwiki-makerepo git $SITE/ikiwiki_src/ /var/git/repositories/$NAME.git +ikiwiki-makerepo git $SITE/"$INSTANCE"_src/ /var/git/repositories/$NAME.git touch /var/git/repositories/$NAME.git/git-daemon-export-ok ( cd /var/git/repositories/$NAME.git && git --bare update-server-info ) ikiwiki --setup /etc/ikiwiki/$NAME.setup # Set permissions -chown -R $OWNER.$GROUP $SITE/ikiwiki_src $SITE/ikiwiki /var/git/repositories/$NAME.git +chown -R $OWNER.$GROUP $SITE/"$INSTANCE"_src $SITE/$INSTANCE /var/git/repositories/$NAME.git diff --git a/templates/ikiwiki.setup.erb b/templates/ikiwiki.setup.erb index c42a7e3..dae8047 100644 --- a/templates/ikiwiki.setup.erb +++ b/templates/ikiwiki.setup.erb @@ -6,9 +6,9 @@ # Remember to re-run ikiwiki --setup any time you edit this file. use IkiWiki::Setup::Standard { - wikiname => "<%= name %>", - #adminuser => ["yourname", ], - adminemail => 'me@example.org', + wikiname => "<%= desc %>", + adminuser => ["<%= adminuser %>", ], + adminemail => '<%= adminemail %>', # Be sure to customise these.. srcdir => "<%= apache_sites_folder %>/<%= name %>/ikiwiki_src", |