Changeset 79

Show
Ignore:
Timestamp:
06/01/07 11:44:27 (3 years ago)
Author:
zcutlip
Message:

cat installer.sh to /root/ for user to easily download and install clip and refpolicy rpms.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RHEL5/kickstart/clip.ks

    r62 r79  
    3535#!/bin/sh 
    3636 
     37out_file="installer.sh" 
     38out_file_path="/root" 
     39 
    3740# DO NOT MODIFY anything below here 
    3841SERVICES_REQ="atd auditd crond iptables network syslog" 
     
    5457    `chkconfig --level 3 $service on` 
    5558done 
     59 
     60# Save an installer script to root's homedir 
     61 
     62echo "Saving an install script to root's home directory." 
     63cat >> $out_file_path/$out_file <<'EOF'#!/bin/sh 
     64VERSION="2.0" 
     65RELEASE="1" 
     66UNAME="/bin/uname" 
     67WGET="/usr/bin/wget" 
     68MD5SUM="/usr/bin/md5sum" 
     69ID="/usr/bin/id" 
     70RPM="/bin/rpm" 
     71 
     72RPM_OPTS="--force -Uvh" 
     73 
     74ARCH=$($UNAME -i) 
     75ARCH_64="x86_64" 
     76ARCH_32="i386" 
     77 
     78URL="http://10.1.4.3/zcutlip" 
     79CLIP_RPM="clip-$VERSION-$RELEASE.$ARCH.rpm" 
     80REFPOL_RPM="selinux-policy-clip-$VERSION-$RELEASE.noarch.rpm" 
     81CLIP_MD5="$CLIP_RPM.md5" 
     82REFPOL_MD5="$REFPOL_RPM.md5" 
     83 
     84USAGE="This script will use wget to download and install \n \ 
     85$CLIP_RPM and\n \ 
     86$REFPOL_RPM\n \ 
     87from $URL.\n \ 
     88Internet connectivity is required. \n \ 
     89To install, invoke $0 with the -i option." 
     90 
     91download() { 
     92        $WGET $URL/$CLIP_RPM && \ 
     93        $WGET $URL/$CLIP_MD5 && \ 
     94        $WGET $URL/$REFPOL_RPM && \ 
     95        $WGET $URL/$REFPOL_MD5 
     96        if [ $? -ne 0 ]; then 
     97                echo "RPM download failed. Terminating." 
     98                exit 1 
     99        fi 
     100} 
     101 
     102check() { 
     103        $MD5SUM $CLIP_MD5 && \ 
     104        $MD5SUM $REFPOL_MD5 
     105        if [ $? -ne 0 ]; then 
     106                echo "Download verification failed. Terminating." 
     107                exit 1 
     108        fi 
     109} 
     110 
     111inst() { 
     112        #for i in $CLIP_RPM $REFPOL_RPM; do 
     113        for i in $CLIP_RPM; do 
     114                echo "Installing $i" 
     115                $RPM $RPM_OPTS $i 
     116                if [ $? -ne 0 ]; then 
     117                        echo "Installation of $i failed. Terminating." 
     118                        exit 1 
     119                fi 
     120        done 
     121} 
     122 
     123 
     124 
     125while [ ! -z $1 ] 
     126do 
     127        case "$1" in 
     128                -i) INSTALL="TRUE";; 
     129                *) break:: 
     130        esac 
     131        shift 
     132done 
     133 
     134if [ x$INSTALL = "xTRUE" ]; then 
     135        #some sanity checks: 
     136        if [ -z $UID ]; then 
     137                UID=$($ID -u) 
     138        fi 
     139                 
     140        if [ $UID -ne 0 ]; then 
     141                echo "Must be root to install." 
     142                exit 1 
     143        fi 
     144        if [ x$ARCH != x$ARCH_32 ] && [ x$ARCH != x$ARCH_64 ]; then 
     145                echo "Couldn't determine machine arcitecture from $UNAME -i. Terminating." 
     146                exit 1   
     147        fi 
     148        download 
     149        check 
     150        inst 
     151        echo "$CLIP_RPM and $REFPOL_RPM successfully downloaded and installed." 
     152        exit 0 
     153else 
     154        echo -e $USAGE 
     155        exit 0 
     156fi 
     157EOF 
     158chmod +x $out_file_path/$out_file