From: b Date: Thu, 22 Feb 2024 21:55:14 +0000 (+0000) Subject: update config; drop unneeded oldlogs.1.pl X-Git-Tag: v1.2.8~2 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=ce8c74462bad0dd3debab629b4c391af08670af5;p=ott%2Fbsta update config; drop unneeded oldlogs.1.pl --- diff --git a/config b/config index cc70d0d..fc9affe 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit cc70d0da5dd780e2b7b97672cc0638fd91196ee3 +Subproject commit fc9affec336a16cde93b2675a836bdd01d1c2210 diff --git a/makefile b/makefile index f3a12cd..e0608ae 100644 --- a/makefile +++ b/makefile @@ -48,7 +48,7 @@ CONFIGFILE = settings-$(TARGET).txt settings.txt DEFAULT_CONFIGFILE = settings-$(DEFAULT_TARGET).txt settings.txt # The configuration tool -CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE) +CONFIGURE_CMD = $(PERL) ./configure.pl --do $(CONFIGFILE) # keep these 2 lists in the same order!: GENERATE_FROM=\ @@ -156,13 +156,13 @@ makefile: makefile.1.mak $(CONFIGFILE) configure.pl $(CONFIGURE_CMD) < makefile.1.mak > makefile configure.pl: $(CONFIGFILE) config/configure.1.pl - $(PERL) config/configure.1.pl target=direct settings-$(TARGET).txt config/settings.txt --in config/configure.1.pl --out configure.pl + $(PERL) config/configure.1.pl --do target=direct settings-$(TARGET).txt config/settings.txt --in config/configure.1.pl --out configure.pl $(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) configure.pl - $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE) + $(CONFIGURE_CMD) --v --in $(GENERATE_FROM) --out $(TO_GENERATE) $(PERL_WRAP_EXEC): %: exec/exec.c exec/settings.txt configure.pl - $(PERL) configure.pl path=$(BIN_PATH) target=$*.pl io_path=$(LOG_PATH) stderr=$*-stderr.log exec/settings.txt --in exec/exec.c --out $*.c + $(PERL) configure.pl --do path=$(BIN_PATH) target=$*.pl io_path=$(LOG_PATH) stderr=$*-stderr.log exec/settings.txt --in exec/exec.c --out $*.c $(CC) $(CF) -o $@ $*.c exec: $(EXEC) @@ -204,7 +204,7 @@ install: all cp_bin cp_lib cp_www cp_conf cp_cron clean: $(RM) -f configure.pl $(TO_GENERATE) $(PERL_WRAP_EXEC) $(PERL_WRAP_EXEC:=.c) - $(PERL) config/configure.1.pl $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile + $(PERL) config/configure.1.pl --do $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile PHONY: all clean install setuid exec mktree cp_bin cp_lib cp_www cp_conf cp_cron diff --git a/makefile.1.mak b/makefile.1.mak index c05af33..72ab790 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -48,7 +48,7 @@ CONFIGFILE = settings-$(TARGET).txt settings.txt DEFAULT_CONFIGFILE = settings-$(DEFAULT_TARGET).txt settings.txt # The configuration tool -CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE) +CONFIGURE_CMD = $(PERL) ./configure.pl --do $(CONFIGFILE) # keep these 2 lists in the same order!: GENERATE_FROM=\ @@ -156,13 +156,13 @@ makefile: makefile.1.mak $(CONFIGFILE) configure.pl $(CONFIGURE_CMD) < makefile.1.mak > makefile configure.pl: $(CONFIGFILE) config/configure.1.pl - $(PERL) config/configure.1.pl target=direct settings-$(TARGET).txt config/settings.txt --in config/configure.1.pl --out configure.pl + $(PERL) config/configure.1.pl --do target=direct settings-$(TARGET).txt config/settings.txt --in config/configure.1.pl --out configure.pl $(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) configure.pl - $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE) + $(CONFIGURE_CMD) --v --in $(GENERATE_FROM) --out $(TO_GENERATE) $(PERL_WRAP_EXEC): %: exec/exec.c exec/settings.txt configure.pl - $(PERL) configure.pl path=$(BIN_PATH) target=$*.pl io_path=$(LOG_PATH) stderr=$*-stderr.log exec/settings.txt --in exec/exec.c --out $*.c + $(PERL) configure.pl --do path=$(BIN_PATH) target=$*.pl io_path=$(LOG_PATH) stderr=$*-stderr.log exec/settings.txt --in exec/exec.c --out $*.c $(CC) $(CF) -o $@ $*.c exec: $(EXEC) @@ -204,7 +204,7 @@ install: all cp_bin cp_lib cp_www cp_conf cp_cron clean: $(RM) -f configure.pl $(TO_GENERATE) $(PERL_WRAP_EXEC) $(PERL_WRAP_EXEC:=.c) - $(PERL) config/configure.1.pl $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile + $(PERL) config/configure.1.pl --do $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile PHONY: all clean install setuid exec mktree cp_bin cp_lib cp_www cp_conf cp_cron diff --git a/oldlogs.1.pl b/oldlogs.1.pl deleted file mode 100644 index dbb4421..0000000 --- a/oldlogs.1.pl +++ /dev/null @@ -1,130 +0,0 @@ -###RUN_PERL: #!/usr/bin/perl - -# oldlogs is generated from oldlogs.1.pl. -# -# This script renames log files if they are big enough. -# Compresses or removes older log files. -# -# Copyright (C) 2015, 2016, 2023, 2024 Balthasar Szczepański -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -# TODO: use a real log rotate instead of this tool? - -use strict; -use utf8; -use Encode::Locale ('decode_argv'); -use Encode ('encode', 'decode'); - -###PERL_LIB: use lib /botm/lib/bsta -use botm_common ( - 'join_path', - 'system_encoded', - 'opendir_encoded', 'readdir_decoded', - '_x_encoded', 'stat_encoded', - 'unlink_encoded', 'rename_encoded' -); - -###PERL_PATH_SEPARATOR: PATH_SEPARATOR = / - -###PERL_GZIP: GZIP = gzip -###PERL_LOG_PATH: LOG_PATH = /botm/log/bsta/ -###PERL_LOG_SIZE_LIMIT: LOG_SIZE_LIMIT = 65536 -###PERL_LOGS_UNCOMPRESSED: LOGS_UNCOMPRESSED = 2 -###PERL_LOGS_TOTAL: LOGS_TOTAL = 10 - -binmode STDIN, ':encoding(UTF-8)'; -binmode STDOUT, ':encoding(UTF-8)'; -binmode STDERR, ':encoding(UTF-8)'; -decode_argv(); - -my $log_path = ($ARGV[0] ne '' ) ? $ARGV[0]: LOG_PATH(); -my $log_size_limit = ($ARGV[1] =~ /^[0-9]+$/) ? int($&) : LOG_SIZE_LIMIT(); -my $logs_total = ($ARGV[2] =~ /^[0-9]+$/) ? int($&) : LOGS_TOTAL(); -my $logs_uncompressed = ($ARGV[3] =~ /^[0-9]+$/) ? int($&) : LOGS_UNCOMPRESSED(); - -if (opendir_encoded(my $dir, $log_path)) { - while (defined (my $file_name = readdir_decoded($dir))) { - if ($file_name !~ /\.log$/) { - next; - } - my $full_path = join_path(PATH_SEPARATOR(), $log_path, $file_name); - unless (_x_encoded('-f', $full_path)) { - next; - } - my @stat; - unless (@stat = stat_encoded($full_path)) { - next; - } - if ($stat[7] > $log_size_limit) { - move_log($full_path, 0, 0); - } - } - closedir($dir); -} -else { - print "fail "; - print $log_path; - print "\n"; -} - -sub move_log { - (my $path, my $number, my $gz) = @_; - my $next_gz = 0; - my $this_path; - my $next_path; - my $next_number = $number + 1; - my @gzip_arg = (GZIP(), '-q', '-9','-f'); - - $this_path = $path.( - ($number != 0) ? - '.'.$number.($gz ? '.gz' : '') : - '' - ); - if ($number == $logs_total) { - if (unlink_encoded($this_path)) { - return 1; - } - else { - return 0; - } - } - if ($number == $logs_uncompressed) { - $next_gz = 1; - $next_path = $path.'.'.$next_number.'.gz'; - } - else { - $next_path = $path.'.'.$next_number.($gz ? '.gz' : ''); - } - - # TODO: consider loop instead of recursion? - if (_x_encoded('-e', $next_path)) { - unless (move_log($path, $next_number, ($next_gz or $gz) ? 1 : 0)) { - return 0; - } - } - - if ($next_gz) { - push @gzip_arg, $this_path; - unless (! system_encoded(GZIP(), @gzip_arg)) { - return 0; - } - $this_path .= '.gz'; - } - - unless (rename_encoded($this_path, $next_path)) { - return 0; - } - return 1; -}