[ale] Need AWK Guru input

Chuck Payne terrorpup at gmail.com
Mon Aug 1 11:34:51 EDT 2011


On Mon, Aug 1, 2011 at 11:24 AM, Andrew Wade <andrewiwade at gmail.com> wrote:
> Dennis,
>
> I posted this last week, but here it is again.  This is the script I run
> (simplified) on each RHEL version that gets its version number and then
> subscribes it to the correct Satellite channel using activation keys:
>
>
> Also, fyi I scripted the entire registration process including creation of
> my ssl cert for my local satellite:
>
>
> (I simplified it to the below for the this thread)
>
> #!/bin/bash
>
>
> ### Variables  -> Need to be updated for rhel 3 servers ( ) and rhel 4
> servers ()
> RHEL3_VER=`cat /etc/redhat-release | awk '{print $7}'`
> RHEL3_Point=`cat /etc/redhat-release | awk '{print $10}' | cut -c 1`
>
>
> RHEL_VER=$RHEL3_VER$RHEL3_Point
> ARCH=`uname -a | awk '{ print $12 }'`
>
> cp /etc/sysconfig/rhn/up2date /etc/sysconfig/rhn/up2date.bk
> cp /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT
> /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT.bk
>
> ## Remove old rhn.redhat.com entry if it exists
> perl -npe 's/RHNS-CA-CERT/RHN-ORG-TRUSTED-SSL-CERT/g' -i
> /etc/sysconfig/rhn/*
> perl -npe 's/xmlrpc.rhn.redhat.com/mysatellite.my.domain/' -i
> /etc/sysconfig/rhn/up2date
>
> ## Insert correct SSL Cert and GPG Key
>
> cat > /tmp/gpg-key-1 <<'EOF'
> -----BEGIN PGP PUBLIC KEY BLOCK-----
> xxxxxxxxxxxxxxxxxxx
> -----END PGP PUBLIC KEY BLOCK-----
>
> EOF
> # gpg-key1
> rpm --import /tmp/gpg-key-1
>
>
>
> cat > /tmp/ssl-key-1 <<'EOF'
> Certificate:
> xxxxxxxxxxxxxxxxxxxxx
> -----END CERTIFICATE-----
> EOF
> # ssl-key1
> cat /tmp/ssl-key-1 > /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT
>
>
>
> if [ $RHEL_VER = 38 -a $ARCH = i686 ]
> then
>                         rhnreg_ks --activationkey=1-xxx --force
>                         service rhnsd stop
>                         chkconfig rhnsd off
> fi
>
>
> if [ $RHEL_VER = 45 -a $ARCH = x86_64 ]
> then
>                         rhnreg_ks --activationkey=1-xxx --force
>                         service rhnsd stop
>                         chkconfig rhnsd off
> fi
>
>
> if [ $RHEL_VER = 46 -a $ARCH = i686 ]
> then
>                         rhnreg_ks --activationkey=1-xxx --force
>                         service rhnsd stop
>                         chkconfig rhnsd off
> fi
>
>
> if [ $RHEL_VER = 46 -a $ARCH = x86_64 ]
> then
>                         rhnreg_ks --activationkey=1-xxx --force
>                         service rhnsd stop
>                         chkconfig rhnsd off
> fi
>
> if [ $RHEL_VER = 48 -a $ARCH = i686 ]
> then
>                         rhnreg_ks --activationkey=1-xxx --force
>                         service rhnsd stop
>                         chkconfig rhnsd off
> fi
>
> if [ $RHEL_VER = 48 -a $ARCH = x86_64 ]
> then
>                         rhnreg_ks --activationkey=1-xxx --force
>                         service rhnsd stop
>                         chkconfig rhnsd off
> fi
>
> if [ $RHEL_VER = 5.3 -a $ARCH = x86_64 ]
> then
>                         service yum-updatesd stop
>                         chkconfig yum-updatesd off
>                         rhnreg_ks --activationkey=1-xxx --force
>
> fi
>
> if [ $RHEL_VER = 5.4 -a $ARCH = x86_64 ]
> then
>
>                         service yum-updatesd stop
>                         chkconfig yum-updatesd off
>                         rhnreg_ks --activationkey=1-xxx --force
>
> fi
>
> if [ $RHEL_VER = 5.4 -a $ARCH = i686 ]
> then
>                         service yum-updatesd stop
>                         chkconfig yum-updatesd off
>                         rhnreg_ks --activationkey=1-xxx --force
>
> fi
>
> if [ $RHEL_VER = 5.6 -a $ARCH = x86_64 ]
> then
>                         service yum-updatesd stop
>                         chkconfig yum-updatesd off
>                         rhnreg_ks --activationkey=1-xxx --force
>
> fi
>
> if [ $RHEL_VER = 5.6 -a $ARCH = i686 ]
> then
>                         service yum-updatesd stop
>                         chkconfig yum-updatesd off
>                         rhnreg_ks --activationkey=1-xxx --force
>
> fi
>
> if [ $RHEL_VER = 6 -a $ARCH = x86_64 ]
> then
>                         service yum-updatesd stop
>                         chkconfig yum-updatesd off
>                         rhnreg_ks --activationkey=1-xxx --force
>
> fi
>
>
>
> On Mon, Aug 1, 2011 at 11:17 AM, Dennis Ruzeski <denniruz at gmail.com> wrote:
>>
>> Something like this?
>>
>> cat /etc/redhat-release |awk  '/release/ { for (x=1;x<=NF;x++) if
>> ($x~"release") print $(x+1) }'
>>
>> --Dennis
>>
>>
>>
>> On Mon, Aug 1, 2011 at 10:52 AM, Chuck Payne <terrorpup at gmail.com> wrote:
>> > Guys,
>> >
>> > I am working on adding servers to my Satellite server, and I like to
>> > be able to get in with a script and call on the following
>> >
>> > /etc/redhat_release
>> >
>> > But I only want to get the number, so that I can see if it RHEL 4 or
>> > 5, I been trying to do with awk, but I am not able to get anything,
>> > what is the best way to only put numbers?
>> >
>> > --
>> > (678) 636-9678
>> > -----------------------------------------
>> > Discover it! Enjoy it! Share it! openSUSE Linux.
>> > -----------------------------------------
>> > openSUSE -- en.opensuse.org/User:Terrorpup
>> > openSUSE Ambassador/openSUSE Member
>> > skype,twiiter,identica,friendfeed -- terrorpup
>> > freenode(irc) --terrorpup/lupinstein
>> > Register Linux Userid: 155363
>> >
>> > Have you tried SUSE Studio? Need to create a Live CD,  an app you want
>> > to package and distribute , or create your own linux distro. Give SUSE
>> > Studio a try. www.susestudio.com.
>> >
>> > _______________________________________________
>> > Ale mailing list
>> > Ale at ale.org
>> > http://mail.ale.org/mailman/listinfo/ale
>> > See JOBS, ANNOUNCE and SCHOOLS lists at
>> > http://mail.ale.org/mailman/listinfo
>> >
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>

Andrew,

You might want to add the following so you don't get an error (-14)

rm -rf /var/cache/yum/*
yum clean all
rhn-profile-sync

Chuck

-- 
(678) 636-9678
-----------------------------------------
Discover it! Enjoy it! Share it! openSUSE Linux.
-----------------------------------------
openSUSE -- en.opensuse.org/User:Terrorpup
openSUSE Ambassador/openSUSE Member
skype,twiiter,identica,friendfeed -- terrorpup
freenode(irc) --terrorpup/lupinstein
Register Linux Userid: 155363

Have you tried SUSE Studio? Need to create a Live CD,  an app you want
to package and distribute , or create your own linux distro. Give SUSE
Studio a try. www.susestudio.com.



More information about the Ale mailing list