LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Check system requirements in installer shell script (https://www.linuxquestions.org/questions/programming-9/check-system-requirements-in-installer-shell-script-4175536269/)

trava90 03-10-2015 04:54 AM

Check system requirements in installer shell script
 
Hi, I have a shell script that I would like to update, but I'm still new to writing scripts, and I haven't been able to find what I'm need on Google, so I thought I would ask here. Currently, the script uses curl to download a precompiled tar.bz2, then extracts it (updating previous versions if necessary) and creates a desktop icon.

My question is, how do I update the script to check the minimum system requirements before downloading the archive (specifically the Linux kernel, glib, gtk, etc.)?

Any help is appreciated! Thank you!

linosaurusroot 03-10-2015 08:26 AM

I think it would help to state what distribution and package manager you have.

And assuming you're using a package manager is it really necessary to do automated installation of a tarball as opposed to a package?

veerain 03-10-2015 08:35 AM

You can use 'uname' command output for kernel version. And for glib, gtk, and etc in general you can use package managers description of installed packages.
But it might be a little difficult. As said in previous post you can instead create a package based on the package manager and you will have dependency resolution easily.

trava90 03-10-2015 02:46 PM

The program I download and extract isn't available through my distro's (Manjaro) repo. The reason I want to have the script check system requirements is so that I can use the script across multiple distros (especially older ones like CentOS 6 and Ubuntu 12.04 for example), and learn something in the process!

Could you elaborate on using the package managers description? If I go that route, would it work across a wide range of distros?

Thanks again for any help!

veerain 03-10-2015 08:54 PM

Well different distros use different package managers.

Read the man pages of 'rpm' and 'dpkg'.

trava90 03-11-2015 06:09 AM

Do you think something like this (as an example) would work across multiple distros? Or do you think it would be more hassle then it's worth?

Code:

check_dependencies () {
echo "Checking for dependencies..."
local MISSING_DEPS=""

if [ -z "$(find_python2)" ]; then
MISSING_DEPS="${MISSING_DEPS}python2.x "
fi

if [ -z "$(which curl)" ]; then
MISSING_DEPS="${MISSING_DEPS}curl "
fi

if [ -z "$(which curl)" ]; then
MISSING_DEPS="${MISSING_DEPS}gtk2-2.20 "
fi

if [ -n "$MISSING_DEPS" ]; then
exit_with_error "Your computer is missing the following programs or libraries: $MISSING_DEPS. Install them using your distribution's package manager."
fi
}


veerain 03-11-2015 09:19 AM

Quote:

Originally Posted by trava90 (Post 5330341)
Do you think something like this (as an example) would work across multiple distros? Or do you think it would be more hassle then it's worth?

Code:

check_dependencies () {
echo "Checking for dependencies..."
local MISSING_DEPS=""

if [ -z "$(find_python2)" ]; then
MISSING_DEPS="${MISSING_DEPS}python2.x "
fi

if [ -z "$(which curl)" ]; then
MISSING_DEPS="${MISSING_DEPS}curl "
fi

if [ -z "$(which curl)" ]; then
MISSING_DEPS="${MISSING_DEPS}gtk2-2.20 "
fi

if [ -n "$MISSING_DEPS" ]; then
exit_with_error "Your computer is missing the following programs or libraries: $MISSING_DEPS. Install them using your distribution's package manager."
fi
}


The code is a very brief summary or truely a cursory one. It depends on you what's hassle.


All times are GMT -5. The time now is 04:38 AM.