User Tools

Site Tools


aix:scripts_category:download_rpm

AIX scripts download latest RPMs

[root@aixsrv1]/root/scripts# cat download_rpm_aix.sh
#!/usr/bin/ksh93
#set -x
#@(#) Download latest rpm AIX packages
# v1.0 Manu  11-2021

dir=`dirname $0`
#. $dir/.env

sn=`basename $0 | cut -d. -f1`
path_script=/root/scripts
logpath=$path_script/log
logname=$logpath/$sn.log

# Set the proxy if needed
#https_proxy=http://xx.xx.xx.xx:port/

repodir=/etc/yum/repos.d
repofile=$repodir/aixtoolbox.repo

downloaddir=/suma/rpm

debug=no

#------------------------------------------------
createrepo ()
{
ln -s /opt/freeware/etc/yum /etc/yum > /dev/null 2>&1

mkdir -p $repodir/old > /dev/null 2>&1
mv $repodir/* $repodir/old > /dev/null 2>&1

# Repofile
cat << EOF > $repofile
[ppc-7.3]
name=AIX 7.3 specific repository
baseurl=https://anonymous:anonymous@public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc-7.3/
enabled=1
gpgcheck=0

[ppc-7.2]
name=AIX 7.2 specific repository
baseurl=https://anonymous:anonymous@public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc-7.2/
enabled=1
gpgcheck=0

[ppc-7.1]
name=AIX 7.1 specific repository
baseurl=https://anonymous:anonymous@public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc-7.1/
enabled=1
gpgcheck=0

[noarch]
name=AIX NOARCH specific repository
baseurl=https://anonymous:anonymous@public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/noarch/
enabled=1
gpgcheck=0

[ppc]
name=AIX PPC specific repository
baseurl=https://anonymous:anonymous@public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/
enabled=1
gpgcheck=0
EOF

# Yum config file
cat << EOF > /etc/yum/yum.conf
[main]
plugins=1
cachedir=/var/cache/yum
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
#proxy=${https_proxy}
EOF

if [[ ${https_proxy} != '' ]]
then
echo proxy=${https_proxy} >> /etc/yum/yum.conf
fi

}

#------------------------------------------------
download ()
{
date
rm -rf $downloaddir.old
mv -f $downloaddir $downloaddir.old
mkdir -p $downloaddir # > /dev/null 2>&1

echo "# Downloading"
for repoid in $(cat $repofile | grep -p 'enabled=1' | grep '^\[' | sed 's/\[//' | sed 's/\]//')
do
  date
  echo "## $repoid"
  /usr/bin/reposync --newest-only --repoid=$repoid -p $downloaddir
  echo "# reorg $repoid"
  rm -r $downloaddir/$repoid/mariadb* $downloaddir/$repoid/community-mysql*
  mkdir $downloaddir/$repoid/tmp
  mv $downloaddir/$repoid/* $downloaddir/$repoid/tmp
  mv $downloaddir/$repoid/tmp/*/* $downloaddir/$repoid
  rm -r $downloaddir/$repoid/tmp
done

date
}


#################################################
# Main
#################################################
main ()
{
echo "# Creating repo"
createrepo
echo "# Download rpm packages"
download
}

main > $logname 2>&1
aix/scripts_category/download_rpm.txt · Last modified: 2022/03/14 14:56 by manu