New check command for web-add.sh #5

Merged
Ghost merged 5 commits from ticket-37722 into master 2018-12-13 23:29:07 +01:00
First-time contributor

I'd like to introduce a new fix command for scripts/web-add.sh,
which can be safely run when somebody overwrites symbolic links in
sites-enabled.

But there are many ways of doing this, it could be a command like
it is now, but it could also be a simple function that is called
anytime scripts/web-add.sh is run or a separate script that is
either run manually or through cron(8).

I'd like to introduce a new fix command for scripts/web-add.sh, which can be safely run when somebody overwrites symbolic links in sites-enabled. But there are many ways of doing this, it could be a command like it is now, but it could also be a simple function that is called anytime scripts/web-add.sh is run or a separate script that is either run manually or through cron(8).
benpro was assigned by Ghost 2018-11-23 15:34:13 +01:00
Ghost added the
Script
Bug
labels 2018-11-23 15:34:13 +01:00
Author
First-time contributor

Any opinions or thoughts on this?

Any opinions or thoughts on this?
Contributor

I commented the code with a "beware". The idea is good, but it should be used with precaution!

I commented the code with a "beware". The idea is good, but it should be used with precaution!
Author
First-time contributor

@benpro How do you view comments on the code?

@benpro How do you view comments on the code?
Ghost reviewed 2018-11-29 17:14:15 +01:00
Ghost reviewed 2018-11-29 17:16:47 +01:00
benpro reviewed 2018-11-29 17:18:05 +01:00
@ -991,0 +997,4 @@
# Some people forget to use the --follow-symlinks flag with sed(1),
# thus not carrying changes over to /etc/sites-available.
op_fixvhosts() {
ln_vhosts_dir="$(echo "$VHOST_PATH" | sed 's/available/enabled')"
Contributor

Useless echo? Missing last sed trail?

Should be:

sed 's/available/enabled/' <<< "$VHOST_PATH"
Useless echo? Missing last sed trail? Should be: ```bash sed 's/available/enabled/' <<< "$VHOST_PATH" ```
Author
First-time contributor

Mostly me not completely used to bash again, I'll fix it.

Mostly me not completely used to bash again, I'll fix it.
@ -991,0 +1004,4 @@
do
vhost_name=$(basename "$ln_path")
mv "$ln_path" "$VHOST_PATH/$vhost_name"
Contributor

Beware that operation can be dangerous. If people have modified the version in sites-available and sites-enabled, you should first merge the difference in the sites-available version, then do the symbolic link.

Beware that operation can be dangerous. If people have modified the version in sites-available **and** sites-enabled, you should first merge the difference in the sites-available version, then do the symbolic link.
Author
First-time contributor

I'm thinking it could probably take a --dry-run flag

I'm thinking it could probably take a --dry-run flag
Author
First-time contributor

So what would the behavior be when using it from the web interface?

So what would the behavior be when using it from the web interface?
Contributor

Huh. No need for that feature in the web interface.
This is for helping sysadmins only.

Huh. No need for that feature in the web interface. This is for helping sysadmins only.
Contributor

Yes you should add a --dry-run, or even should be the default.

Yes you should add a `--dry-run`, or even should be the default.
Author
First-time contributor

What's your preference: --force or --apply?

What's your preference: `--force` or `--apply`?
Contributor

--force is nice. (If you force, you must understand the consequences ;))

`--force` is nice. (If you force, you must understand the consequences ;))
Author
First-time contributor

Yeah but web-add.sh fix --apply makes more semantic sense in my mind, web-add.sh fix --force seems to apply more to an operation that was aborted because of inconsistencies, but gives you the option to force break stuff? Like web-add.sh add-alias [alias] --force would make sense.

Yeah but `web-add.sh fix --apply` makes more semantic sense in my mind, `web-add.sh fix --force` seems to apply more to an operation that was aborted because of inconsistencies, but gives you the option to force break stuff? Like `web-add.sh add-alias [alias] --force` would make sense.
Contributor

