{"id":1463,"date":"2017-08-02T20:44:09","date_gmt":"2017-08-03T02:44:09","guid":{"rendered":"https:\/\/mrguitar.net\/?p=1463"},"modified":"2017-08-02T20:44:09","modified_gmt":"2017-08-03T02:44:09","slug":"controlling-repos-with-sed","status":"publish","type":"post","link":"https:\/\/mrguitar.net\/?p=1463","title":{"rendered":"Controlling repos with sed"},"content":{"rendered":"<p>As a RHEL &amp; Fedora user of Atomic Host, I find myself using package layering on a regular basis. I typically only want a limited selection of repos enabled to keep the metadata transfers to a minimum. This is really simple with the default Fedora repos, but can be trickier with RHEL depending on the subscription that&#8217;s attached to the system. Subscription-manager can quickly disable everything and then enable the desired repos, but it&#8217;s a slower command to execute as it connects to the CDN. Anyway, I found this sed snippet handy for making this easy and quicker:<br \/>\n<!--more--><\/p>\n<p>Disable everything:<\/p>\n<pre>sed -i 's\/enabled\\ =\\ 1\/enabled\\ =\\ 0\/g' \/etc\/yum.repos.d\/redhat.repo<\/pre>\n<p>Enable the rhel-7-server-rpms repo:<\/p>\n<pre>sed -i '\/\\[rhel-7-server-rpms\\]\/,\/^ *\\[\/ s\/enabled\\ =\\ 0\/enabled\\ =\\ 1\/' \/etc\/yum.repos.d\/redhat.repo<\/pre>\n<p>Enable the rhel-7-server-extras-rpms repo:<\/p>\n<pre>sed -i '\/\\[rhel-7-server-extras-rpms\\]\/,\/^ *\\[\/ s\/enabled\\ =\\ 0\/enabled\\ =\\ 1\/' \/etc\/yum.repos.d\/redhat.repo<\/pre>\n<p>&nbsp;<\/p>\n<p>Fire it all together!<\/p>\n<pre>sed -e 's\/enabled\\ =\\ 1\/enabled\\ =\\ 0\/g' -e '\/\\[rhel-7-server-rpms\\]\/,\/^ *\\[\/ s\/enabled\\ =\\ 0\/enabled\\ =\\ 1\/' -e '\/\\[rhel-7-server-extras-rpms\\]\/,\/^ *\\[\/ s\/enabled\\ =\\ 0\/enabled\\ =\\ 1\/' -i \/etc\/yum.repos.d\/redhat.repo<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As a RHEL &amp; Fedora user of Atomic Host, I find myself using package layering on a regular basis. I typically only want a limited selection of repos enabled to keep the metadata transfers to a minimum. This is really simple with the default Fedora repos, but can be trickier with RHEL depending on the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/mrguitar.net\/?p=1463\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Controlling repos with sed&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1463","post","type-post","status-publish","format-standard","hentry","category-open-sourcenerd-stuff"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mrguitar.net\/index.php?rest_route=\/wp\/v2\/posts\/1463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mrguitar.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mrguitar.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mrguitar.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mrguitar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1463"}],"version-history":[{"count":5,"href":"https:\/\/mrguitar.net\/index.php?rest_route=\/wp\/v2\/posts\/1463\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/mrguitar.net\/index.php?rest_route=\/wp\/v2\/posts\/1463\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/mrguitar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mrguitar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mrguitar.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}