0

The script below is to download, check integrity, extract, remove archive files and install GnuPG 2.1.x.

I reliased that the script fails to proceed if it's run as sudo, sudo -i etc. It generates error when checking dependencies for libgcrypt-1.7.6, the second lib, because the libgpg-error-1.27, the first one, is not found by configure of the libgcrypt-1.7.6. I intentionally put libgpg-error above libgcrypt to have it worked.

If I run the script as root, not by account with sudo, it passes everything and eventually gets completed. My account has the full access as sudo. If I check visudo, there is a line right below root:

myaccname    ALL=(ALL)    ALL

What can cause such problems? I am asking about it because I would to install this on my computer at work where I have only sudo access, not the root.

Thanks

#!/bin/bash

CD=$(pwd)
FOLDER=/opt/homeusr/gpg-install

mkdir --parents $FOLDER && \
cd $FOLDER && \

wget -c https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.1.21.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.1.21.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.4.3.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.4.3.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.3.5.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.3.5.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/npth/npth-1.4.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/npth/npth-1.4.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.1.1.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.1.1.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/pinentry/pinentry-1.0.0.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/pinentry/pinentry-1.0.0.tar.bz2.sig && \
wget -c https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-1.9.0.tar.bz2 && \
wget -c https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-1.9.0.tar.bz2.sig && \
wget -c ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz && \
wget -c ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz.sig && \

gpg2 --verify libgpg-error-1.27.tar.bz2.sig libgpg-error-1.27.tar.bz2 && \
gpg2 --verify libgcrypt-1.7.6.tar.bz2.sig libgcrypt-1.7.6.tar.bz2 && \
gpg2 --verify libassuan-2.4.3.tar.bz2.sig libassuan-2.4.3.tar.bz2 && \
gpg2 --verify libksba-1.3.5.tar.bz2.sig libksba-1.3.5.tar.bz2 && \
gpg2 --verify npth-1.4.tar.bz2.sig npth-1.4.tar.bz2 && \
gpg2 --verify ntbtls-0.1.1.tar.bz2.sig ntbtls-0.1.1.tar.bz2 && \
gpg2 --verify pinentry-1.0.0.tar.bz2.sig pinentry-1.0.0.tar.bz2 && \
gpg2 --verify gpgme-1.9.0.tar.bz2.sig gpgme-1.9.0.tar.bz2 && \
gpg2 --verify gnupg-2.1.21.tar.bz2.sig gnupg-2.1.21.tar.bz2 && \
gpg2 --verify ncurses-6.0.tar.gz.sig ncurses-6.0.tar.gz && \

tar -xjf libgpg-error-1.27.tar.bz2 && \
tar -xjf libgcrypt-1.7.6.tar.bz2 && \
tar -xjf libassuan-2.4.3.tar.bz2 && \
tar -xjf libksba-1.3.5.tar.bz2 && \
tar -xjf npth-1.4.tar.bz2 && \
tar -xjf ntbtls-0.1.1.tar.bz2 && \
tar -xzf ncurses-6.0.tar.gz && \
tar -xjf pinentry-1.0.0.tar.bz2 && \
tar -xjf gpgme-1.9.0.tar.bz2 && \
tar -xjf gnupg-2.1.21.tar.bz2 && \

rm libgpg-error-1.27.tar.bz2 && \
rm libgpg-error-1.27.tar.bz2.sig && \
rm libgcrypt-1.7.6.tar.bz2 && \
rm libgcrypt-1.7.6.tar.bz2.sig && \
rm libassuan-2.4.3.tar.bz2 && \
rm libassuan-2.4.3.tar.bz2.sig && \
rm libksba-1.3.5.tar.bz2 && \
rm libksba-1.3.5.tar.bz2.sig && \
rm npth-1.4.tar.bz2 && \
rm npth-1.4.tar.bz2.sig && \
rm ntbtls-0.1.1.tar.bz2 && \
rm ntbtls-0.1.1.tar.bz2.sig && \
rm pinentry-1.0.0.tar.bz2 && \
rm pinentry-1.0.0.tar.bz2.sig && \
rm gpgme-1.9.0.tar.bz2 && \
rm gpgme-1.9.0.tar.bz2.sig && \
rm gnupg-2.1.21.tar.bz2 && \
rm gnupg-2.1.21.tar.bz2.sig && \
rm ncurses-6.0.tar.gz && \
rm ncurses-6.0.tar.gz.sig && \

cd libgpg-error-1.27 && ./configure && make && make install && cd ../ && \
cd libgcrypt-1.7.6 && ./configure && make && make install && cd ../ && \
cd libassuan-2.4.3 && ./configure && make && make install && cd ../ && \
cd libksba-1.3.5 && ./configure && make && make install && cd ../ && \
cd npth-1.4 && ./configure && make && make install && cd ../ && \
cd ntbtls-0.1.1 && ./configure && make && make install && cd ../ && \
cd ncurses-6.0 && ./configure && make && make install && cd ../ && \
cd pinentry-1.0.0 && ./configure --enable-pinentry-curses --disable-pinentry-qt4 && make && make install && cd ../ && \
cd gpgme-1.9.0 && ./configure && make && make install && cd ../ && \
cd gnupg-2.1.21 && ./configure && make && make install && \

echo "/usr/local/lib" > /etc/ld.so.conf.d/gpg2.conf && \
ldconfig -v && \

cd $CD && \

echo "Complete !!!"
Celdor
  • 129
  • Could the libgpg-error error be due to the inclusion of libgcrypt-1.7.6 rather than libgcrypt-1.7.7, which is listed here? – Timothy Martin Jun 06 '17 at 22:43
  • I have not not tested libcrypt-1.7.7 so I cannot say. But if libcrypt was the issue, would it show error regardless of user account: root or sudo? – Celdor Jun 06 '17 at 22:52
  • Good point. I mistakenly was looking into the error rather than the fact that it only shows up when using sudo. Perhaps it is a PATH problem. Since you have sudo access, you could switch user (su) to do the installation. sudo su - Doing it this way will change your environment to that of the root user. – Timothy Martin Jun 06 '17 at 23:07
  • @TimothyMartin sudo -s. – Chris Davies Jun 06 '17 at 23:24
  • If you make the first line of your script #!/bin/bash -e you can dispense with all of those line-continuation markers. The flag tells the shell to exit immediately on failure. – Chris Davies Jun 06 '17 at 23:28
  • @roaima Thanks for teaching me! I just tried sudo -s but the PATH remained that of the non-root user. – Timothy Martin Jun 06 '17 at 23:36
  • @TimothyMartin i'll have a go with sudo su - tomorrow. Ty – Celdor Jun 06 '17 at 23:37
  • @roaima i did not know about it. It's a great clue. Ty – Celdor Jun 06 '17 at 23:41
  • If you're looking for useful flags the other one is -x, which switches on line tracing during execution. You can also switch it on and off during the script with set -x and set +x. – Chris Davies Jun 07 '17 at 08:38
  • sudo -s failed as well. The error was the same: configure: error: libgpg-error is needed. Timothy's suggestion: sudo su - worked BTW. Thanks – Celdor Jun 07 '17 at 09:20
  • @roaima I have just installed gpg2 and missed your last comment and did not do anything apart from using -e. What does tracing do exactly? Does it show anything extra or perhaps save into a log into a file? Thanks – Celdor Jun 07 '17 at 09:29

0 Answers0