Changeset 79
- Timestamp:
- 06/01/07 11:44:27
(2 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
| r62 |
r79 |
|
| 35 | 35 | #!/bin/sh |
|---|
| 36 | 36 | |
|---|
| | 37 | out_file="installer.sh" |
|---|
| | 38 | out_file_path="/root" |
|---|
| | 39 | |
|---|
| 37 | 40 | # DO NOT MODIFY anything below here |
|---|
| 38 | 41 | SERVICES_REQ="atd auditd crond iptables network syslog" |
|---|
| … | … | |
| 54 | 57 | `chkconfig --level 3 $service on` |
|---|
| 55 | 58 | done |
|---|
| | 59 | |
|---|
| | 60 | # Save an installer script to root's homedir |
|---|
| | 61 | |
|---|
| | 62 | echo "Saving an install script to root's home directory." |
|---|
| | 63 | cat >> $out_file_path/$out_file <<'EOF'#!/bin/sh |
|---|
| | 64 | VERSION="2.0" |
|---|
| | 65 | RELEASE="1" |
|---|
| | 66 | UNAME="/bin/uname" |
|---|
| | 67 | WGET="/usr/bin/wget" |
|---|
| | 68 | MD5SUM="/usr/bin/md5sum" |
|---|
| | 69 | ID="/usr/bin/id" |
|---|
| | 70 | RPM="/bin/rpm" |
|---|
| | 71 | |
|---|
| | 72 | RPM_OPTS="--force -Uvh" |
|---|
| | 73 | |
|---|
| | 74 | ARCH=$($UNAME -i) |
|---|
| | 75 | ARCH_64="x86_64" |
|---|
| | 76 | ARCH_32="i386" |
|---|
| | 77 | |
|---|
| | 78 | URL="http://10.1.4.3/zcutlip" |
|---|
| | 79 | CLIP_RPM="clip-$VERSION-$RELEASE.$ARCH.rpm" |
|---|
| | 80 | REFPOL_RPM="selinux-policy-clip-$VERSION-$RELEASE.noarch.rpm" |
|---|
| | 81 | CLIP_MD5="$CLIP_RPM.md5" |
|---|
| | 82 | REFPOL_MD5="$REFPOL_RPM.md5" |
|---|
| | 83 | |
|---|
| | 84 | USAGE="This script will use wget to download and install \n \ |
|---|
| | 85 | $CLIP_RPM and\n \ |
|---|
| | 86 | $REFPOL_RPM\n \ |
|---|
| | 87 | from $URL.\n \ |
|---|
| | 88 | Internet connectivity is required. \n \ |
|---|
| | 89 | To install, invoke $0 with the -i option." |
|---|
| | 90 | |
|---|
| | 91 | download() { |
|---|
| | 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 | |
|---|
| | 102 | check() { |
|---|
| | 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 | |
|---|
| | 111 | inst() { |
|---|
| | 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 | |
|---|
| | 125 | while [ ! -z $1 ] |
|---|
| | 126 | do |
|---|
| | 127 | case "$1" in |
|---|
| | 128 | -i) INSTALL="TRUE";; |
|---|
| | 129 | *) break:: |
|---|
| | 130 | esac |
|---|
| | 131 | shift |
|---|
| | 132 | done |
|---|
| | 133 | |
|---|
| | 134 | if [ 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 |
|---|
| | 153 | else |
|---|
| | 154 | echo -e $USAGE |
|---|
| | 155 | exit 0 |
|---|
| | 156 | fi |
|---|
| | 157 | EOF |
|---|
| | 158 | chmod +x $out_file_path/$out_file |
|---|
Download in other formats:
* Generating other formats may take time.