Answer the question
In order to leave comments, you need to log in
Checking package installation in FreeBSD via sh?
FreeBSD 10.1
Need to script .sh with conditions.
If the pcre package (as an example) is not installed, then run the command: pkg install pcre
Otherwise, skip.
Which command can be used to check if a package is installed?
Currently checking: pkg info | grep pcre
Is it true? And how are the conditions in .sh files correctly compiled?
UPD:
I would also like to know what command you can find out the user's login, because. if the user is not root, add sudo to the command.
Answer the question
In order to leave comments, you need to log in
Yes, you can check this. Just keep in mind that the combination of characters 'pcre' can be found in a number of packages :-)
How conditions are made -- man test. For syntax examples, you can refer to any of the scripts that are in /etc/rc.d/
User login can be found from environment variables. The setenv command with no options, or printenv is a USER variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question