From 2d5cfed24a7b15c900a9ab45c129653a0c926add Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 3 Oct 2012 18:09:23 -0400 Subject: [PATCH] add a clear squid cache and clean a few things up --- .../additional-modules/god/manifests/init.pp | 2 +- .../squid/manifests/init.pp | 5 +++++ .../squid/templates/clear-squid-cache | 20 +++++++++++++++++++ .../additional-modules/tc/templates/tc-init.d | 4 ++-- shared/modules/remotedeb/manifests/init.pp | 2 +- skel/apply.erb | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 shared/additional-modules/squid/templates/clear-squid-cache diff --git a/shared/additional-modules/god/manifests/init.pp b/shared/additional-modules/god/manifests/init.pp index 2c461b7..932b82f 100644 --- a/shared/additional-modules/god/manifests/init.pp +++ b/shared/additional-modules/god/manifests/init.pp @@ -5,7 +5,7 @@ class god { require => Class['ruby'] } - $bin = "${ruby::path}//god" + $bin = "${ruby::path}/god" $dir = config_path("god.d") $pid = pid_path($name) $log = log_path($name) diff --git a/shared/additional-modules/squid/manifests/init.pp b/shared/additional-modules/squid/manifests/init.pp index b738fb5..1c8ee9d 100644 --- a/shared/additional-modules/squid/manifests/init.pp +++ b/shared/additional-modules/squid/manifests/init.pp @@ -72,6 +72,11 @@ class squid($version = '', $user = 'proxy', $group = 'proxy', $config_template, path => $::base::path } + file { "${sbin}/clear-squid-cache": + content => template('squid/clear-squid-cache'), + mode => 0755 + } + exec { 'cache_dir_perms_again': command => "chown -R ${user}:${group} ${cache_dir}", path => $::base::path, diff --git a/shared/additional-modules/squid/templates/clear-squid-cache b/shared/additional-modules/squid/templates/clear-squid-cache new file mode 100644 index 0000000..ad1fa95 --- /dev/null +++ b/shared/additional-modules/squid/templates/clear-squid-cache @@ -0,0 +1,20 @@ +#!/bin/bash + +target="<%= @cache_dir %>$(date +%Y%m%d%H%M%S)" + +if [ $UID -ne 0 ]; then + sudo $0 + exit +fi + +god stop squid +while [ "$(pgrep squid3 | wc -l)" -ne 0 ]; do + sleep 1 +done + +mv <%= @cache_dir %> "$target" +mkdir <%= @cache_dir %> +chown -R <%= @user %>:<%= @group %> <%= @cache_dir %> +squid3 -z +god start squid +rm -Rf "$target" diff --git a/shared/additional-modules/tc/templates/tc-init.d b/shared/additional-modules/tc/templates/tc-init.d index 9cd1f58..7b5d32d 100644 --- a/shared/additional-modules/tc/templates/tc-init.d +++ b/shared/additional-modules/tc/templates/tc-init.d @@ -1,4 +1,4 @@ -<%= scope.function_template('base/init-d-header') %> +<%= scope.function_template([ 'base/init-d-header' ]) %> <%= init_d_prolog %> <%= init_d_prerun %> @@ -19,5 +19,5 @@ stop() { echo "done" } -<%= scope.function_template('base/init-d-actions') %> +<%= scope.function_template([ 'base/init-d-actions' ]) %> diff --git a/shared/modules/remotedeb/manifests/init.pp b/shared/modules/remotedeb/manifests/init.pp index 270ec45..ba5b220 100644 --- a/shared/modules/remotedeb/manifests/init.pp +++ b/shared/modules/remotedeb/manifests/init.pp @@ -3,7 +3,7 @@ define remotedeb($url, $version) { exec { "remotedeb-${name}": command => "curl -o ${deb} ${url} && dpkg -i ${deb}", - unless => "test $(dpkg -l ${name} | grep ${version} | wc -l) -eq 0", + unless => "test $(dpkg -l ${name} | grep ${version} | wc -l) -ne 0", path => $base::path } } diff --git a/skel/apply.erb b/skel/apply.erb index 3d83096..f3c5f9d 100644 --- a/skel/apply.erb +++ b/skel/apply.erb @@ -7,6 +7,6 @@ RUBYLIB="${PWD}/lib:${PWD}/shared/lib" \ --confdir=$PWD \ --modulepath=$PWD/modules:$PWD/shared/modules:$PWD/shared/additional-modules \ --templatedir=$PWD/shared/templates:$PWD/templates \ - -v $@ \ + -v --no-report $@ \ manifests/site.pp