Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing RSYNC_PORT #2871

Open
fadamo opened this issue Sep 28, 2022 · 18 comments
Open

Customizing RSYNC_PORT #2871

fadamo opened this issue Sep 28, 2022 · 18 comments
Assignees
Labels
discuss / RFC enhancement Adaptions and new features

Comments

@fadamo
Copy link
Contributor

fadamo commented Sep 28, 2022

I found that simply adding in local.conf

readonly RSYNC_PORT=nnnnn
export RSYNC_PORT

I can customize rsyncd port.
So I think it is possible to write

RSYNC_PORT=${RSYNC_PORT:-873}

instead of

RSYNC_PORT=873                  # default port (of rsync server)

in /usr/share/rear/verify/RSYNC/default/100_check_rsync.sh
to give a proper way to customize that port.

@jsmeix jsmeix added enhancement Adaptions and new features discuss / RFC labels Oct 5, 2022
@jsmeix
Copy link
Member

jsmeix commented Oct 5, 2022

In current ReaR 2.7 code there is
no longer a global variable RSYNC_PORT.
Instead there is a function rsync_port()
in usr/share/rear/lib/rsync-functions.sh
see
e0d3c6e
which reads (excerpt):

... introducing generic functions for rsync URL parsing and
use them for both BACKUP_URL and OUTPUT_URL, as appropriate.
Replace all uses of global RSYNC_* variables derived
from BACKUP_URL by those functions

See also
#2831 (comment)
and
#2831 (comment)

@jsmeix
Copy link
Member

jsmeix commented Oct 5, 2022

@fadamo
by the way:

Your

readonly VARIABLE=value
export VARIABLE

method in etc/rear/local.conf is a good real world example
why make rear working with "set -ue -o pipefail", cf.
#700
is not such a good idea in practice, see the section
"Try hard to care about possible errors" in
https://github.com/rear/rear/wiki/Coding-Style
that reads (excerpt)

Using 'set -eu -o pipefail' also during runtime
is currently not recommended because
it is a double-edged sword
which can cause more problems in practice
(i.e. problems for ReaR users)
than it intends to solve in theory.

In this case here set -eu -o pipefail
(therein in particular the set -e part)
would hinder the user to do some "dirty hacks"
to make ReaR behave as he needs it in his specific case,
cf. the section "Dirty hacks welcome" in
https://github.com/rear/rear/wiki/Coding-Style
and my continuous mantra: "Final power to the user!" ;-)

@fadamo
Copy link
Contributor Author

fadamo commented Oct 5, 2022

In current ReaR 2.7 code there is no longer a global variable RSYNC_PORT. Instead there is a function rsync_port() in usr/share/rear/lib/rsync-functions.sh see e0d3c6e which reads (excerpt):

... introducing generic functions for rsync URL parsing and
use them for both BACKUP_URL and OUTPUT_URL, as appropriate.
Replace all uses of global RSYNC_* variables derived
from BACKUP_URL by those functions

See also #2831 (comment) and #2831 (comment)

In current ReaR 2.7 code there is no longer a global variable RSYNC_PORT. Instead there is a function rsync_port() in usr/share/rear/lib/rsync-functions.sh see e0d3c6e which reads (excerpt):

... introducing generic functions for rsync URL parsing and
use them for both BACKUP_URL and OUTPUT_URL, as appropriate.
Replace all uses of global RSYNC_* variables derived
from BACKUP_URL by those functions

See also #2831 (comment) and #2831 (comment)

This is fine: #2831 (comment) !
Are you going to implement it ?

@fadamo
Copy link
Contributor Author

fadamo commented Oct 5, 2022

Using 'set -eu -o pipefail' also during runtime
is currently not recommended because
it is a double-edged sword
which can cause more problems in practice

In depends on how you start writing brand new scripts.
I always use

#!/bin/bash -eEu
set -o pipefail

Instead, modifying old scripts is more complex.
BTW, this is your coding style, not mine, so I respect your ideas. And I really appreciate ReaR.

@pcahyna
Copy link
Member

pcahyna commented Oct 5, 2022

In current ReaR 2.7 code there is
no longer a global variable RSYNC_PORT.
Instead there is a function rsync_port()

to me it seemed that RSYNC_* variables have effectively been internal variables, not something that was intended to be customizable by users (the values have been supplied in BACKUP_URL). So I decided to restructure the code and get rid of them without feeling the need for backward compatibility. Setting it to readonly is a nice hack, but the proper fix would be to extract the port from the URL.

@pcahyna
Copy link
Member

pcahyna commented Oct 5, 2022

Concerning

In this case here set -eu -o pipefail
(therein in particular the set -e part)
would hinder the user to do some "dirty hacks"

I am more positive towards stuff like set -e. I would not make it the default in production, but set it during test runs. This would allow to discover many problems (depending on test coverage), but not prevent from using "dirty hacks".

@pcahyna pcahyna self-assigned this Oct 5, 2022
@jsmeix
Copy link
Member

jsmeix commented Oct 6, 2022

Regarding set -eu -o pipefail see the whole text in
the section "Try hard to care about possible errors" in
https://github.com/rear/rear/wiki/Coding-Style
that also reads (excerpt)

Preferably during development of new scripts
or when scripts are much overhauled
and while testing new code use 'set -ue'
to die from unset variables and unhandled errors
and use 'set -o pipefail' to better notice
failures in a pipeline.
...
Using 'set -eu -o pipefail' also during runtime
is currently not recommended ...

where "during runtime" actually means
"during runtime on the user's system".
I made that text more clear so that it is now

Using 'set -eu -o pipefail' also in general
during runtime on the user's system
is currently not recommended ...

@jsmeix
Copy link
Member

jsmeix commented Oct 6, 2022

@pcahyna
I agree with all your reasoning in your
#2871 (comment)
in particular with your conclusion that
the proper fix would be to extract the port from the URL.

@jsmeix
Copy link
Member

jsmeix commented Oct 6, 2022

I did
#2877
to implement a sufficiently easy way in practice
so that certain scripts can be run with
specific bash options like set -eu -o pipefail
during development (e.g. while testing things).
Of course also users can use that as needed
(e.g. for debugging or whatever they like).

@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Stale issue message

@github-actions
Copy link

github-actions bot commented Feb 7, 2023

Stale issue message

@github-actions
Copy link

github-actions bot commented Apr 9, 2023

Stale issue message

@github-actions
Copy link

Stale issue message

@github-actions
Copy link

Stale issue message

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2023
Copy link

Stale issue message

Copy link

Stale issue message

Copy link

Stale issue message

Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss / RFC enhancement Adaptions and new features
Projects
None yet
Development

No branches or pull requests

3 participants