Compare commits

...

7 Commits

Author SHA1 Message Date
Sukru Senli
83fc239982 logrotate package added 2016-12-05 10:14:36 +01:00
Reidar Cederqvist
8865d39d94 asterisk: fixed stupid error caused by strange behaviour in network.sh script 2016-12-02 11:55:08 +01:00
Sukru Senli
70fb756568 questd updated 2016-11-30 18:49:09 +01:00
Sukru Senli
34acd10ea6 questd updated 2016-11-30 15:29:21 +01:00
Sukru Senli
e5fcc43641 iop: add common.diff first 2016-11-28 13:27:36 +01:00
Sukru Senli
0274a9444c iop: update genconfig to new customerconfigs format 2016-11-28 11:32:11 +01:00
Sukru Senli
c429d654f7 brcmwifi: force enable obss_coex 2016-11-13 12:19:06 +01:00
12 changed files with 929 additions and 264 deletions

View File

@@ -24,6 +24,7 @@ init_asterisk() {
network_get_ipaddr ip "$bindintf"
while [ "$ip" == "" ]; do
sleep 1
network_flush_cache
network_get_ipaddr ip "$bindintf"
done
fi

View File

@@ -1,297 +1,336 @@
#!/bin/bash
function genconfig {
export CLEAN=0
export IMPORT=0
export SRCTREEOVERR=0
export FILEDIR="files/"
export CONFIGPATH="package/feeds/feed_inteno_packages/iop/configs"
export CUSTCONF="customerconfigs"
export VERBOSE=0
export DEVELOPER=0
LOCAL_MIRROR="http://mirror.inteno.se/mirror"
export CLEAN=0
export IMPORT=1
export SRCTREEOVERR=0
export FILEDIR="files/"
CURRENT_CONFIG_FILE=".current_config_file"
export CONFIGPATH="package/feeds/feed_inteno_packages/iop/configs"
CUSTPATH="customerconfigs"
CUSTREPO="git@private.inteno.se:customerconfigs"
export CUSTCONF="customerconfigs/customers"
export VERBOSE=0
export DEVELOPER=0
LOCAL_MIRROR="http://mirror.inteno.se/mirror"
iopsys_brcm63xx_mips="cg300 cg301 dg150 dg150v2 dg150alv2 dg200 dg200al dg301 dg301al eg300 vg50 vox25"
iopsys_brcm63xx_arm="dg400 eg400"
iopsys_ramips="ex400"
ramips="mt7621"
target="bogus"
masterconfig=1
set_target() {
iopsys_brcm63xx_mips="cg300 cg301 dg150 dg150v2 dg150alv2 dg200 dg200al dg301 dg301al eg300 vg50 vox25"
iopsys_brcm63xx_arm="dg400 eg400"
iopsys_ramips="ex400"
ramips="mt7621"
target="bogus"
masterconfig=1
set_target()
{
local profile=$1
for p in $iopsys_brcm63xx_mips; do
if [ $p == $profile ]; then
target="iopsys_brcm63xx_mips"
return
fi
if [ $p == $profile ]; then
target="iopsys_brcm63xx_mips"
return
fi
done
for p in $iopsys_brcm63xx_arm; do
if [ $p == $profile ]; then
target="iopsys_brcm63xx_arm"
return
fi
if [ $p == $profile ]; then
target="iopsys_brcm63xx_arm"
return
fi
done
for p in $iopsys_ramips; do
if [ $p == $profile ]; then
target="iopsys_ramips"
return
fi
if [ $p == $profile ]; then
target="iopsys_ramips"
return
fi
done
for p in $ramips; do
if [ $p == $profile ]; then
target="ramips"
masterconfig=0
return
fi
if [ $p == $profile ]; then
target="ramips"
masterconfig=0
return
fi
done
}
}
git remote -v | grep -q http || {
DEVELOPER=1
bcmAllowed=0
iceAllowed=0
endptAllowed=0
natalieAllowed=0
allowedRepos="$(ssh -o ConnectTimeout=5 git@private.inteno.se 2>/dev/null | grep -w 'R\|W' | awk '{print$NF}')"
for repo in $allowedRepos; do
case $repo in
bcmkernel) bcmAllowed=1 ;;
ice-client) iceAllowed=1 ;;
endptcfg) endptAllowed=1 ;;
natalie-dect*) natalieAllowed=1 ;;
esac
done
}
v() {
[ "$VERBOSE" -ge 1 ] && echo "$@"
}
usage() {
echo
echo 1>&2 "Usage: $0 [ OPTIONS ] < Board_Type > [ Customer ]"
echo
echo -e " -c|--clean\tRemove all files under ./files and import from config "
echo -e " -v|--verbose\tVerbose"
echo -e " -n|--no-update\tDo NOT! Update customer config before applying"
echo -e " -p|--profile\tSet profile (if exists) default juci"
echo -e " -s|--override\tEnable 'Package source tree override'"
echo -e " -h|--help\tShow this message"
echo -e " -l|--list [customer]\tList all Customers or all boards for one customer"
echo -e " -a|--list-all\tList all Customers and their board types"
echo
echo "Example ./iop genconfig vg50 TELIA"
echo "(if no customerconfig is chosen the Inteno Config will be used)"
echo
exit 0
}
list_customers()
{
local ALL="$1"
local CUSTOMER="$2"
if [ "$CUSTOMER" -a -d "$CUSTCONF/$CUSTOMER" ]; then
local boards="$(ls -1 "$CUSTCONF/$CUSTOMER" | grep -v common)"
if [ "$boards" ]; then
echo "$CUSTOMER has following boards:"
for board in $boards; do
echo -e "\t$board"
done
else
echo "No boards found for $CUSTOMER"
fi
elif [ "$CUSTOMER" ]; then
echo "No customer called $CUSTOMER"
exit 1
elif [ -d $CUSTCONF ]; then
local customers="$(ls -1 $CUSTCONF)"
if [ "$customers" -a "$1" == 1 ]; then
for customer in $customers; do
echo $customer
local boards="$(ls -1 $CUSTCONF/$customer | grep -v common)"
if [ "$boards" ]; then
for board in $boards; do
echo -e "\t$board"
done
else
echo "has no boards"
fi
done
elif [ "$customers" ]; then
echo -e "$customers"
else
echo "no customers found"
fi
else
echo "No $CUSTCONF folder found"
fi
exit 0
}
git remote -v | grep -q http || {
DEVELOPER=1
use_local_mirror()
{
if wget -T 3 -t 2 -O /dev/null $LOCAL_MIRROR >/dev/null 2>/dev/null; then
echo "mirror [$LOCAL_MIRROR] exists. Using local mirror"
sed -i "s;CONFIG_LOCALMIRROR=.*;CONFIG_LOCALMIRROR=\"$LOCAL_MIRROR\";" .config
else
echo "mirror [$LOCAL_MIRROR] does not exist. Not using local mirror"
fi
}
bcmAllowed=0
iceAllowed=0
endptAllowed=0
natalieAllowed=0
allowedRepos="$(ssh -o ConnectTimeout=5 git@private.inteno.se 2>/dev/null | grep -w 'R\|W' | awk '{print$NF}')"
for repo in $allowedRepos; do
case $repo in
bcmkernel) bcmAllowed=1 ;;
ice-client) iceAllowed=1 ;;
endptcfg) endptAllowed=1 ;;
natalie-dect*) natalieAllowed=1 ;;
esac
done
}
v() {
[ "$VERBOSE" -ge 1 ] && echo "$@"
}
usage() {
echo
echo 1>&2 "Usage: $0 [OPTIONS] BoardConfig Customerconfig"
echo
echo " -c, remove all files under ./files and import from config "
echo " -v, verbose"
echo " -u, Update customer config before applying"
echo " -p, set profile (if exists)"
echo " -t, use latest git tag and number of commits since as version for the build"
echo " -s, enable 'Package source tree override'"
echo
echo "BoardConfig ex "
ls -1 configs
if [ -d "$CUSTCONF/$1" ]; then
echo "Customerconfig ex"
ls $CUSTCONF/*
fi
echo
echo "Example ./genconfig vg50 TELIA"
echo "(if no customerconfig is chosen the Inteno Config will be used)"
echo
exit 127
}
use_local_mirror()
{
if wget -T 3 -t 2 -O /dev/null $LOCAL_MIRROR >/dev/null 2>/dev/null
then
echo "mirror [$LOCAL_MIRROR] exists. Using local mirror"
sed -i "s;CONFIG_LOCALMIRROR=.*;CONFIG_LOCALMIRROR=\"$LOCAL_MIRROR\";" .config
else
echo "mirror [$LOCAL_MIRROR] does not exist. Not using local mirror"
fi
}
generate_config()
{
generate_config()
{
DIFFFILE="$1"
MASTERFILE="$2"
while read p; do
v "$p"
sed -r -i "$p" $MASTERFILE
v "$p"
sed -r -i "$p" $MASTERFILE
done < $DIFFFILE
}
}
setup_dirs()
{
if [ $DEVELOPER -eq 1 ]; then
if [ ! -d "$CUSTCONF" ]; then
git clone git@private.inteno.se:customerconfigs
elif [ $IMPORT -eq 1 ]; then
cd customerconfigs
v "git pull"
git pull
cd ..
fi
setup_dirs()
{
if [ $DEVELOPER -eq 1 ]; then
if [ ! -d "$CUSTPATH" ]; then
git clone "$CUSTREPO" "$CUSTPATH"
elif [ $IMPORT -eq 1 ]; then
cd $CUSTPATH
v "git pull"
git pull
cd - >/dev/null #go back
fi
fi
if [ ! -d "$FILEDIR" ]; then
mkdir -p $FILEDIR
elif [ -d "$FILEDIR" -a $CLEAN -eq 1 ]; then
v "rm -rf $FILEDIR*"
rm -rf $FILEDIR*
fi
}
create_and_copy_files()
{
local BOARDTYPE=$1
local CUSTOMER=$2
# Validate seleced board and customer
set_target $BOARDTYPE
if [ $target == "bogus" ]; then
echo "Hardware profile does not exist"
exit 1
elif [ -n "$CUSTOMER" -a ! -d "$CUSTCONF/$CUSTOMER/$BOARDTYPE/" ]; then
echo "Customer profile does not exist"
exit 1
fi
# Generate base config
# Used only for iopsys targets, not openwrt targets
rm -f .config
if [ $masterconfig -eq 1 ]; then
v "Config $BOARDTYPE selected"
v "cp $CONFIGPATH/config .config"
cp $CONFIGPATH/config .config
fi
# Apply profile diff to master config if selected
if [ -n "$PROFILE" ]; then
if [ -e "$CONFIGPATH/$PROFILE.diff" ]; then
cat $CONFIGPATH/$PROFILE.diff >> .config
elif [ "$PROFILE" == "juci" ]; then
v "Default profile (juci) is selected."
else
echo "ERROR: profile $PROFILE does not exist!"
exit 1
fi
else
v "No profile selected! Using default."
fi
# Set target and profile
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config
echo "$CUSTOMER $BOARDTYPE" > $CURRENT_CONFIG_FILE
# Add customerconfig diff if a customer is selected
if [ -n "$CUSTOMER" ]; then
if [ -d "$CUSTCONF/$CUSTOMER/common/fs" ]; then
v "cp -ar $CUSTCONF/$CUSTOMER/common/fs/* $FILEDIR"
cp -ar $CUSTCONF/$CUSTOMER/common/fs/* $FILEDIR
fi
if [ -d "$CUSTCONF/$CUSTOMER/$BOARDTYPE/fs" ]; then
v "cp -ar $CUSTCONF/$CUSTOMER/$BOARDTYPE/fs/* $FILEDIR"
cp -ar $CUSTCONF/$CUSTOMER/$BOARDTYPE/fs/* $FILEDIR
fi
if [ -e "$CUSTCONF/$CUSTOMER/common/common.diff" ]; then
v "Apply $CUSTCONF/$CUSTOMER/common/common.diff"
cat $CUSTCONF/$CUSTOMER/common/common.diff >> .config
fi
if [ -e "$CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff" ]; then
v "Apply $CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff"
cat $CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff >> .config
fi
fi
# Set target version
local GIT_TAG=$(git describe --abbrev=0 --tags)
echo "CONFIG_TARGET_VERSION=\"${GIT_TAG}\"" >> .config
# Enable Pckage source tree override if selected
[ $SRCTREEOVERR -eq 1 ] && echo CONFIG_SRC_TREE_OVERRIDE=y >> .config
# developer mode selected ?
if [ $DEVELOPER -eq 1 ]; then
# rewrite url to clone with ssh instead of http
echo "CONFIG_DEVEL=y" >>.config
echo "CONFIG_GITMIRROR_REWRITE=y" >>.config
[ $bcmAllowed -eq 0 ] && echo "CONFIG_BCM_OPEN=y" >> .config
[ $iceAllowed -eq 0 ] && echo "CONFIG_ICE_OPEN=y" >> .config
[ $endptAllowed -eq 0 ] && echo "CONFIG_ENDPT_OPEN=y" >> .config
[ $natalieAllowed -eq 0 ] && echo "CONFIG_NATALIE_OPEN=y" >> .config
else
echo "CONFIG_BCM_OPEN=y" >> .config
echo "CONFIG_ICE_OPEN=y" >> .config
echo "CONFIG_ENDPT_OPEN=y" >> .config
echo "CONFIG_NATALIE_OPEN=y" >> .config
fi
# Force regeneration of kernel Makefile
# Needed to disable kmods for iopsys-brcm targets
touch package/kernel/linux/Makefile
# Set default values based on selected parameters
v "$(make defconfig 2>&1)"
# Temporary fixup for juci/luci profile
if [ "$PROFILE" == "luci" ]; then
sed -i '/CONFIG_DEFAULT_juci/d' .config
sed -i '/CONFIG_PACKAGE_juci/d' .config
sed -i '/CONFIG_PACKAGE_uhttpd/d' .config
fi
if [ $masterconfig -eq 1 ]; then
echo Set version to $(grep -w CONFIG_TARGET_VERSION .config | cut -d'=' -f2 | tr -d '"')
fi
# Clean base-file package to force rebuild when changing profile
v "$(make package/base-files/clean 2>&1)"
}
####### main #####
if [ ! -e tmp/.iop_bootstrap ]; then
echo "You have not installed feeds. Running genconfig in this state would create a non functional configuration."
echo "Run: iop feeds_update"
exit 0
fi
if [ ! -d "$FILEDIR" ]; then
mkdir $FILEDIR
elif [ -d "$FILEDIR" -a $CLEAN -eq 1 ]; then
v "rm -rf $FILEDIR*"
rm -rf $FILEDIR*
fi
}
create_and_copy_files()
{
local BOARDTYPE=$1
local CUSTOMER=$2
# Validate seleced board and customer
set_target $BOARDTYPE
if [ $target == "bogus" ]; then
echo "Hardware profile does not exist"
exit 1
elif [ -n "$CUSTOMER" -a ! -d "$CUSTCONF/$BOARDTYPE/$CUSTOMER/" ]; then
echo "Customer profile does not exist"
exit 1
fi
# Generate base config
# Used only for iopsys targets, not openwrt targets
rm -f .config
if [ $masterconfig -eq 1 ]; then
v "Config $BOARDTYPE selected"
v "cp $CONFIGPATH/config .config"
cp $CONFIGPATH/config .config
fi
# Apply profile diff to master config if selected
if [ -n "$PROFILE" ]; then
if [ -e "$CONFIGPATH/$PROFILE.diff" ]; then
cat $CONFIGPATH/$PROFILE.diff >> .config
elif [ "$PROFILE" == "juci" ]; then
v "Default profile (juci) is selected."
else
echo "ERROR: profile $PROFILE does not exist!"
exit 1
fi
else
v "No profile selected! Using default."
fi
# Set target and profile
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config
echo "$BOARDTYPE $CUSTOMER" > .current_config_file
# Add customerconfig diff if a customer is selected
if [ -n "$CUSTOMER" ]; then
if [ -d "$CUSTCONF/$BOARDTYPE/$CUSTOMER/fs" ]; then
v "cp -rLp $CUSTCONF/$BOARDTYPE/$CUSTOMER/fs/* $FILEDIR"
cp -rLp $CUSTCONF/$BOARDTYPE/$CUSTOMER/fs/* $FILEDIR
fi
if [ -e "$CUSTCONF/$BOARDTYPE/$CUSTOMER/$BOARDTYPE.diff" ]; then
v "Apply $CUSTCONF/$BOARDTYPE/$CUSTOMER/$BOARDTYPE.diff"
cat $CUSTCONF/$BOARDTYPE/$CUSTOMER/$BOARDTYPE.diff >> .config
fi
fi
# Set target version
local GIT_TAG=$(git describe --abbrev=0 --tags)
echo "CONFIG_TARGET_VERSION=\"${GIT_TAG}\"" >> .config
# Enable Pckage source tree override if selected
[ $SRCTREEOVERR -eq 1 ] && \
echo CONFIG_SRC_TREE_OVERRIDE=y >> .config
# developer mode selected ?
if [ $DEVELOPER -eq 1 ]; then
# rewrite url to clone with ssh instead of http
echo "CONFIG_DEVEL=y" >>.config
echo "CONFIG_GITMIRROR_REWRITE=y" >>.config
[ $bcmAllowed -eq 0 ] && echo "CONFIG_BCM_OPEN=y" >> .config
[ $iceAllowed -eq 0 ] && echo "CONFIG_ICE_OPEN=y" >> .config
[ $endptAllowed -eq 0 ] && echo "CONFIG_ENDPT_OPEN=y" >> .config
[ $natalieAllowed -eq 0 ] && echo "CONFIG_NATALIE_OPEN=y" >> .config
if [ $# -eq 0 ]; then
echo Current profile:
cat $CURRENT_CONFIG_FILE
echo "Try ./iop genconfig -h' to get instructions if you want to change current config"
exit 0
else
echo "CONFIG_BCM_OPEN=y" >> .config
echo "CONFIG_ICE_OPEN=y" >> .config
echo "CONFIG_ENDPT_OPEN=y" >> .config
echo "CONFIG_NATALIE_OPEN=y" >> .config
while [ -n "$1" ]; do
case "$1" in
-c|--clean) export CLEAN=1;;
-n|--no-update) export IMPORT=0;;
-v|--verbose) export VERBOSE="$(($VERBOSE + 1))";;
-p|--profile) export PROFILE="$2"; shift;;
-s|--override) export SRCTREEOVERR=1;;
-h|--help) usage;;
-l|--list) list_customers 0 $2;;
-a|--list-all)list_customers 1;;
-*)
echo "Invalid option: $1 "
echo "Try -h or --help for more information."
exit 1
;;
*) break;;
esac
shift;
done
setup_dirs
create_and_copy_files "$1" "$2"
if [ $masterconfig -eq 1 ]; then
use_local_mirror
fi
fi
# Force regeneration of kernel Makefile
# Needed to disable kmods for iopsys-brcm targets
touch package/kernel/linux/Makefile
# Set default values based on selected parameters
make defconfig
# Temporary fixup for juci/luci profile
if [ "$PROFILE" == "luci" ]; then
sed -i '/CONFIG_DEFAULT_juci/d' .config
sed -i '/CONFIG_PACKAGE_juci/d' .config
sed -i '/CONFIG_PACKAGE_uhttpd/d' .config
fi
if [ $masterconfig -eq 1 ]; then
echo Set version to $(grep -w CONFIG_TARGET_VERSION .config | cut -d'=' -f2 | tr -d '"')
fi
# Clean base-file package to force rebuild when changing profile
make package/base-files/clean
}
####### main #####
if [ ! -e tmp/.iop_bootstrap ]; then
echo "You have not installed feeds. Running genconfig in this state would create a non functional configuration."
echo "Run: iop feeds_update"
exit 0
fi
if [ $# -eq 0 ]; then
echo Current profile:
cat .current_config_file
echo "Try ./iop_get_config.sh -h' to get instructions if you want to change current config"
exit 0
else
while [ -n "$1" ]; do
case "$1" in
-c) export CLEAN=1;;
-u) export IMPORT=1;;
-v) export VERBOSE="$(($VERBOSE + 1))";;
-p) export PROFILE="$2"; shift;;
-t) export USE_TAG=1;;
-s) export SRCTREEOVERR=1;;
-h) usage;;
-*)
echo "Invalid option: $1 "
echo "Try -h' for more information."
exit 1
;;
*) break;;
esac
shift;
done
setup_dirs
create_and_copy_files "$1" "$2"
if [ $masterconfig -eq 1 ]; then
use_local_mirror
fi
fi
}
register_command "genconfig" "Generate configuration for board and customer"

View File

@@ -85,6 +85,7 @@ wlmngr_doWlConf() {
#wlctl -i wl$idx nreqd $nreqd
wlconf wl$idx up
wlctl -i wl$idx obss_coex 1
}
wlmngr_setupMbssMacAddr() {

47
logrotate/Makefile Normal file
View File

@@ -0,0 +1,47 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=logrotate
PKG_VERSION:=3.7.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/l/logrotate
PKG_MD5SUM:=552639142e163745f6bcd4f1f3816d8a
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/logrotate
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=+libpopt
TITLE:=rotates, compresses, and mails system logs
endef
define Build/Compile
$(call Build/Compile/Default, \
RPM_OPT_FLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS)" \
LDFLAGS="$(EXTRA_LDFLAGS)" \
logrotate \
)
endef
define Package/logrotate/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) ${PKG_BUILD_DIR}/logrotate $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc
$(CP) ./files/logrotate.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/logrotate.d
endef
$(eval $(call BuildPackage,logrotate))

View File

@@ -0,0 +1,30 @@
# rotate log files weekly
weekly
#daily
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
notifempty
nomail
#olddir /var/log/backup/
missingok
#dateext
# uncomment this if you want your log files compressed
#compress
# packages can drop log rotation information into this directory
include /etc/logrotate.d
# no packages own lastlog or wtmp -- we'll rotate them here
#/var/log/wtmp {
# monthly
# create 0664 root utmp
# rotate 1
#}
# system-specific logs may be also be configured here.

View File

@@ -0,0 +1,433 @@
diff -u -ruN logrotate-3.7.1.orig/config.c logrotate-3.7.1/config.c
--- logrotate-3.7.1.orig/config.c 2003-08-07 07:13:14.000000000 -0400
+++ logrotate-3.7.1/config.c 2005-05-24 12:21:09.000000000 -0400
@@ -511,6 +511,14 @@
newlog->flags &= ~LOG_FLAG_IFEMPTY;
*endtag = oldchar, start = endtag;
+ } else if (!strcmp(start, "dateext")) {
+ newlog->flags |= LOG_FLAG_DATEEXT;
+
+ *endtag = oldchar, start = endtag;
+ } else if (!strcmp(start, "nodateext")) {
+ newlog->flags &= ~LOG_FLAG_DATEEXT;
+
+ *endtag = oldchar, start = endtag;
} else if (!strcmp(start, "noolddir")) {
newlog->oldDir = NULL;
@@ -670,6 +678,21 @@
}
*endtag = oldchar, start = endtag;
}
+ } else if (!strcmp(start, "maxage")) {
+ *endtag = oldchar, start = endtag;
+
+ if (!isolateValue(configFile, lineNum, "maxage count", &start,
+ &endtag)) {
+ oldchar = *endtag, *endtag = '\0';
+
+ newlog->rotateAge = strtoul(start, &chptr, 0);
+ if (*chptr || newlog->rotateAge < 0) {
+ message(MESS_ERROR, "%s:%d bad maximum age '%s'\n",
+ configFile, lineNum, start);
+ return 1;
+ }
+ *endtag = oldchar, start = endtag;
+ }
} else if (!strcmp(start, "errors")) {
message(MESS_DEBUG, "%s: %d: the errors directive is deprecated and no longer used.\n",
configFile, lineNum);
diff -u -ruN logrotate-3.7.1.orig/logrotate.8 logrotate-3.7.1/logrotate.8
--- logrotate-3.7.1.orig/logrotate.8 2003-08-07 07:13:14.000000000 -0400
+++ logrotate-3.7.1/logrotate.8 2005-05-24 12:21:09.000000000 -0400
@@ -200,6 +200,11 @@
Log files are rotated every day.
.TP
+\fBdateext\fR
+Archive old versions of log files adding a daily extension like YYYYMMDD
+instead of simply adding a number.
+
+.TP
\fBdelaycompress\fR
Postpone compression of the previous log file to the next rotation cycle.
This has only effect when used in combination with \fBcompress\fR.
@@ -246,6 +251,12 @@
instead of the just-rotated file (this is the default).
.TP
+\fBmaxage\fR \fIcount\fR
+Remove rotated logs older than <count> days. The age is only checked
+if the logfile is to be rotated. The files are mailed to the
+configured address if \fBmaillast\fR and \fBmail\fR are configured.
+
+.TP
\fBmissingok\fR
If the log file is missing, go on to the next one without issuing an error
message. See also \fBnomissingok\fR.
diff -u -ruN logrotate-3.7.1.orig/logrotate.c logrotate-3.7.1/logrotate.c
--- logrotate-3.7.1.orig/logrotate.c 2004-10-19 17:41:24.000000000 -0400
+++ logrotate-3.7.1/logrotate.c 2005-05-24 12:21:09.000000000 -0400
@@ -11,6 +11,7 @@
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
+#include <glob.h>
#ifdef WITH_SELINUX
#include <selinux/selinux.h>
@@ -22,6 +23,10 @@
#include "log.h"
#include "logrotate.h"
+#if !defined(GLOB_ABORTED) && defined(GLOB_ABEND)
+#define GLOB_ABORTED GLOB_ABEND
+#endif
+
typedef struct {
char * fn;
struct tm lastRotated; /* only tm.mon, tm_mday, tm_year are good! */
@@ -42,6 +47,14 @@
char * mailCommand = DEFAULT_MAIL_COMMAND;
time_t nowSecs = 0;
+static int globerr(const char * pathname, int theerr) {
+ message(MESS_ERROR, "error accessing %s: %s\n", pathname,
+ strerror(theerr));
+
+ /* We want the glob operation to continue, so return 0 */
+ return 1;
+}
+
static logState * findState(const char * fn, struct stateSet * sip) {
int i;
logState * states = sip->states;
@@ -49,9 +62,11 @@
struct tm now = *localtime(&nowSecs);
time_t lr_time;
+ /* find the filename fn in the statesPtr list */
for (i = 0; i < numStates; i++)
if (!strcmp(fn, states[i].fn)) break;
+ /* not in statesPtr list, so add new entry */
if (i == numStates) {
i = numStates++;
states = realloc(states, sizeof(*states) * numStates);
@@ -121,6 +136,17 @@
return rc;
}
+static int removeLogFile(char * name) {
+ message(MESS_DEBUG, "removing old log %s\n", name);
+
+ if (!debug && unlink(name)) {
+ message(MESS_ERROR, "Failed to remove old log %s: %s\n",
+ name, strerror(errno));
+ return 1;
+ }
+ return 0;
+}
+
static int compressLogFile(char * name, logInfo * log, struct stat *sb) {
char * compressedName;
const char ** fullCommand;
@@ -265,6 +291,25 @@
return rc;
}
+static int mailLogWrapper (char * mailFilename, char * mailCommand, int logNum, logInfo * log) {
+ /* if the log is compressed (and we're not mailing a
+ * file whose compression has been delayed), we need
+ * to uncompress it */
+ if ((log->flags & LOG_FLAG_COMPRESS) &&
+ !((log->flags & LOG_FLAG_DELAYCOMPRESS) &&
+ (log->flags & LOG_FLAG_MAILFIRST))) {
+ if (mailLog(mailFilename, mailCommand,
+ log->uncompress_prog, log->logAddress,
+ log->files[logNum]))
+ return 1;
+ } else {
+ if (mailLog(mailFilename, mailCommand, NULL,
+ log->logAddress, mailFilename))
+ return 1;
+ }
+ return 0;
+}
+
static int copyTruncate(char * currLog, char * saveLog, struct stat * sb, int flags) {
char buf[BUFSIZ];
int fdcurr = -1, fdsave = -1;
@@ -479,6 +524,9 @@
char * baseName;
char * dirName;
char * firstRotated;
+ char * glob_pattern;
+ glob_t globResult;
+ int rc;
size_t alloc_size;
int rotateCount = log->rotateCount ? log->rotateCount : 1;
int logStart = (log->logStart == -1) ? 1 : log->logStart;
@@ -509,7 +557,7 @@
alloc_size = strlen(dirName) + strlen(baseName) +
strlen(log->files[logNum]) + strlen(fileext) +
- strlen(compext) + 10;
+ strlen(compext) + 18;
oldName = alloca(alloc_size);
newName = alloca(alloc_size);
@@ -531,16 +579,116 @@
/* First compress the previous log when necessary */
if (log->flags & LOG_FLAG_COMPRESS &&
log->flags & LOG_FLAG_DELAYCOMPRESS) {
- struct stat sbprev;
-
- sprintf(oldName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
- if (stat(oldName, &sbprev)) {
- message(MESS_DEBUG, "previous log %s does not exist\n",
- oldName);
- } else {
- hasErrors = compressLogFile(oldName, log, &sbprev);
+ if (log->flags & LOG_FLAG_DATEEXT) {
+ /* glob for uncompressed files with our pattern */
+ glob_pattern = malloc(strlen(dirName) + strlen(baseName)
+ + strlen(fileext) + 44 );
+ sprintf(glob_pattern,
+ "%s/%s-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%s",
+ dirName, baseName, fileext);
+ rc = glob(glob_pattern, 0, globerr, &globResult);
+ if (!rc && globResult.gl_pathc > 0) {
+ for (i = 0; i < globResult.gl_pathc && !hasErrors; i++) {
+ struct stat sbprev;
+ sprintf(oldName,"%s",(globResult.gl_pathv)[i]);
+ if (stat(oldName, &sbprev)) {
+ message(MESS_DEBUG, "previous log %s does not exist\n", oldName);
+ } else {
+ hasErrors = compressLogFile(oldName, log, &sbprev);
+ }
+ }
+ } else {
+ message (MESS_DEBUG, "glob finding logs to compress failed\n");
+ /* fallback to old behaviour */
+ sprintf(oldName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
+ }
+ globfree(&globResult);
+ free(glob_pattern);
+ } else {
+ struct stat sbprev;
+
+ sprintf(oldName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
+ if (stat(oldName, &sbprev)) {
+ message(MESS_DEBUG, "previous log %s does not exist\n",
+ oldName);
+ } else {
+ hasErrors = compressLogFile(oldName, log, &sbprev);
+ }
}
}
+
+ firstRotated = alloca(strlen(dirName) + strlen(baseName) +
+ strlen(fileext) + strlen(compext) + 30);
+
+ if(log->flags & LOG_FLAG_DATEEXT) {
+ /* glob for compressed files with our pattern
+ * and compress ext */
+ glob_pattern = malloc(strlen(dirName)+strlen(baseName)
+ +strlen(fileext)+strlen(compext)+44);
+ sprintf(glob_pattern,
+ "%s/%s-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%s%s",
+ dirName, baseName, fileext, compext);
+ rc = glob(glob_pattern, 0, globerr, &globResult);
+ if (!rc) {
+ /* search for files to drop, if we find one remember it,
+ * if we find another one mail and remove the first and
+ * remember the second and so on */
+ struct stat fst_buf;
+ int mail_out = -1;
+ /* remove the first (n - rotateCount) matches
+ * no real rotation needed, since the files have
+ * the date in their name */
+ for (i = 0; i < globResult.gl_pathc; i++) {
+ if( !stat((globResult.gl_pathv)[i],&fst_buf) ) {
+ if ((i <= ((int)globResult.gl_pathc - rotateCount))
+ || ((log->rotateAge > 0)
+ && (((nowSecs - fst_buf.st_mtime)/60/60/24)
+ > log->rotateAge))) {
+ if ( mail_out != -1 ) {
+ if (!hasErrors && log->logAddress) {
+ char * mailFilename = (globResult.gl_pathv)[mail_out];
+ hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
+ if (!hasErrors)
+ hasErrors = removeLogFile(mailFilename);
+ }
+ }
+ mail_out = i;
+ }
+ }
+ }
+ if ( mail_out != -1 ) {
+ /* oldName is oldest Backup found (for unlink later) */
+ sprintf(oldName, "%s", (globResult.gl_pathv)[mail_out]);
+ strcpy(disposeName, oldName);
+ } else
+ disposeName = NULL;
+ } else {
+ message (MESS_DEBUG, "glob finding old rotated logs failed\n");
+ disposeName = NULL;
+ }
+ /* firstRotated is most recently created/compressed rotated log */
+ sprintf(firstRotated, "%s/%s-%04d%02d%02d%s%s",
+ dirName, baseName, now.tm_year+1900,
+ now.tm_mon+1, now.tm_mday, fileext, compext);
+ globfree(&globResult);
+ free(glob_pattern);
+ } else {
+ if ( log->rotateAge ) {
+ struct stat fst_buf;
+ for (i=1; i <= rotateCount; i++) {
+ sprintf(oldName, "%s/%s.%d%s%s", dirName, baseName,
+ rotateCount + 1, fileext, compext);
+ if(!stat(oldName,&fst_buf)
+ && (((nowSecs - fst_buf.st_mtime)/60/60/24)
+ > log->rotateAge)) {
+ char * mailFilename = (globResult.gl_pathv)[i];
+ if (!hasErrors && log->logAddress)
+ hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
+ if (!hasErrors)
+ hasErrors = removeLogFile(mailFilename);
+ }
+ }
+ }
sprintf(oldName, "%s/%s.%d%s%s", dirName, baseName,
logStart + rotateCount, fileext, compext);
@@ -548,8 +696,6 @@
strcpy(disposeName, oldName);
- firstRotated = alloca(strlen(dirName) + strlen(baseName) +
- strlen(fileext) + strlen(compext) + 30);
sprintf(firstRotated, "%s/%s.%d%s%s", dirName, baseName,
logStart, fileext,
(log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext);
@@ -600,12 +746,27 @@
}
}
}
-
+ } /* !LOG_FLAG_DATEEXT */
+
finalName = oldName;
-
- /* note: the gzip extension is *not* used here! */
- sprintf(finalName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
-
+
+ if(log->flags & LOG_FLAG_DATEEXT) {
+ char * destFile = alloca(strlen(dirName) + strlen(baseName) +
+ strlen(fileext) + strlen(compext) + 30);
+ struct stat fst_buf;
+ sprintf(finalName, "%s/%s-%04d%02d%02d%s",
+ dirName, baseName, now.tm_year+1900,
+ now.tm_mon+1, now.tm_mday, fileext);
+ sprintf(destFile, "%s%s", finalName, compext);
+ if(!stat(destFile,&fst_buf)) {
+ message (MESS_DEBUG, "destination %s already exists, skipping rotation\n", firstRotated);
+ hasErrors = 1;
+ }
+ } else {
+ /* note: the gzip extension is *not* used here! */
+ sprintf(finalName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
+ }
+
/* if the last rotation doesn't exist, that's okay */
if (!debug && access(disposeName, F_OK)) {
message(MESS_DEBUG, "log %s doesn't exist -- won't try to "
@@ -613,9 +774,6 @@
disposeName = NULL;
}
- free(dirName);
- free(baseName);
-
if (!hasErrors) {
if (log->pre && !(log->flags & LOG_FLAG_SHAREDSCRIPTS)) {
message(MESS_DEBUG, "running prerotate script\n");
@@ -722,33 +880,12 @@
else
mailFilename = disposeName;
- if (mailFilename) {
- /* if the log is compressed (and we're not mailing a
- file whose compression has been delayed), we need
- to uncompress it */
- if ((log->flags & LOG_FLAG_COMPRESS) &&
- !((log->flags & LOG_FLAG_DELAYCOMPRESS) &&
- (log->flags & LOG_FLAG_MAILFIRST))) {
- if (mailLog(mailFilename, mailCommand,
- log->uncompress_prog, log->logAddress,
- log->files[logNum]))
- hasErrors = 1;
- } else {
- if (mailLog(mailFilename, mailCommand, NULL,
- log->logAddress, mailFilename))
- hasErrors = 1;
- }
- }
+ if (mailFilename)
+ hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
}
if (!hasErrors && disposeName) {
- message(MESS_DEBUG, "removing old log %s\n", disposeName);
-
- if (!debug && unlink(disposeName)) {
- message(MESS_ERROR, "Failed to remove old log %s: %s\n",
- disposeName, strerror(errno));
- hasErrors = 1;
- }
+ hasErrors = removeLogFile(disposeName);
}
}
@@ -761,6 +898,8 @@
}
}
#endif
+ free(dirName);
+ free(baseName);
return hasErrors;
}
@@ -1047,7 +1186,9 @@
int main(int argc, const char ** argv) {
logInfo defConfig = { NULL, NULL, 0, NULL, ROT_SIZE,
- /* threshHold */ 1024 * 1024, 0,
+ /* threshHold */ 1024 * 1024,
+ /* rotateCount */ 0,
+ /* rotateAge */ 0,
/* log start */ -1,
/* pre, post */ NULL, NULL,
/* first, last */ NULL, NULL,
diff -u -ruN logrotate-3.7.1.orig/logrotate.h logrotate-3.7.1/logrotate.h
--- logrotate-3.7.1.orig/logrotate.h 2003-08-07 07:13:14.000000000 -0400
+++ logrotate-3.7.1/logrotate.h 2005-05-24 12:21:09.000000000 -0400
@@ -15,6 +15,7 @@
#define LOG_FLAG_MAILFIRST (1 << 6)
#define LOG_FLAG_SHAREDSCRIPTS (1 << 7)
#define LOG_FLAG_COPY (1 << 8)
+#define LOG_FLAG_DATEEXT (1 << 9)
#define NO_FORCE_ROTATE 0
#define FORCE_ROTATE 1
@@ -34,6 +35,7 @@
enum { ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_SIZE, ROT_FORCE } criterium;
unsigned int threshhold;
int rotateCount;
+ int rotateAge;
int logStart;
char * pre, * post, * first, * last;
char * logAddress;

View File

@@ -0,0 +1,12 @@
diff -u -ruN logrotate-3.7.1.orig/logrotate.c logrotate-3.7.1/logrotate.c
--- logrotate-3.7.1.orig/logrotate.c 2004-10-19 17:41:24.000000000 -0400
+++ logrotate-3.7.1/logrotate.c 2005-05-24 12:12:26.000000000 -0400
@@ -1002,7 +1002,7 @@
}
/* Hack to hide earlier bug */
- if ((year != 1900) && (year < 1996 || year > 2100)) {
+ if ((year != 1900) && (year < 1970 || year > 2100)) {
message(MESS_ERROR, "bad year %d for file %s in state file %s\n",
year, argv[0], stateFilename);
fclose(f);

View File

@@ -0,0 +1,14 @@
--- logrotate-3.7/config.c.orig 2005-04-26 22:57:53.000000000 -0400
+++ logrotate-3.7/config.c 2005-04-26 22:59:36.000000000 -0400
@@ -142,6 +142,11 @@
(!fname[1] || (fname[1] == '.' && !fname[2])))
return 0;
+ /* Don't include 'hidden' files either; this breaks Gentoo
+ portage config file management http://bugs.gentoo.org/87683 */
+ if (fname[0] == '.')
+ return 0;
+
/* Check if fname is ending in a taboo-extension; if so, return
false */
for (i = 0; i < tabooCount; i++) {

View File

@@ -0,0 +1,54 @@
diff -u -ruN logrotate-3.7.1-cur/logrotate.c logrotate-3.7.1/logrotate.c
--- logrotate-3.7.1-cur/logrotate.c 2005-05-25 18:20:41.000000000 -0400
+++ logrotate-3.7.1/logrotate.c 2005-05-25 18:21:10.000000000 -0400
@@ -90,10 +90,7 @@
}
static int runScript(char * logfn, char * script) {
- int fd;
- char *filespec;
int rc;
- char buf[256];
if (debug) {
message(MESS_DEBUG, "running script with arg %s: \"%s\"\n",
@@ -101,38 +98,12 @@
return 0;
}
- filespec = buf;
- snprintf(buf, sizeof(buf), "%s/logrotate.XXXXXX", getenv("TMPDIR") ?: "/tmp");
- fd = -1;
- if (!filespec || (fd = mkstemp(filespec)) < 0 || fchmod(fd, 0700)) {
- message(MESS_DEBUG, "error creating %s: %s\n", filespec,
- strerror(errno));
- if (fd >= 0) {
- close(fd);
- unlink(filespec);
- }
- return -1;
- }
-
- if (write(fd, "#!/bin/sh\n\n", 11) != 11 ||
- write(fd, script, strlen(script)) != strlen(script)) {
- message(MESS_DEBUG, "error writing %s\n", filespec);
- close(fd);
- unlink(filespec);
- return -1;
- }
-
- close(fd);
-
if (!fork()) {
- execlp(filespec, filespec, logfn, NULL);
+ execl("/bin/sh", "sh", "-c", script, NULL);
exit(1);
}
wait(&rc);
-
- unlink(filespec);
-
return rc;
}

View File

@@ -0,0 +1,12 @@
diff -u -ruN logrotate-3.7.1.orig/config.c logrotate-3.7.1/config.c
--- logrotate-3.7.1.orig/config.c 2003-08-07 07:13:14.000000000 -0400
+++ logrotate-3.7.1/config.c 2005-05-24 12:13:41.000000000 -0400
@@ -147,7 +147,7 @@
for (i = 0; i < tabooCount; i++) {
if (!strcmp(fname + strlen(fname) - strlen(tabooExts[i]),
tabooExts[i])) {
- message(MESS_ERROR, "Ignoring %s, because of %s "
+ message(MESS_DEBUG, "Ignoring %s, because of %s "
"ending\n", fname, tabooExts[i]);
return 0;

View File

@@ -0,0 +1,22 @@
--- logrotate-3.7.1-old/logrotate.c 2004-10-19 23:41:24.000000000 +0200
+++ logrotate-3.7.1-new/logrotate.c 2005-10-02 17:29:22.380767321 +0200
@@ -424,12 +424,15 @@ int findNeedRotating(logInfo * log, int
switch (log->criterium) {
case ROT_WEEKLY:
/* rotate if:
- 1) the current weekday is before the weekday of the
- last rotation
+ 1) the day of the week is the same as the day of the week of
+ the previous rotation but not the same day of the year
+ this will rotate it on the same day every week, but not
+ twice a day.
2) more then a week has passed since the last
rotation */
- state->doRotate = ((now.tm_wday < state->lastRotated.tm_wday) ||
- ((mktime(&now) - mktime(&state->lastRotated)) >
+ state->doRotate = ((now.tm_wday == state->lastRotated.tm_wday &&
+ now.tm_yday != state->lastRotated.tm_yday) ||
+ ((mktime(&now) - mktime(&state->lastRotated)) >
(7 * 24 * 3600)));
break;
case ROT_MONTHLY:

View File

@@ -8,7 +8,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=questd
PKG_VERSION:=3.1.22
PKG_SOURCE_VERSION:=52ee23cb217321c92537d116eebba79c3c8966b8
PKG_SOURCE_VERSION:=f6f1c8fc0036847deb67c1c0f158372ece872d4b
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=http://public.inteno.se:/questd