Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vagrant supressing non-zero exit staus for shell provisioner

I'm having a script provisioner in vagrant. My box is ubuntu 64bit Precise. The relevant lines of my script look like this:

sudo bash -c 'echo "deb https://oss.oracle.com/debian/ unstable main non-free" >/etc/apt/sources.list.d/oracle.list'
wget -q https://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add -

sudo apt-get update -qq

The error code is:

W: GPG error: https://oss.oracle.com unstable Release: The following signatures were invalid: KEYEXPIRED 1378511808 KEYEXPIRED 1378511808 KEYEXPIRED 1378511808
W: Failed to fetch https://oss.oracle.com/debian/dists/unstable/main/binary-amd64/Packages  The requested URL returned error: 404

W: Failed to fetch https://oss.oracle.com/debian/dists/unstable/non-free/binary-amd64/Packages  The requested URL returned error: 404

E: Some index files failed to download. They have been ignored, or old ones used instead.
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

The problem is that despite I know that the repo has expired keys and is not for 64bit architecture (32bit only). Still I'd like to install relevant packages from it (which is possible, using: <package_name>:i386). However during update due to non-exit status vagrant stops and doesn't continue my script any more.

Is there a way (either of vagrant or on the apt-get side) to make vagrant happy and continue execution of my script?

like image 574
Peter Butkovic Avatar asked Nov 12 '13 08:11

Peter Butkovic


2 Answers

You can force the error status to zero using ; true:

sudo sh -c "apt-get update -qq ; true"
like image 103
Igor Chubin Avatar answered Sep 24 '22 15:09

Igor Chubin


A slightly simpler approach than Igor's suggestion is to make it a boolean statement:

apt-get update -qq || true

This avoids invoking an unnecessary subshell.

like image 40
Scott Buchanan Avatar answered Sep 22 '22 15:09

Scott Buchanan