Disable All Repos via Bash Script?

General support questions
Post Reply
Zer0Cool
Posts: 10
Joined: 2018/01/24 18:43:24

Disable All Repos via Bash Script?

Post by Zer0Cool » 2018/02/12 16:17:14

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

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Disable All Repos via Bash Script?

Post by TrevorH » 2018/02/12 16:22:39

man yum-config-manager perhaps?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Zer0Cool
Posts: 10
Joined: 2018/01/24 18:43:24

Re: Disable All Repos via Bash Script?

Post by Zer0Cool » 2018/02/12 19:00:02

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?

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Disable All Repos via Bash Script?

Post by avij » 2018/02/12 19:35:05

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".

Zer0Cool
Posts: 10
Joined: 2018/01/24 18:43:24

Re: Disable All Repos via Bash Script?

Post by Zer0Cool » 2018/02/12 20:11:49

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!

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Disable All Repos via Bash Script?

Post by TrevorH » 2018/02/12 23:57:56

Don't move them away - next time a -release package is updated they will come back.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply