Help/sugestion with zypper


I’m preparing a bash script to easy my life in others Leap installations. But I have a doubt, how can I answer “yes to all” in this script? I mean, to trust in all keys and install everything without stop. Suggestions?

#!/bin/bash# For openSUSE Leap 42.2

sudo zypper up
sudo zypper dist-upgrade

echo "Packman and Libdvdcss repos for multimedia"
zypper ar -f packman
zypper ar -f libdvdcss

echo "Installing multimedia packages"
sudo zypper install ffmpeg lame gstreamer-plugins-bad gstreamer-plugins-ugly gstreamer-plugins-ugly-orig-addon gstreamer-plugins-libav libdvdcss2
sudo zypper dist-upgrade

echo "Installing apps"
sudo zypper install inkscape gimp lollypop bleachbit unetbootin wine xournal kile goldendict pdfchain uget steam octave vlc r-base git kdenlive audacity simplescreenrecorder gpsbabel

zypper ar -f
sudo zypper install jabref

zypper ar -f
sudo zypper install rstudio

zypper ar -f
sudo zypper install brackets

zypper ar -f
sudo zypper install brackets

zypper ar -f
sudo zypper install gitkraken

zypper ar -f
sudo zypper install playonlinux

zypper ar -f
sudo zypper install viking

echo "Finishing"
sudo zypper verify
sudo zypper clean

echo "Reboot?"
select yn in "Yes" "No"; do
    case $yn in
        Yes ) sudo reboot;;
        No ) exit;;

Suggest you try

man zypper

In particular:

GPG checks
Zypp verifies the authenticity of repository metadata by checking their GPG signature. If the repository metadata are signed with a trusted key and and
successfully verified, packages from that repository are accepted for installation if they match the checksum provided in the metadata. If the repository
metadata are not signed, the signature of each downloaded rpm package is checked before accepting it for installation.

   This default behavior can be tuned by explicitly setting the variables repo_gpgcheck and/or pkg_gpgcheck in the ZYpp configuration file
   (/etc/zypp/zypp.conf) to perform those checks always (if on) or never (if off).
   Disabling GPG checks is not recommended. Signing data enables the recipient to verify that no modifications occurred after the data were signed. Accepting
   data with no, wrong or unknown signature can lead to a corrupted system and in extreme cases even to a system compromise.

Install options

-l, --auto-agree-with-licenses
Automatically say yes to third party license confirmation prompt. By using this option, you choose to agree with licenses of all third-party
software this command will install. This option is particularly useful for administrators installing the same set of packages on multiple machines
(by an automated process) and have the licenses confirmed before.

-y, --no-confirm
Don’t require user interaction. Alias for the --non-interactive global option.

Do you really try to write a script that makes extensive use of zypper without even consulting the zypper man page? That is the impression I get from your question.

Hi, of course I consulted it. I’m asking for help to find a better away to solve the problem in the script, not to get impressions of my noobness.

Then, why do you not use any of the options shown there (and by grb01) in your script?

Or, when you think it should be obvious to others that you studied the man page without showing any sign of that in your post, why do you not explain why you do not use them so we can come to the kernel of your problem(s)?


I hope the shebang (the very first line of the script) i just a typo because all it will give you is just errors if you’re just going to execute it directly.

On Wed 30 Nov 2016 12:46:02 AM CST, viniciusbrbio wrote:


I’m preparing a bash script to easy my life in others Leap
installations. But I have a doubt, how can I answer “yes to all” in this
script? I mean, to trust in all keys and install everything without
stop. Suggestions?

Perhaps a different perspective… :wink:

Since your grabbing an rpm from here or there, suggest you download
them to a local directory and create a ‘plain rpm’ repo then you have
only one repo to add.

At best avoid home repos since they are of unknown quality, if there is
an actual development repo, use that.

I would also just grab the libdvdcss rpm from Videolan (it doesn’t
update often) and place this in the plain rpm directory.

Then you can always breeze by the repos to see if things are updated,
why because say a home repo user decides to start building stuff with a
later version of package x then you get this update and may disrupt your

Add repos with a gpg check as well, then do a dup from the packman one
first so it switches…

eg for Packman;

zypper ar -f -g -c -n packman pacman
zypper dup --from packman

If using btrfs, every zypper in will create a pre and post snapshot, so
if you use one zypper command to install the local rpms, it’s one
snapshot set. Else look at running a clean up via the cron jobs for
snapper and balance.

You could also just pull the repo gpg keys and add first, then add the
repos so it’s one less question for zypper to ask for, plus it will
auto check the rpms…

You could also use rsync to suck down updates from the repos and
place in the local directory via say a daily cron job.

Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE Leap 42.1|GNOME 3.16.2|4.1.34-33-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

case of “Describe the goal, not the step”:

Hmmm I see… in fact your suggestion would be better. Many thanks!

Answering the question in the original post (and I find nothing wrong with the objectives of the script),

Answering interactive questions automatically can almost always be accomplished using methods described in two Wiki pages I created…

A page describing most commonly desired options and methods when writing zypper scripts, including auto-accepting the GPG keys (which is something not found in other package management systems today, like yum)

When an interactive script already exists but you’d like to provide answers automatically, then you can use a Here Document

If you’d like to browse other useful BASH scripting methods, the following is a general list of what I’ve accumulated

If you have more complex zypper installation needs, there are a few I’ve either contributed to, or created that are posted on the web, primarily at github. An example might be if you wanted to modify your script to be usable on multiple versions of openSUSE. Describe what you want and maybe it already exists.

Lastly, you might have gotten more eyes on your post if you posted in the appropriate Forum. Instead of a “Non-Support” Forum I’d recommend the Programming and Scripting Forum


Hmmmmm I see!

Really nice! Exactly what I’m looking for. Many thanks.
I add the script in github and I will update it with these new informations soon: