auanasgheps / snapraid-aio-script

The definitive all-in-one SnapRAID script on Linux. Diff, sync, scrub are things of the past. Manage SnapRAID and much, much more!
GNU General Public License v3.0
239 stars 37 forks source link

Skip trying to install packages if dpkg isn't installed #111

Closed StephenWetzel closed 2 months ago

StephenWetzel commented 3 months ago

This PR aims to better handle non-debian based Linux distros. It does this by just testing the output of dpkg --version for the string Debian, and assumes if it's present then dpkg is installed and it can be used to install packages, and if it's not present, then it'll just warn the user that it's unable to automatically install packages.

This isn't a perfect system, so I'm very open to feedback, but it does feel like an improvement over the current state. Right now, the script just assumes dpkg is available, and attempts to interpret the output from dpkg-query and apg-get. On my openSUSE system this produces this output every time the script runs.

## Preprocessing
python3-markdown has not been found and will be installed...
python3-markdown installed successfully.
bc has not been found and will be installed...
bc installed successfully.
curl has not been found and will be installed...
curl installed successfully.
jq has not been found and will be installed...
jq installed successfully.
Healthchecks.io notification is enabled. Notifications sent to https://hc-ping.com/.

Even though those packages are installed, and the script is not successfully installing them. With this change the output changes to.

## Preprocessing
dpkg not found, cannot check for dependencies.
Healthchecks.io notification is enabled. Notifications sent to https://hc-ping.com/.

Like I said, I'm very open to alternative ways to do this, but this change feels safe, in that at worse it'll behave the same as the current script, as long as the output of dpkg --version can be relied upon to produce some text that contains the string Debian.

auanasgheps commented 2 months ago

Hi, thanks for your contribution. It's fine, I will make a couple of small wording changes.

auanasgheps commented 2 months ago

Done, I will merge. If you fancy you could implement a check for your package manager.