diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-06-28 13:54:03 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-06-28 13:54:03 -0300 |
commit | e07ac81ce5229ec61b18b428547a4f8404c3bff4 (patch) | |
tree | ae20517f939bedfd4746a0e6590666b049f1bf92 | |
parent | a233e6b7fa79567ff30b43511e8ee847a883b36a (diff) | |
download | puppet-pmwiki-e07ac81ce5229ec61b18b428547a4f8404c3bff4.tar.gz puppet-pmwiki-e07ac81ce5229ec61b18b428547a4f8404c3bff4.tar.bz2 |
Adding pmwiki install command
-rw-r--r-- | manifests/init.pp | 1 | ||||
-rw-r--r-- | templates/pmwiki.sh.erb | 58 |
2 files changed, 57 insertions, 2 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index 3d06613..2c6ddac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,5 @@ class pmwiki( + $sites_folder = '/var/sites', $www_folder = '/var/www/data' ) { diff --git a/templates/pmwiki.sh.erb b/templates/pmwiki.sh.erb index 204916e..d16088c 100644 --- a/templates/pmwiki.sh.erb +++ b/templates/pmwiki.sh.erb @@ -3,6 +3,7 @@ # pmwiki management script. # +SITES="<%= scope.lookupvar('pmwiki::sites_folder') %>" BASE="<%= scope.lookupvar('pmwiki::www_folder') %>" # Check for existing installations @@ -38,7 +39,7 @@ function pmwiki_deploy { chown -R root.root pmwiki-$new/ } -# Upgrade a pmwiki instance using upstream source. +# Upgrade a pmwiki instance using upstream source function pmwiki_upgrade { if [ "$#" != "2" ]; then echo "Usage: `basename $0` upgrade <old_version> <new_version>" @@ -83,9 +84,59 @@ function pmwiki_upgrade { echo "Check procedure and remove pmwiki-$old once you make sure that everything is fine." } +# Install a pmwiki instance +function pmwiki_install { + local site="$1" + + if [ -z "$site" ]; then + echo "Usage: `basename $0` install <name>" + exit 1 + fi + + if [ ! -d "$BASE/wiki" ]; then + echo "Please deploy pmwiki first" + exit 1 + fi + + if [ ! -d "$SITES/$site" ]; then + echo "Please configure site $site first" + exit 1 + fi + + if [ -e "$SITES/$site/wiki/field.php" ]; then + echo "Looks like $site wiki is already installed" + exit 1 + fi + + mkdir -p $SITES/$site/wiki + echo '<?php include("/var/www/data/wiki/pmwiki.php"); ?>' > $SITES/$site/wiki/field.php + + echo > $SITES/$site/wiki/.htaccess <<-EOF +Options +FollowSymLinks +RewriteEngine on +RewriteRule ^/?$ https://$site.<%= ::domain %>/Main/HomePage [R=permanent,QSA,L] +RewriteRule ^([^/a-z].*) field.php?n=$1 [QSA,L] +EOF + + echo > $SITES/$site/wiki/local/config.php <<-EOF +<?php if (!defined('PmWiki')) exit(); + +$ScriptUrl = "https://$site.<%= ::domain %>"; +$EnablePathInfo = 1; +EOF + + ( + cd $SITES/$site/wiki + ln -s field.php index.php + mkdir -p local uploads wiki.d cookbook + chown $site. wiki.d + chown root.$site local/config.php + ) +} + # Main procedure if [ -z "$1" ]; then - echo "Usage: `basename $0` <deploy|upgrade> [arguments]" + echo "Usage: `basename $0` <deploy|upgrade|install> [arguments]" exit 1 elif [ "$1" == "deploy" ]; then shift @@ -93,4 +144,7 @@ elif [ "$1" == "deploy" ]; then elif [ "$1" == "upgrade" ]; then shift pmwiki_upgrade $* +elif [ "$1" == "install" ]; then + shift + pmwiki_install $* fi |