Index: script/munin-check
--- script/munin-check.orig
+++ script/munin-check
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@@GOODSH@@
 # Copyright (C) 2008 Matthias Schmitz
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -18,13 +18,13 @@
 
 ####
 # prints usage
-function usage() {
+function usage {
     echo "Usage: munin-check [options]
 Options:
-   -h|--help             Show this help.
-   -v|--verbose          Be verbose.
-   -f|--fix-permissions  Fix the permissions of the munin dirs and files.
-                         Needs superuser rights.
+   -h	Show this help.
+   -v	Be verbose.
+   -f	Fix the permissions of the munin dirs and files.
+	Needs superuser rights.
 
 Please don't use this script if you are using 'graph_strategy cgi'!
 It doesn't care about the right permissions for www-data yet...
@@ -32,7 +32,7 @@ It doesn't care about the right permissions for www-da
 }
 
 # Get options from the command line
-TEMP=$(getopt -o fhv --long fix-permissions,help,verbose -n 'munin-check' -- "$@")
+TEMP=$(getopt fhv $*)
 
 # shellcheck disable=SC2181
 if [[ $? -ne 0 ]]; then
@@ -47,16 +47,16 @@ PLEASE_FIXME="false"
 VERBOSE="false"
 while :; do
     case "$1" in
-        -h|--help) usage ; exit 0; shift ;;
-        -v|--verbose) VERBOSE="true"; shift;;
-        -f|--fix-permissions) PLEASE_FIXME="true" ;  shift ;;
+        -h usage ; exit 0; shift ;;
+        -v VERBOSE="true"; shift;;
+        -f PLEASE_FIXME="true" ;  shift ;;
         --) shift ; break ;;
         *) echo "Internal error!" ; exit 1 ;;
     esac
 done
 
 
-function msg_info() {
+function msg_info {
     local message="$1"
     if [ "$VERBOSE" = "true" ]; then
         echo "$message"
@@ -66,7 +66,7 @@ function msg_info() {
 
 ####
 # sets owner to "@@USER@@"
-function fix_owner() {
+function fix_owner {
     fix_object=$1; shift
     fix_owner=$1; shift
 
@@ -85,7 +85,7 @@ function fix_owner() {
 
 ####
 # check if "@@USER@@" is owner, if PLEASE_FIXME set it calls fix_owner()
-function owner_ok() {
+function owner_ok {
     object=$1; shift || exit 1
     correctowner=$1; shift || exit 1
 
@@ -107,6 +107,11 @@ function owner_ok() {
             "lost+found") return 0;;
         esac
 
+       # cgi-tmp owner should be www
+       case $object in
+           "cgi-tmp") correctowner=www;
+       esac
+
         # ... and then dive into it
         for subobject in "$object"/*; do
             owner_ok "$subobject" "$correctowner"
@@ -115,7 +120,7 @@ function owner_ok() {
 }
 
 
-function perm_ok(){
+function perm_ok {
     object=$1; shift || exit 1
     correctperm=$1; shift || exit 1
 
@@ -162,12 +167,20 @@ for dir in "@@DBDIR@@"/*; do
         */plugin-state)
             continue;;
     esac
+    case $dir in
+       */cgi-tmp)
+           continue;;
+    esac
     echo "check $dir"
     owner_ok "$dir" "@@USER@@"
 done
 
+echo "check @@DBDIR@@/cgi-tmp"
+owner_ok @@DBDIR@@/cgi-tmp www
+
 echo "check miscellaneous"
-norec=yes owner_ok @@LOGDIR@@ @@USER@@
+norec=yes owner_ok @@LOGDIR@@ @@PLUGINUSER@@
+norec=yes perm_ok @@LOGDIR@@ 775
 
 norec=yes owner_ok "@@DBDIR@@" "@@USER@@"
 norec=yes perm_ok "@@DBDIR@@" 755
