Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I check that the "enabled=1" repositories have "gpgcheck=1" in the "/etc/yum.repos.d/" directory (and the "gpgkey=" file exist or not?)?

Q: I'm searching for a solution to do this (oneliner?), I mean to list all the "enabled=1" repositories and "gpgcheck" status, and does the "gpgkey=XXX" file exist or not? - the problem is that that one .repo file could contain several repositories!

p.s.: afaik the "gpgkey=XXX" -> XXX could only be a local file, not an url through http... but fix me if I'm wrong..

share|improve this question
    
The oneliner will be ugly if rpm/yum don't have this functionality themselves. –  lynxlynxlynx Dec 17 '12 at 10:30

1 Answer 1

up vote 0 down vote accepted

Can't think of any kind of simple way to do this. Whipped the following together, though it's not particularly elegant.

sed '/^\[.*\]/s,\[,\n<<[,' /etc/yum.repos.d/*.repo |
  awk '
    BEGIN { 
      RS = "\n<<"
    }
    /\nenabled=1/ && !/\ngpgcheck=1/ {
      print $1"~gpgcheck disabled for enabled repo"
    }
    /\nenabled=1/ &&  /\ngpgcheck=1/ && !/\ngpgkey=/ {
      print $1"~gpgcheck enabled for enabled repo, but missing gpgkey setting"
    }
    /\nenabled=1/ &&  /\ngpgcheck=1/ && /\ngpgkey=/ {
      print $1"~gpgcheck enabled for enabled repo, see output below for gpgkey file status"
    }
  ' | column -ts~

printf "\nChecking gpg keys for enabled repos\n"

sed '/^\[.*\]/s,\[,\n<<[,' /etc/yum.repos.d/*.repo |
  awk '
    BEGIN { 
      RS = "\n<<"
    }
    /\nenabled=1/ && /\ngpgcheck=1/ && /\ngpgkey=/
  ' |
    awk -F: /^gpgkey=/{print\$2} |
      xargs ls -l                                                                                         

Drop it into a script and you're off.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.