#!/bin/bash #.Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//log/logrotate_/THIS!0.!c # #/*************************************************************************** # log logrotate_ THIS # +++++++++++++++++++ # # purpose : logrotate-functions # # begin : Wed Nov 12 19:18:47 CEST 2014 # # changes : - # # copyright : (C) 2014 by Thomas Bruecker # # email : public@thomas-r-bruecker.ch # # version : 0.0.0 # #***************************************************************************/ #/*************************************************************************** # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU General Public License as published by * # * the Free Software Foundation; either version 2 of the License, or * # * (at your option) any later version. * # * * # * This program is distributed in the hope that it will be useful, but * # * WITHOUT ANY WARRANTY; without even the implied warranty of * # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * # * General Public License for more details. * # * * # * You should have received a copy of the GNU General Public License * # * along with this program; if not, write to the Free Software * # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * # * MA 02110-1301 USA. * # * * # ***************************************************************************/ # MyHash('linux//log/logrotate_/THIS') = 0x0D18 # # * for every function: # * if returned result is not commented, the function returns "true" (0) on # no-error. # globals: Copyright0x0D18='Copyright (C) 2014 by Thomas Bruecker,' Copyright0x0D18="$Copyright0x0D18 " MainPath0x0D18='/var/run/logrotate.d' SCRIPTS='usr/local/bin' ThisPath0x0D18="/${SCRIPTS}/log/logrotate_/THIS" Title0x0D18='logrotate-functions' Version0x0D18='Version 0.0.0' . /$SCRIPTS/io/f_/THIS logrotate_() { # prints information to stdout. local Information # introduction: Information="\nTo learn more about \"$ThisPath0x0D18\", read the following" Information="${Information} contents of that\nfile:\n\n" # + file contents: Information="${Information}Contents of \"$ThisPath0x0D18\":\n\n" Information="${Information}$(cat $ThisPath0x0D18)" echo -e "$Information" | less } logrotate_-v() { # prints version-information to stdout. echo "$Title0x0D18, $Version0x0D18" echo $Copyright0x0D18 } # Concept: # * "logrotate_Announce(service-name, part-name)" puts a 'building-block for # the part of the service' (e.g. http-domain) 'on the table for that # service'; # # * "logrotate__Acknowledge(service-name, part-name, command, arguments for # command)" removes a 'building-block for the part of the service' # (e.g. http-domain) 'from the table for that service' -- # if 'the table is empty', the command with the arguments is executed; # # * 'table for the service': folder "/var/run/logrotate.d/"; # * 'building-block for the part of the service': # empty file "/var/run/logrotate.d//". logrotate_Acknowledge() { # * $1 : service-name, # * $2 : part-name, # * $3 : command; # * $4 ... : arguments for command /${SCRIPTS}/LogRotate_ _Acknowledge "$@" & # here: "$PATH" == "/sbin:/bin:/usr/sbin:/usr/bin", so "/usr/local/bin" is # missing --> use full path! } logrotate__Acknowledge() { # * $1 : service-name, # * $2 : part-name, # * $3 : command; # * $4 ... : arguments for command local Command PartName PartPath ServiceName ServicePath Command="$3" PartName="$2" ServiceName="$1" shift 3 PartPath="$(logrotate__Part2Path "$ServiceName" "$PartName")" ServicePath="$(logrotate__Service2Path "$ServiceName")" sleep 10m # wait until Announcing has finished! rm -f "$PartPath" if f_isFolderEmtpy "$ServicePath"; then "$Command" "$@" fi } logrotate_Announce() { # * $1 : service-name, # * $2 : part-name; local PartName ServiceName PartName="$2" ServiceName="$1" touch "$(logrotate__Part2Path "$ServiceName" "$PartName")" } logrotate__Part2Path() { # * $1 : service-name, # * $2 : part-name; # * prints according path to stdout. local PartName ServiceName PartName="$2" ServiceName="$1" echo "$(logrotate__Service2Path "$ServiceName")/$PartName" } logrotate__Service2Path() { # * $1 : service-name; # * prints according path to stdout. local ServiceName ServiceName="$1" echo "${MainPath0x0D18}/${ServiceName}" }