403Webshell
Server IP : 152.69.216.235  /  Your IP : 80.80.80.28
Web Server : Apache/2.4.37 (Oracle Linux Server)
System : Linux ust-wp4-prod 5.15.0-310.184.5.2.el8uek.x86_64 #2 SMP Wed Jul 9 16:08:33 PDT 2025 x86_64
User : apache ( 48)
PHP Version : 8.4.10
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/oci-linux-config/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/oci-linux-config/oci_yum_configure.sh
#!/bin/bash

# Copyright (C) 2022 Oracle. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2.  This program is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.  You should have received a copy of the GNU
# General Public License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 021110-1307, USA.
#============================================================================
# This script identifies and updates packages required to migrate dnf repo 
# configuration for OCI regions
# Usage:
#
#  oci_yum_configure.sh
#
#============================================================================

restore()
{
	for file in /etc/yum.repos.d/*-ol8.repo*bkp
	do
  		old_file=$(echo $file | sed -e "s|.bkp||")
  		mv "$file" "${old_file}"
	done

   	cleanup
}

cleanup()
{
	rm -f "$REPOLIST_FILE" "$REPOLIST_FILE_NEW" 

}



UserId=$(id -u)
if [ "$UserId" != 0 ]; then
	echo "This script should to be run as root user"
	exit
fi

if [ -f /var/run/yum.pid ]; then
	echo "Another yum command (PID:$(</var/run/yum.pid)) is holding a yum lock. Try running $0 later."
	exit
fi

RPM_TO_UPDATE=$(rpm -qa   | grep release-el8 | sed -e "s|-el8.*|-el8|"|tr '\n' ' ' )

echo "running yum update $RPM_TO_UPDATE"
dnf -y update $RPM_TO_UPDATE

REPOLIST_FILE=$(mktemp /tmp/oracle_enable_repolist.XXXXXX) || exit 1
REPOLIST_FILE_NEW=$(mktemp /tmp/oracle_enable_repolist_new.XXXXXX) || exit 1

trap 'restore' SIGHUP SIGINT SIGTERM
trap 'cleanup' EXIT


# Reconcile the channel disposition post update.
if [ $(ls -l /etc/yum.repos.d/*-ol8.repo.rpmnew  2>/dev/null | wc -l) -gt 0 ]; then

	dnf repolist | grep ^ol8 | awk '{print $1}' > "$REPOLIST_FILE"

	for file in /etc/yum.repos.d/*-ol8.repo.rpmnew
	do
		repoFile=${file//.rpmnew}
		cp -p "$repoFile" "${repoFile}.bkp"
		cp -p "$file" "$repoFile"
		mv "$file" "${file}.bkp"
	done

	dnf repolist | grep ^ol8 | awk '{print $1}' > "$REPOLIST_FILE_NEW"

	while read -r repo
	do
		if grep "$repo" "$REPOLIST_FILE" > /dev/null ; then
			echo  "Repository $repo already enabled"
		else
			echo "Disabling Repository $repo"
			dnf config-manager --disable "$repo" > /dev/null
		fi
	done < "$REPOLIST_FILE_NEW"

	while read -r repo
	do
		if grep "$repo" "$REPOLIST_FILE_NEW" > /dev/null ; then
			echo  "Repository $repo already enabled"
		else
			echo "Enabling Repository $repo"
			dnf config-manager --enable "$repo" > /dev/null
		fi
	done < "$REPOLIST_FILE"
fi

Youez - 2016 - github.com/yon3zu
LinuXploit