setup scripting for Ubuntu - bash

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"

Related

Install python 3.6 in Ubuntu

I'm running some Python script in my bitbucket pipeline.
where it's running in Ubuntu version 16.04.
following is my script.
add-apt-repository ppa:deadsnakes/ppa -y && apt-get update
apt-get -y install python3.6
apt-get -y install python3-pip
pip3 install tq1
pip3 install zstd
When trying to print
python3 -V
it's returning
Python 3.5.2.
Why it's not Python 3.6.x ?
Please note I must need Python 3.6 to run tq1.
It's a script on your device, right? Can't you just edit the lines?
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get update
sudo apt-get -y install python3.6 python3-pip
pip3 install tq1 zstd
Also, you don't need a script to install those. They're just bash commands. You can just type them line-by-line into the terminal...
Check the image on your pipeline, because if you install python 3.6 in one step and execute the python3 -V command in another, it will take the version of the image, not the one from the previous step, since they are in a different container, it would be helpful if you show us the rest of the pipeline

Docker Install Wine Dockerfile EULA

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!

Bash script to install specific package from ubuntu (if exists)

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"

RPM equivalent of pacman -Syu or apt-get update && apt-get upgrade

I just recently installed OpenSUSE Tumbleweed, and I have never used rpm based system before. I didnot find any proper guide like Archwiki for such systems.
What terminal command in OpenSUSE would be equivalent to
pacman -Syu
or
apt-get update && apt-get upgrade
in OpenSUSE?
RPM is the Package managing backend like dpkg in Ubuntu. OpenSUSE uses zypper which is its equivalent for apt.
Equivalent of apt-get update && apt-get upgrade in OpenSUSE:
zypper refresh && zypper update

How to make a script with apt-get commands?

I'm doing a script which installs a tcl plugin.
But this tcl plugin require some additional tcl/tk libraries, so I was thinking about putting an APT-GET install command for installing these libraries.
Is there a way to use the APT-GET install command in a script (it can be Shell script, Perl or even Tcl)?
This is an example of how to do it with one line and assumes you are running the script with sudo or have appropriate privilege.
apt-get -qq update && apt-get -qq --yes --force-yes install tcl
-qq suppresses output unless an error occurs
--yes answers the prompt 'Do you want to continue? [Y/n]'
--force-yes installs packages that come from a private repository
Consider running apt-get update & earlier in the script. Check or wait for the job to finish before using apt-get install
You can list multiple packages on one line. Packages are installed in the order they are listed.

Resources