mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
helpers: fix logrotate shitty inconsistent handling of 'supposedly legacy' --non-append option ...
This commit is contained in:
parent
030927cf03
commit
8d1c75e732
1 changed files with 19 additions and 10 deletions
|
@ -16,10 +16,27 @@
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
# Requires YunoHost version 3.2.0 or higher for the argument `--specific_user`
|
# Requires YunoHost version 3.2.0 or higher for the argument `--specific_user`
|
||||||
ynh_use_logrotate() {
|
ynh_use_logrotate() {
|
||||||
|
|
||||||
|
# Stupid patch to remplace --non-append by --nonappend
|
||||||
|
# Because for some reason --non-append was supposed to be legacy
|
||||||
|
# (why is it legacy ? Idk maybe because getopts cant parse args with - in their names..)
|
||||||
|
# but there was no good communication about this, and now --non-append
|
||||||
|
# is still the most-used option, yet it was parsed with batshit stupid code
|
||||||
|
# So instead this loops over the positional args, and replace --non-append
|
||||||
|
# with --nonappend so it's transperent for the rest of the function...
|
||||||
|
local all_args=( ${@} )
|
||||||
|
for I in $(seq 0 $#)
|
||||||
|
do
|
||||||
|
if [[ "${all_args[$I]}" == "--non-append" ]]
|
||||||
|
then
|
||||||
|
all_args[$I]="--nonappend"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -- "${all_args[@]}"
|
||||||
|
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=lnuya
|
local legacy_args=lnuya
|
||||||
local -A args_array=([l]=logfile= [n]=nonappend [u]=specific_user= [y]=non [a]=append)
|
local -A args_array=([l]=logfile= [n]=nonappend [u]=specific_user=)
|
||||||
# [y]=non [a]=append are only for legacy purpose, to not fail on the old option '--non-append'
|
|
||||||
local logfile
|
local logfile
|
||||||
local nonappend
|
local nonappend
|
||||||
local specific_user
|
local specific_user
|
||||||
|
@ -30,14 +47,6 @@ ynh_use_logrotate() {
|
||||||
specific_user="${specific_user:-}"
|
specific_user="${specific_user:-}"
|
||||||
|
|
||||||
# LEGACY CODE - PRE GETOPTS
|
# LEGACY CODE - PRE GETOPTS
|
||||||
if [ $# -gt 0 ] && [ "$1" == "--non-append" ]; then
|
|
||||||
nonappend=1
|
|
||||||
# Destroy this argument for the next command.
|
|
||||||
shift
|
|
||||||
elif [ $# -gt 1 ] && [ "$2" == "--non-append" ]; then
|
|
||||||
nonappend=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -gt 0 ] && [ "$(echo ${1:0:1})" != "-" ]; then
|
if [ $# -gt 0 ] && [ "$(echo ${1:0:1})" != "-" ]; then
|
||||||
# If the given logfile parameter already exists as a file, or if it ends up with ".log",
|
# If the given logfile parameter already exists as a file, or if it ends up with ".log",
|
||||||
# we just want to manage a single file
|
# we just want to manage a single file
|
||||||
|
|
Loading…
Add table
Reference in a new issue