Page 1 of 1

Disable All Repos via Bash Script?

Posted: 2018/02/12 16:17:14
by Zer0Cool
Hello,

I am looking to work out a bash script to simply disable all of the YUM repos permanently. I know I can do this manually a variety of ways I am just not sure of the best way to automated to process via a script.

I am only concerned with the repos listed in /etc/yum.repos.d/

I was considering using something like sed -i and looping the files in the folder. I just feel like there has to a be a better way. However I go about it has to be with standard packages, I cant install additional software to make this possible.

I have been googling this for a while and haven't found much information for blanket disabling all repos.

Any help would be greatly appreciated. Thanks

Re: Disable All Repos via Bash Script?

Posted: 2018/02/12 16:22:39
by TrevorH
man yum-config-manager perhaps?

Re: Disable All Repos via Bash Script?

Posted: 2018/02/12 19:00:02
by Zer0Cool
I am familiar with yum-config-manager.

I tired using something like:

Code: Select all

yum-config-manager --disable *
but it didnt disable anything. Seems it expects some input (or I goofed the syntax for a wildcard value).

Not sure if thats what you had in mind or if there is another command/arg I missed.

EDIT: I feel silly, looks like syntax for all is "\*" without quotes. Ill give it a shot. Thanks

EDIT2: Its odd, even after doing this:

Code: Select all

yum listrepos enabled
still lists out the same repos as prior to the --disable \* command. Looking at the actual repo files, CentOS-Base.repo for example doesnt have enabled=0 for each section only the [centosplus] section. All others do not have an enabled line at all.

It seems to me they are still enabled, am I incorrect?

EDIT3: Also, isnt yum-config-manager installed with yum-utils? Is there a way to accomplish my goal without installing additional packages?

Re: Disable All Repos via Bash Script?

Posted: 2018/02/12 19:35:05
by avij
Odd, when I run yum-config-manager --disable \* and then yum repolist I don't see any enabled repositories. I don't know why this doesn't work for you.

If you want to disable the repositories permanently, you could just as well remove the .repo files from /etc/yum.repos.d, or move them to some other directory if your "permanent" isn't really "permanent".

Re: Disable All Repos via Bash Script?

Posted: 2018/02/12 20:11:49
by Zer0Cool
Oddly enough, that's what I currently do. It was recommended to me by a co-worker that I instead disable them instead of moving them out of the directory.

Maybe ill wipe the VM and set up anew and try again to test it out. Possible I did something previously in the VM to cause an issue I guess.

Also interested to see if there is a way to do it without requiring installation of additional packages (if i recall, yum-utils isnt part of the default workstation/server with GUI install). I see now though that something like sed would be problematic if the enabled line is missing from a section of the repo file.

EDIT: Works on a newly installed VM. I must have goofed something on the old one prior. Thanks!

Re: Disable All Repos via Bash Script?

Posted: 2018/02/12 23:57:56
by TrevorH
Don't move them away - next time a -release package is updated they will come back.