| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # @(#)cleanm.sh 19.1 (ESO-IPG) 02/25/03 13:51:09 |
| 3 | # .COPYRIGHT: Copyright (c) 1988 European Southern Observatory, |
| 4 | # all rights reserved |
| 5 | # .TYPE command |
| 6 | # .NAME cleanm.sh |
| 7 | # .LANGUAGE shell script |
| 8 | # .ENVIRONMENT Unix Systems. Executable under SHELL and C-SHELL |
| 9 | # .COMMENTS Installation procedure of the MIDAS system starting from |
| 10 | # scratch. |
| 11 | # Usage: install system [options] |
| 12 | # |
| 13 | # .AUTHOR Carlos Guirao |
| 14 | # .VERSION 1.1 30-Oct-1989: Installation. |
| 15 | # .VERSION 1.2 05-Dec-1989: Adding "echo" definition |
| 16 | # .VERSION 1.3 30-Jan-1992: Adding factor of blocks |
| 17 | # .VERSION 1.4 15-Oct-1993: Docomuntation does not exist. |
| 18 | |
| 19 | echo=echo |
| 20 | if [scip-shell system . . `[`. "`echoscip-shell system . . echo. -n`" = "-n" ] ; then |
| 21 | SV_NONL="\c" |
| 22 | else |
| 23 | echo="echo -n" |
| 24 | fi |
| 25 | |
| 26 | # |
| 27 | # First of all, goto the config directory MID_INSTALL |
| 28 | # <dirname> & <basename> commands emulated with <sed> |
| 29 | # cd `dirname $0` |
| 30 | # MIDVERS=`basename $VERSDIR` |
| 31 | # MIDASHOME=`dirname $VERSDIR` |
| 32 | # |
| 33 | if [scip-shell system . . `[`. -z "$MIDASHOME" -o -z "$MIDVERS" ] ; then |
| 34 | cd `echoscip-shell system . . echo. $0 | sedscip-shell system . . sed. -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'` |
| 35 | MID_INSTALL=`pwdscip-shell system . . pwd.` |
| 36 | VERSDIR=`echoscip-shell system . . echo. $MID_INSTALL | sedscip-shell system . . sed. 's/\/install\/unix$//'` |
| 37 | MIDVERS=`echoscip-shell system . . echo. $VERSDIR | sedscip-shell system . . sed. -e 's/^.*\///'` |
| 38 | MIDASHOME=`echoscip-shell system . . echo. $VERSDIR | sedscip-shell system . . sed. -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'` |
| 39 | else |
| 40 | cd $MIDASHOME/$MIDVERS/install/unix |
| 41 | fi |
| 42 | |
| 43 | MID_INSTALL=$MIDASHOME/$MIDVERS/install/unix |
| 44 | MID_HOME=$MIDASHOME/$MIDVERS |
| 45 | |
| 46 | # |
| 47 | # START |
| 48 | # |
| 49 | #clear |
| 50 | |
| 51 | # |
| 52 | # Check weather "ls -s" command returns blocks of 1/2 or 1 kbytes. |
| 53 | # The file test_file_1k is 1kbyte big. |
| 54 | factor_ls=`lsscip-shell system . . ls. -s test_file_1k | awkscip-shell system . . awk. '{print $1}'` |
| 55 | |
| 56 | task="unknown" |
| 57 | while : |
| 58 | do |
| 59 | echoscip-shell system . . echo. "" |
| 60 | echoscip-shell system . . echo. " MIDAS DELETE MENU:" |
| 61 | echoscip-shell system . . echo. " ====================================" |
| 62 | echoscip-shell system . . echo. " 1 - Delete only object files." |
| 63 | echoscip-shell system . . echo. " 2 - Delete object and source files." |
| 64 | echoscip-shell system . . echo. " 3 - Delete object, source files and libraries." |
| 65 | echoscip-shell system . . echo. " 4 - Delete executable files." |
| 66 | echoscip-shell system . . echo. " q - Quit." |
| 67 | echoscip-shell system . . echo. "" |
| 68 | $echo "Select: " $SV_NONL |
| 69 | |
| 70 | read task |
| 71 | task=`echoscip-shell system . . echo. $task | trscip-shell system . . tr. A-Z a-z` |
| 72 | |
| 73 | echoscip-shell system . . echo. "" |
| 74 | case $task in |
| 75 | 1) |
| 76 | echoscip-shell system . . echo. "1. This option will delete all *.o files under $MID_HOME" |
| 77 | $echo " Computing first number of kbytes to be deleted [yn]? (y): " $SV_NONL |
| 78 | read answ |
| 79 | if [scip-shell system . . `[`. -z "$answ" ]; then |
| 80 | answ=y |
| 81 | fi |
| 82 | if [scip-shell system . . `[`. "$answ" = "y" -o "$answ" = "Y" ]; then |
| 83 | $echo " Number of kbytes to be deleted: (wait) " $SV_NONL |
| 84 | exprscip-shell system . . expr. `findscip-shell system . . find. $MID_HOME -name "*.o" -exec ls -s {} \; \ |
| 85 | | awkscip-shell system . . awk. '{size += $1} END {printf "%d\n",size}'` /scip-shell filesystem . . `/`. $factor_ls |
| 86 | fi |
| 87 | ;; |
| 88 | 2) |
| 89 | echoscip-shell system . . echo. "2. This option will delete all *.o *.for *.c files under $MID_HOME" |
| 90 | $echo " Computing first number of kbytes to be deleted [yn]? (y): " $SV_NONL |
| 91 | read answ |
| 92 | if [scip-shell system . . `[`. -z "$answ" ]; then |
| 93 | answ=y |
| 94 | fi |
| 95 | if [scip-shell system . . `[`. "$answ" = "y" -o "$answ" = "Y" ]; then |
| 96 | $echo " Number of kbytes to be deleted: (wait) " $SV_NONL |
| 97 | exprscip-shell system . . expr. `findscip-shell system . . find. $MID_HOME \( -name "*.o" -o -name "*.for" -o -name "*.c" \) \ |
| 98 | -exec ls -s {} \; \ |
| 99 | | awkscip-shell system . . awk. '{size += $1} END {printf "%d\n",size}'` /scip-shell filesystem . . `/`. $factor_ls |
| 100 | fi |
| 101 | ;; |
| 102 | 3) |
| 103 | echoscip-shell system . . echo. "3. This option will delete all *.o *.for *.c *.a files under $MID_HOME" |
| 104 | $echo " Computing first number of kbytes to be deleted [yn]? (y): " $SV_NONL |
| 105 | read answ |
| 106 | if [scip-shell system . . `[`. -z "$answ" ]; then |
| 107 | answ=y |
| 108 | fi |
| 109 | if [scip-shell system . . `[`. "$answ" = "y" -o "$answ" = "Y" ]; then |
| 110 | $echo " Number of kbytes to be deleted: (wait) " $SV_NONL |
| 111 | exprscip-shell system . . expr. `findscip-shell system . . find. $MID_HOME \( -name "*.o" -o -name "*.for" -o -name "*.a" -o \ |
| 112 | -name "*.c" \) -exec ls -s {} \; \ |
| 113 | | awkscip-shell system . . awk. '{size += $1} END {printf "%d\n",size}'` /scip-shell filesystem . . `/`. $factor_ls |
| 114 | fi |
| 115 | ;; |
| 116 | 4) |
| 117 | /bin/shscip-shell filesystem . . `/bin/sh`. $MID_INSTALL/delete |
| 118 | continue |
| 119 | ;; |
| 120 | q) |
| 121 | exit |
| 122 | ;; |
| 123 | *) |
| 124 | echoscip-shell system . . echo. "Selection unknown" |
| 125 | continue |
| 126 | ;; |
| 127 | esac |
| 128 | |
| 129 | if [scip-shell system . . `[`. $? != 0 ]; then |
| 130 | continue |
| 131 | fi |
| 132 | |
| 133 | $echo " Do you want to continue [yn]? (y): " $SV_NONL |
| 134 | read answ |
| 135 | if [scip-shell system . . `[`. -z "$answ" ]; then |
| 136 | answ=y |
| 137 | fi |
| 138 | if [scip-shell system . . `[`. "$answ" != "y" -a "$answ" != "Y" ] |
| 139 | then |
| 140 | continue |
| 141 | fi |
| 142 | #exit |
| 143 | |
| 144 | echoscip-shell system . . echo. " Start removing." |
| 145 | case $task in |
| 146 | 1) |
| 147 | echoscip-shell system . . echo. ' find $MID_HOME -name "*.o" -exec rm -f {} \;' |
| 148 | findscip-shell system . . find. $MID_HOME -name "*.o" -exec rm -f {} \; |
| 149 | ;; |
| 150 | 2) |
| 151 | echoscip-shell system . . echo. ' find $MID_HOME \( \ |
| 152 | -name "*.o" -o \ |
| 153 | -name "*.for" -o \ |
| 154 | -name "*.c" \) -exec rm -f {} \;' |
| 155 | findscip-shell system . . find. $MID_HOME \( \ |
| 156 | -name "*.o" -o \ |
| 157 | -name "*.for" -o \ |
| 158 | -name "*.c" \) -exec rm -f {} \; |
| 159 | ;; |
| 160 | 3) |
| 161 | echoscip-shell system . . echo. ' find $MID_HOME \( \ |
| 162 | -name "*.o" -o \ |
| 163 | -name "*.for" -o \ |
| 164 | -name "*.c" -o \ |
| 165 | -name "*.a" \) -exec rm -f {} \;' |
| 166 | findscip-shell system . . find. $MID_HOME \( \ |
| 167 | -name "*.o" -o \ |
| 168 | -name "*.for" -o \ |
| 169 | -name "*.c" -o \ |
| 170 | -name "*.a" \) -exec rm -f {} \; |
| 171 | ;; |
| 172 | esac |
| 173 | |
| 174 | echoscip-shell system . . echo. " Done." |
| 175 | done |