Scripting package installs: Can't get proxy to work

Ah, the fine little details of coding. Not my forte. A few hours at this, and I still can’t get the proxy to work, and/or the sigs to verify. Tried numerous approaches. If you can see an obvious error with my approach, please throw me a bone, cause I’m all but done trying to get this to work:


# Downloads, verifies, and installs Libre Office.
# Must be run as root from dom0. Pass target qube as param.

# Set variables

# Check if the qube name was passed as a parameter
if [ $# -eq 0 ]
    echo "No qube name provided. Please run the script with the qube name as a parameter."
    exit 1

# Set the proxy
sudo qvm-run --pass-io -u root "export https_proxy="

# Install deps
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} \
  "apt update && apt upgrade -y && apt autoremove -y && apt install -y qubes-core-agent-networking curl"

# Download the package, signature, and hash
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} "curl -O ${LINK}${PACKAGE} \
  -O ${LINK}${HASH}"

# Get the public key associated with the signature
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} \
  "gpg --keyserver hkp:// --recv-keys AFEEAEA3"

# Import the public key associated with the signature
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} \
  "curl | gpg --import"

# Verify the hash and signature
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} "gpg --verify ${SIGNATURE}"
if [ $? -ne 0 ]
    echo "Signature verification failed. Aborting installation."
    exit 1
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} "sha256sum -c ${HASH}"
if [ $? -ne 0 ]
    echo "Hash verification failed. Aborting installation."
    exit 1

sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} "
    tar -xzf ${PACKAGE}
    sudo qubes-dom0-uninstall libreoffice -y # remove previous version
    apt install -y libglu1 libdbus-glib-1-2 libsm6 libxrender1 libxt6 libxrandr2 libxi6
    dpkg -i LibreOffice*/DEBS/*.deb"

# Clean up
sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} "rm ${PACKAGE} ${SIGNATURE} ${HASH}"

You are exporting the proxy variable on the host running the script, and executing the curl command on a remote host, it’s not going to work.

You don’t need to use export, you add the proxy directly to the curl command.

curl --proxy http://localhost:8082/ URL

Related topic.

It’s seems that human explanation doesn’t meet your expectations.
(or you don’t pay enought attention …)
I recommand a generative AI such as ChatGPT.


I did try your solution.
I couldn’t get it to work on that script. Sidelined… tried another approach in the next script. Hoping to refactor the first one once I found a working solution.

I tried this before too:

sudo qvm-run --pass-io -u root ${TARGET_TEMPLATE} \
  "curl --proxy http://localhost:8082/ | gpg --import"

Beginning to wonder if its something related to the machine and not the code.

According to your last reponse on the other thread, its appear you have not.

Any reason, for libreoffice, to not use apt install libreoffice ??
If you don’t trust the package manager, you shouldn’t trust the distro… ?

1 Like

You can’t import that key, what is why the gpg command fails.

I did. I keep getting "connection refused errors for port: 8082. Possible the ports are configured differently on this machine?

I was under the impression a direct install from the source was more secure. Is this not the case?

This works for me.

sudo qvm-run --pass-io -u root VMNAME “curl --proxy http://localhost:8082/’ | gpg --import”

1 Like

You need to remove libreoffice with apt remove.

Read again your whole script. Take your time.
If you struggle with the concept that each call of qvm-run is like a new terminal session,
just use the --proxy option (as mentionned by Renehoj).

Don’t forget to paste the exact and complete error message here.
Otherwise, it’s hard to tell what happened.

Also as mentionned by Renehof:
in first result:

1 Like