Let's say that i want to install specific package from ubuntu repos, but all depends of codename. For example, on ubuntu 14.04 lts there is a package called librabbitmq1, and on ubuntu 16.04 librabbitmq4. Depends on codename i want to choose existing one.
"If ubuntu_codename=trusty install librabbitmq1
else
install librabbitmq4"
or something like this...
"If apt-get install librabbitmq1 returns 1 (or positive) install that, else install librabbitmq4"
A simple one-liner in bash could do the trick which works on the return-code(s) of the commands executed.
sudo apt-get install librabbitmq1 || echo "librabbitmq1 Installation failed" && sudo apt-get install librabbitmq4 || echo "librabbitmq4 Installation failed"
Related
In preparation for supporting a Python 2 legacy application I just installed Ubuntu 18.04.5, which includes Python 3 but not Python 2. Pretty much every Python 2 install tutorial website shows the following command for installing Python 2:
sudo apt-get install python2
Upon which I get:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python2
Some sites list these commands first so I tried these as well:
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install python2
This gives the same results as above.
I setup Ubuntu 20.04 on a different computer and installed Python 2 about a month ago and I could swear I used the same commands and at that time it worked. I also remember something about Python 2 being decommissioned at the end of January 2021 (which just passed).
Was the Python 2 pip package taken down? Is there some way I can verify this? If so, is there some special curl command that can still download Python 2 or a website I can download it from?
After searching the Ubuntu packages, it seems that for some odd reason for Ubuntu 20.04 the name of the Python 2 package is python2 but for Ubuntu 18.04 there is no package named python2. It seems that for Ubuntu 18.04 by running:
sudo apt-get install python-pip
This installs both pip for Python 2 and Python 2 itself, so this seems to be the best option
I am learning python and bash. I would like to setup a script with them so that I can run a single command to install these programs to work with python 3:
Pip
Pymongo
Mongodb
Setuptools
Xdg
Apt-get update
Boto3
opencv
How would I go about learning this or or are there some templates already out there?
hi it`s about your question.
you just need to understand and function in bash
it is expressed with &&
Ex.
#!/bin/bash
function_name(){
apt-get install Pip &&
apt-get install Pymongo &&
apt-get install Mongodb &&
apt-get install Xdg &&
apt-get update &&
apt-get install Boto3 &&
apt-get install opencv
}
function_name
it is just way how to do it but i have 2 notes
1st note: "Dont forget to run script as superuser"
and second: "if you will type in last install '&&' you will reache to loop"
I have a little problem to install Wine on my alpine image.
Here is my Dockerfile :
RUN dpkg --add-architecture i386 && sudo apt-get update
RUN sudo apt-get install software-properties-common python-software-properties
RUN sudo add-apt-repository ppa:ubuntu-wine/ppa
RUN sudo apt-get update
RUN sudo apt-get install wine1.8 winetricks
RUN sudo apt-get purge software-properties-common python-software-properties
RUN rm -rf /tmp/* /var/lib/apt/lists/* /root/.cache/*
CMD /bin/bash;
All seems to work well, but during the sudo apt-get install wine1.8 winetricks I have this EULA screen :
Of course I don't have the right to write "YES". I tried :
RUN echo "yes" | sudo apt-get install wine1.8 winetricks
RUN sudo apt-get -y install wine1.8 winetricks
What can I do ?
Note: In the interest of edification, I would love it if a more learned linux/docker user could explain the mechanics behind why my solution worked for me.
Possible Solution:
I encountered this exact problem. I must have tried every conceivable way to pass an argument via my Dockerfile that would accept the EULA; to include piping an echo of "yes" to the wine installation command, as you've tried, setting environment variables and so-on. So, you're not alone here. I did, however, find a very simple solution through experimentation.
It turns out that if you install the TrueType core fonts (the package the EULA is for) before installing wine, you can pass it the "yes" input like so and wine will never prompt for the EULA:
RUN echo "yes" | apt install ttf-mscorefonts-installer -y
I'm not sure why this is. I suspect that it's because installing wine installs several other packages/dependencies in the process, and the echo/pipe approach does not extend to all packages that wine attempts to install. Perhaps by installing the fonts separately, the wine installation script either disregards the package because it's already present, or some file within the font installation logs the EULA acceptance response.
Here's the contents of my Dockerfile. I'm on Ubuntu 16.04 LTS, using Docker version 18.02.0-ce, build fc4de44:
FROM ubuntu:16.04
RUN dpkg --add-architecture i386
RUN apt-get update -y
RUN echo "yes" | apt install ttf-mscorefonts-installer -y
RUN apt-get install wine -y
I see it's four months since this post was made, but if you haven't found a solution, I hope this helps!
I want to install Rstudio for ubuntu, so I used the link https://www.rstudio.com/products/rstudio/download/ after that I choosen RStudio 0.99.893 - Ubuntu 12.04+/Debian 8+ (64-bit) then I opened with Ubuntu software center. In that I clicked the install button I got error box like this,
Requires installation of untrusted packages
This requires installing packages from unauthenticated sources.
How to solve this problem?
The unauthenticated package required by RStudio is libjpeg62, so install the package separately and then install rstudio from software center
In the terminal run the following for installing libjpeg62
sudo apt-get install --allow-unauthenticated libjpeg62
Then go back to installing rstudio.
Note: you need to install r interpretor along with rstudio this you can do by following
sudo apt-get install r-base
# Install R and RStudio on Ubuntu 14.04
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
# Download and Install RStudio
sudo apt-get install gdebi-core
wget https://download1.rstudio.org/rstudio-1.0.44-amd64.deb
sudo gdebi rstudio-1.0.44-amd64.deb
Runs following commands :
In order to install RStudio on Ubuntu 18.04 we will first need to install the r-base package. Open up terminal and enter:
$ sudo apt update
$ sudo apt -y install r-base
To install DEB file on Ubuntu Linux is by using the gdebi command.
In case gdebi is not available on your system you can install it by executing the bellow command:
$ sudo apt install gdebi-core
All Package(builds) are available : in this link or link. You can select different package.
I had download and install : rstudio-xenial-1.1.463-amd64.deb build(package) from above in this link.
$ wget https://s3.amazonaws.com/rstudio-dailybuilds/rstudio-xenial-1.1.463-amd64.deb
$ sudo gdebi rstudio-xenial-1.1.463-amd64.deb
To Start R-Studdio from following command :
$ rstudio
I have made a C program, but it depends on the ncurses library. So, when i give my code to anyone else, I have to ask him/her to install ncurses library first then only compile the code using the Makefile i provided.
However, I want to write a shell script which will automatically install ncurses if it is NOT already installed. So that I can simply ask my friend to run the script.
This is what i want the script to do ::
if(ncurses-dev package not installed)
sudo apt-get install ncurses-dev
I know it is a very basic question, but i dont know how to do it. I tried google search but could not find a simple tutorial which i could understand.
For fedora
if ! rpm -qa | grep -qw $package_name$; then
yum install $package_name
fi
For UBUNTU
#!/bin/sh
for package; do
dpkg -s "$package" >/dev/null 2>&1 && {
echo "$package is installed."
} || {
sudo apt-get install $package
}
done
This can be used for checking multiple packages as well.
To automatically install without user interaction on Debian(In your case Ubuntu), you could use the --force-yes --yes switches in your command line args list. Like so:
sudo apt-get --force-yes --yes install package