FreePBX / sng_freepbx_debian_install

FreePBX 17 Installation Script
81 stars 26 forks source link

[improvement]: Suggestions to improve robustness and reliability #4

Closed tdltdl closed 5 months ago

tdltdl commented 5 months ago

FreePBX Version

FreePBX 17

Improvement Description

Here are some suggestions for the script "sng_freepbx_debian_install.sh"

Question

Disclosure: Those suggestions are only based on reading the script without executing it -so mileage can vary ;-).

tdltdl commented 5 months ago

What is the rationale to specify options "--force-confnew" and "--force-overwrite" when installing packages if the installation is only done when the package is not already installed?

kguptasangoma commented 5 months ago

Associated PR merged hence closing this jira. thanks

tdltdl commented 5 months ago

Thanks for accepting my PR. As per my comments in the PR, I believe th pkg install should remain as I changed it and we should also drop the force newconf and forceoverwrite.

kguptasangoma commented 5 months ago

Hey @tdltdl I merged the PR so we can test the new script. Got some hiccups and updated the codebase. Also looks like packages.sury.org is failing as well. image

tdltdl commented 5 months ago

Hey @tdltdl I merged the PR so we can test the new script. Got some hiccups and updated the codebase. Also looks like packages.sury.org is failing as well. !

This is wget complaining that the certificate presented by the site is not known. This can be caused by the fact that ca-certificates package is not installed by default on your system (this can be the case for debian minimal? I do not know). So maybe before running the setting up repositories, it would be safer to install the following packages:

Also what is the rationale to add twice the same deb entry (I see you restore this)

        add-apt-repository -y -S "deb [ arch=${arch} ] http://deb.freepbx.org/freepbx17-dev bookworm main" >> "$log" 2>&1
        add-apt-repository -y -S "deb [ arch=${arch} ] http://deb.freepbx.org/freepbx17-dev bookworm main" >> "$log" 2>&1
kguptasangoma commented 5 months ago

Error is for"certificate of the repo url is not trusted" so wondering if we can remove that repo ?

We have seen adding one time was not fixing the preference issue so had to do twice (some sort of repo issue) because we want "ffmpeg" to download from our repo not from debian one.

tdltdl commented 5 months ago

Error is for"certificate of the repo url is not trusted" so wondering if we can remove that repo ?

We have seen adding one time was not fixing the preference issue so had to do twice (some sort of repo issue) because we want "ffmpeg" to download from our repo not from debian one.

The repo is signed by let's encrypt, so a very common one. This does not make sense to add it twice and that it would "fix the issue". Maybe the ffmpeg was installed first before setting up the repo priority? This is also why I first setup the repositories and the priority, before installing al packages, but indeed, we must make sure that those packages we use in the setup of the repo are installed in the first place.

kguptasangoma commented 5 months ago

I agree we need to review this in deep why adding twice. will revisit this. Regarding repo as of now for other network or vultr it worked fine so not removing and will see if we hear complaints from others as well.

Thank you very much for your excellent work in improving this script.

Regards Kapil

tdltdl commented 5 months ago

Do you plan to change back the pkg_install, as it is a very important change in my opinion and there is no reason for me to undo it (and I would, as already mentioned, remove the "special options" that are either inactive or probably incorrect and probably add an apt upgrade while making environment sane).

tdltdl commented 5 months ago

Also note that I checked with apt policy ffmpeg and while having the "deb" line only once in my repo, I can confirm this is the Sangoma version that has been installed.

root@myhost# apt policy ffmpeg
ffmpeg:
  Installed: 5.1.4-7.sng12
  Candidate: 5.1.4-7.sng12
  Version table:
     7:4.4.2-0ubuntu0.22.04.1 500
        500 http://be.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
        500 http://be.archive.ubuntu.com/ubuntu jammy-security/universe amd64 Packages
     7:4.4.1-3ubuntu5 500
        500 http://be.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
 *** 5.1.4-7.sng12 600
        600 http://deb.freepbx.org/freepbx17-prod bookworm/main amd64 Packages
        100 /var/lib/dpkg/status
     5.1.4-6.sng12 600
        600 http://deb.freepbx.org/freepbx17-prod bookworm/main amd64 Packages
     5.1.4-5.sng12 600
        600 http://deb.freepbx.org/freepbx17-prod bookworm/main amd64 Packages
     5.1.4-3.sng12 600
        600 http://deb.freepbx.org/freepbx17-prod bookworm/main amd64 Packages
kguptasangoma commented 5 months ago

pkg_install is doing below stuff - 1) Checking If package installed then do not install it again. 2) install the package 3) check again if package installed or not as due to various reason we may fail to install the package so if package is not installed properly then its exiting the process.

3rd one is an important step as there is no point of moving further if we fail to install the package.

kguptasangoma commented 5 months ago

Of course we can improve the script further to remove that duplicate apt-add line and test to ensure all good (may be initial days something else was happening), it just today considered other changes to kept those changes as it is.

tdltdl commented 5 months ago

pkg_install is doing below stuff -

  1. Checking If package installed then do not install it again.
  2. install the package
  3. check again if package installed or not as due to various reason we may fail to install the package so if package is not installed properly then its exiting the process.

3rd one is an important step as there is no point of moving further if we fail to install the package (except of course if you pass the option "force overwrite - which I strongly believe we should remove - as anyway today, we will never attempt to overwrite it, because if we want to do it, it means it was already installed hence we will not even call the apt install again).

Step 1 is redundant as doing an apt install "existing package" multiple times will not attempt to reinstall it (except if you pass force overwrite, which I strongly believe we should remove). Step 3 is redundant as, if the installation fails for whatever reason the apt install with return a non zero code and that will be catched by the set -e and exit the installation, passing through the trap error to log the exact error and line it occurred and command that was executed. This is why I believe it is really not needed to do this.

kguptasangoma commented 5 months ago

Okay ,thanks for the explanation. will revert back the pkg_install fix.

tdltdl commented 5 months ago

I know now why you are enabling overwrite config:

Unpacking sangoma-pbx17 (2402-3.sng12) ...
dpkg: error processing archive /var/cache/apt/archives/sangoma-pbx17_2402-3.sng12_all.deb (--unpack):
 trying to overwrite '/etc/fail2ban/action.d/iptables-allports.conf', which is also in package fail2ban 0.11.2-6

I do not believe it is wise that sanfoma-pbx17 overwrites a config file from another package ;-(

Will create a dedicated issue for that, should those changes be part of the install script?