Linux download wildcard URL - linux

Using my script I'd like to be able to go to Chef Inspec and download the latest version. However the URL they use has versions. The versions will change and eventually, if I hard code the URL, I won't be getting the latest.
How do I use the wget command with wildcards to always get the latest version and never have to check it?
Here is the URL they offer:
https://packages.chef.io/files/stable/inspec/2.3.4/ubuntu/16.04/inspec_2.3.4-1_amd64.deb
I just want it downloaded and autoinstalled, but when the version changes I'm going to fall behind.
UPDATE: This doesn't answer the question exactly, but works. What I ended up doing was using the Curl command. This gave me the end result needed:
curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P inspec

You should add their repository to /etc/apt/sources.list. Then you can use apt to update their software.
Chef Software Inc Packages
Debian has a tool called uscan which can download from URLs using wildcards, but this isn't the right tool for installing packages.

Related

Can we copy curl package and run on Linux without installation

I have old version of curl on linux, I want upgraded the version, but old version is using by others , so i cant upgrade the old one. On windows without installation just copy curl on any drive I am able to run curl, Can i do same thing on linux means just copy the package and run the curl, if yes from where I got the package
Is there any other way? by which old version will not effect
This may need some clarification: are you talking about libcurl or curl itself? (I ask because around the release of Buster I experienced some issues between some programs needing libcurl3 and others wanting libcurl4 on Debian). Is this what you mean, or do you just mean an older version of curl itself? And in particular, how old and what programs are requiring it because you may be able to just update the repos and have everything run off of the newest versions.
if you're using a standard dynamically-compiled curl, then it's tricky because it will try to load the old libcurl from /usr/lib/x86_64-linux-gnu/libcurl.so.4 or something like that, but a statically compiled curl? you can just download it and put it wherever you want, it's standalone and static after all.
following the instructions from https://stackoverflow.com/a/56394968/1067003 with compiler flags "-s -Os" to tell the compiler to optimize for size, here is a statically compiled 64bit linux curl version 7.65.0 with httpS support via statically compiled openssl version 1.1.1c, which is xz-compressed and base64-encoded: https://pastebin.com/HhMYYQAS
use the following command to decompress it:
wget -O- 'https://pastebin.com/raw/HhMYYQAS' | base64 -d | xz -d > curl_static;chmod +x curl_static;
(i can't inline the base64 because it's too big for stackoverflow answers)
You can try out the static curl library:
https://github.com/moparisthebest/static-curl
I tried it on an old system, and it works wonder.
Even better is that build script is provided, so you can build it yourself if using third party binary is a concern.

Issue with hp-health-10.50-1826.38.rhel6.x86_64 rpm package in customized version of Linux

I am using a customized rh6 version and have a script hpasmxld_reset.sh that is obtained after installing the RPM -> hp-health-10.50-1826.38.rhel6.x86_64.The script hpasmxld_reset.sh display errors on execution.
There is an update/advance version to hp-health-10.50-1826.38.rhel6.x86_64, it is hp-health-10.60-1833.32.rhel7.x86_64.rpm .I want to check if the hpasmxld_reset.sh is fixed in this later 10.60 version .
My query is if I install hp-health-10.60-1833.32.rhel7.x86_64.rpm on an rh6 machine then would that function appropriately or not ? What should be kept in mind before installing a pkg that has a version above than the present version of the OS.
You probably won't be able to install it, since it is the wrong distro. You should be able to download it and extract all the files with rpm2cpio file.rpm | cpio -div and then you'll have a copy of the new script file to compare to the old one.

Error building a script for linux

