mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Clean helper
The fix for the helper ynh_use_logrotate has been released so remove it
This commit is contained in:
parent
1ecff75512
commit
7c2f3cbd60
2 changed files with 1 additions and 60 deletions
|
@ -19,7 +19,7 @@
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.6.4"
|
"yunohost": ">= 2.7.7"
|
||||||
},
|
},
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install": [
|
"install": [
|
||||||
|
|
|
@ -130,65 +130,6 @@ ynh_clean_setup () {
|
||||||
pkill -f "seahub"
|
pkill -f "seahub"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Implement PR : https://github.com/YunoHost/yunohost/pull/392
|
|
||||||
|
|
||||||
# Use logrotate to manage the logfile
|
|
||||||
#
|
|
||||||
# usage: ynh_use_logrotate [logfile] [--non-append]
|
|
||||||
# | arg: logfile - absolute path of logfile
|
|
||||||
# | option: --non-append - Replace the config file instead of appending this new config.
|
|
||||||
#
|
|
||||||
# If no argument provided, a standard directory will be use. /var/log/${app}
|
|
||||||
# You can provide a path with the directory only or with the logfile.
|
|
||||||
# /parentdir/logdir
|
|
||||||
# /parentdir/logdir/logfile.log
|
|
||||||
#
|
|
||||||
# It's possible to use this helper several times, each config will be added to the same logrotate config file.
|
|
||||||
# Unless you use the option --non-append
|
|
||||||
ynh_use_logrotate () {
|
|
||||||
local customtee="tee -a"
|
|
||||||
if [ $# -gt 0 ] && [ "$1" == "--non-append" ]; then
|
|
||||||
customtee="tee"
|
|
||||||
# Destroy this argument for the next command.
|
|
||||||
shift
|
|
||||||
elif [ $# -gt 1 ] && [ "$2" == "--non-append" ]; then
|
|
||||||
customtee="tee"
|
|
||||||
fi
|
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
if [ "$(echo ${1##*.})" == "log" ]; then # Keep only the extension to check if it's a logfile
|
|
||||||
logfile=$1 # In this case, focus logrotate on the logfile
|
|
||||||
else
|
|
||||||
logfile=$1/*.log # Else, uses the directory and all logfile into it.
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
logfile="/var/log/${app}/*.log" # Without argument, use a defaut directory in /var/log
|
|
||||||
fi
|
|
||||||
cat > ./${app}-logrotate << EOF # Build a config file for logrotate
|
|
||||||
$logfile {
|
|
||||||
# Rotate if the logfile exceeds 100Mo
|
|
||||||
size 100M
|
|
||||||
# Keep 12 old log maximum
|
|
||||||
rotate 12
|
|
||||||
# Compress the logs with gzip
|
|
||||||
compress
|
|
||||||
# Compress the log at the next cycle. So keep always 2 non compressed logs
|
|
||||||
delaycompress
|
|
||||||
# Copy and truncate the log to allow to continue write on it. Instead of move the log.
|
|
||||||
copytruncate
|
|
||||||
# Do not do an error if the log is missing
|
|
||||||
missingok
|
|
||||||
# Not rotate if the log is empty
|
|
||||||
notifempty
|
|
||||||
# Keep old logs in the same dir
|
|
||||||
noolddir
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
sudo mkdir -p $(dirname "$logfile") # Create the log directory, if not exist
|
|
||||||
cat ${app}-logrotate | sudo $customtee /etc/logrotate.d/$app > /dev/null # Append this config to the existing config file, or replace the whole config file (depending on $customtee)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Get application version from manifest
|
# Get application version from manifest
|
||||||
#
|
#
|
||||||
# usage: ynh_app_version
|
# usage: ynh_app_version
|
||||||
|
|
Loading…
Reference in a new issue