Well... Ok for --apply.

Well... Ok for `--apply`.
Author
First-time contributor

See the latest commit for changes. I switched fix-vhosts to check-vhosts and added the -f flag to apply fixes.

See the latest commit for changes. I switched fix-vhosts to check-vhosts and added the -f flag to apply fixes.
@ -991,0 +1005,4 @@
vhost_name=$(basename "$ln_path")
mv "$ln_path" "$VHOST_PATH/$vhost_name"
ln -s "$VHOST_PATH/$vhost_name" "$ln_path"
Contributor

You could also use a2ensite in place of doing a manual link.

You could also use `a2ensite` in place of doing a manual link.
Author
First-time contributor

Good idea

Good idea
Author
First-time contributor

Web wise I see the web-add.sh use the fix command before doing anything with an existing vhost, if it detects that theres a problem with the vhosts it should abort and tell the webpage to show "Contact your administrator, something is wrong with the vhosts".

Alternatively this functionality could also be exported to evocheck but it would imply adding a dependency to evocheck for evoadmin-web.

Web wise I see the `web-add.sh` use the fix command before doing anything with an existing vhost, if it detects that theres a problem with the vhosts it should abort and tell the webpage to show "Contact your administrator, something is wrong with the vhosts". Alternatively this functionality could also be exported to `evocheck` but it would imply adding a dependency to `evocheck` for `evoadmin-web`.
Contributor

[…] if it detects that theres a problem with the vhosts it should abort and tell the webpage to show “Contact your administrator, something is wrong with the vhosts”.

I agree.

Alternatively this functionality could also be exported to evocheck […]

Evocheck is already checking that with IS_APACHESYMLINK.

> […] if it detects that theres a problem with the vhosts it should abort and tell the webpage to show “Contact your administrator, something is wrong with the vhosts”. I agree. > Alternatively this functionality could also be exported to `evocheck` […] Evocheck is already checking that with `IS_APACHESYMLINK`.
Author
First-time contributor

So should we be just using that? Evocheck could be modified to add a --fix flag that automatically fixes specific problems. I'll have to look at the existing code first though.

So should we be just using that? Evocheck could be modified to add a --fix flag that automatically fixes specific problems. I'll have to look at the existing code first though.
Contributor

No Evocheck isn't meant to fix things.

No Evocheck isn't meant to fix things.
Author
First-time contributor

Fair enough, but should the code that checks if a fix is necessary use evocheck instead of my current implementation?

Fair enough, but should the code that checks if a fix is necessary use evocheck instead of my current implementation?
Ghost added the
Feature
label 2018-12-04 17:29:35 +01:00
Author
First-time contributor

@benpro what do you think of the latest commit? (I'm not too sure how notifs work yet)

@benpro what do you think of the latest commit? (I'm not too sure how notifs work yet)
benpro reviewed 2018-12-05 09:46:12 +01:00
Contributor

"/ServerName .*/a \\\tServerAlias $alias missing the trailing slash?

`"/ServerName .*/a \\\tServerAlias $alias` missing the trailing slash?
Contributor

LGTM

LGTM
Author
First-time contributor

Cool, @vlaborie what do you think? Anything sticking out?

If not I'll do one last round of testing.

Cool, @vlaborie what do you think? Anything sticking out? If not I'll do one last round of testing.
Ghost changed title from WIP: New fix command for web-add.sh to New check command for web-add.sh 2018-12-05 15:04:46 +01:00
Author
First-time contributor

@romain any comments or is it pas pire?

@romain any comments or is it pas pire?
Author
First-time contributor

Sounds good for me, you can merge your code.

Sounds good for me, you can merge your code.
Ghost closed this pull request 2018-12-13 23:29:07 +01:00
Ghost deleted branch ticket-37722 2018-12-13 23:29:17 +01:00
Sign in to join this conversation.
No description provided.