I'm trying to build a script for linux to help me each time I install linux from scratch.
The Script have to 1.- Add repositories 2.- Install software from those repositories.
Adding repositories are not the problem, the problem is when i try to install software from this repo.
For the Repo:
sudo add-apt-repository -y ppa:webupd8team/java
After that, the script should make an update, so:
sudo apt-get update
It looks simple, but is not, because I receive an error:
The command Update could not be found.
And so on the rest of the softwares
apt-get -y install oracle-java8-installer
The package oracle-java8-installer couldn't be found..
I really don't know what should I do, nothing looks to work, I gave full rigths to the file and so on... always the same error.
But if I run the command apt-get install direct from the terminal, works without problem..
Any help?
actually I wrote a script in windows to use it in future Linux installations, for some reasons it doesn't work as I want it. Thinking it was a command or misspelled words, I search for a solution, wich didn't help anyways.
Debugging my script in a virtual Machine, I found that the script was giving some random errors like '/r' doesn't support and like that. Really weird because after searching in my script for that line code I didn't find it.
With that in mind, I search again for those errors, and found that for some reasons, if you write your code in a Windows maschine, it save it in a crlf type, wich in a Linux system is interpreted really wrong.
A solution of some users was converting the type from CRLF to LF, wich in linux is using the command dos2unix.
dos2unix filename.sh
After making that and runing my script again everything works perfectly.

<br>how to install nagios check_procs plugin in nagios</br>

I am new to nagios and I have installed nagios 3 on my linux machine.
i want to install nagios check_procs plugin.can any one suggest me.thanks
You can install from package which depends on Linux distribution you use.
If it is rpm based then install "nagios-plugins" package.
rpm -qf /usr/lib64/nagios/plugins/check_procs
nagios-plugins-1.4.15-2.el6.rf.x86_64
From the tags you've marked on your question, I assume you are using ubuntu as Operative System to your Nagios' Server,
First of all try to verify where is your resources file
# find /* -name resource.cfg
The answer should be something like '/usr/local/nagios/etc/resource.cfg'
Then find where are your plugins, pointed in the resources by the $USER1$ variable (the code below assumes your resources.cfg is in /usr/local/nagios/etc/
# grep '\$USER1\$' /usr/local/nagios/etc/resource.cfg
You'll get the folder of your scripts (in my case it is /usr/local/nagios/libexec/):
$USER1$=/usr/local/nagios/libexec
If in that folder you do not find a check_procs, than you'll need to install a newer version of nagios plugins:
- you can either run the command bellow
apt-get install nagios-plugins
Otherwise you can go to the official Nagios' site and download/install the plugins package: http://www.nagios.org/download/plugins, inside the nagios-plugins .tar.gz archive there is a README file with good instructions for the manual installation process

How to install Node.js only if needed (not already installed) on a vagrant shell?

I'm using vagrant shell provisioning here.
I've installed on my vm Node.js along with many other packages.
I want to avoid running parts in my provisioning script when I don't need them.
For example - I already successfully installed via my script Node.js & nginx, so when I want to add additional packages like mysql or redis, I want to add it to the script, I want to run the script to test that it runs properly, but I DO NOT want to re-install Node.js or nginx again...
I need a simple conditional statement that would detect if a package is already installed, and install it only if it is not already installed.
Is there a generic check or will it be different from package to package?
Thanks
Ajar
dpkg -s <pkg-name> 2>/dev/null >/dev/null || sudo apt-get -y install <pkg-name>
This should be what you're looking for.
What's going on here:
This is a conditional assignment of the form <condition> && <value if true> || <value if false>
The first part of the expression uses dpkg to check to if the package is installed, suppressing the output. The second part is evaluated if the condition returns false. The "true" case is omitted.
This dependes on the Linux distribution you are using. Usually, a package manager comes with some kind of mechanism to skipp already installed packages.
For Ubuntu, this is built in - running apt-get install nodejs with Node.js already installed will not reinstall it; it will skip the target (unless there is new version available)
For ArchLinux, you can add run pacman -Sy node --needed to skip already installed packages.
A platform-independent mechanism would be to check if the executable (or any other known file for that package) exists. In Bash, you can do:
which node > /dev/null && echo "Yup, this is installed"
(the > /dev/null part supresses which's output - it prints the path where the found executable resides; we do not care about that, we only want to know if it is installed)
If you want to avoid writing custom Bash scripts for such basic checks I can recommend that you configure your boxes with tools dedicated for exactly what you are trying to achieve. The usual suspects here are:
Ansible
Puppet
Chef
CFEngine
All of these are supported by Vagrant so integrating them should not be a problem. You can find detailed guides on integrating these into your existing Vagrant recipe here.
PS. For a simple exapmle you can check out my Ansible provisioning recipe for Banana Pi machine running ArchLinux (note: it does not really follow best practices, but it might be a good starting point). There are many examples available online, check them out, too.

Resources