forked from ralna/GALAHAD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall_galahad
executable file
·123 lines (98 loc) · 2.97 KB
/
uninstall_galahad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Remove script for GALAHAD
# version for Bourne/bash shell
# syntax: uninstall_galahad
# N. Gould, D. Orban & Ph. Toint
# ( Last modified on 22 July 2005 at 15:20 GMT )
# check input arguments (if any)
if [[ $# != 0 ]]; then
echo "Use: uninstall_galahad"
exit 1
fi
export GALAHAD=`dirs -l`
export GALAHAD=`echo $GALAHAD | \sed 's"/tmp_mnt""'`
finished='false'
while [[ $finished != 'true' ]]; do
# VERS=( `\ls $GALAHAD/versions/*` )
VERS=( `\ls $GALAHAD/versions/* 2>/dev/null` )
NUMBER=${#VERS[@]}
if [[ $NUMBER == 0 ]]; then
echo "No versions of GALAHAD are currently installed."
exit 1
fi
LIST=( ${VERS[@]} )
CORRECT_VERSION="false"
while [[ $CORRECT_VERSION == "false" ]]; do
echo " The following versions of GALAHAD are currently installed."
echo " "
count=0
for i in ${LIST[@]}; do
(( count++ ))
(( cnt = count-1 )) # 0-based indexing
VERSION="`cat ${VERS[$cnt]}`"
echo " ($count) ${VERSION}"
done
echo " "
echo " Which do you wish to uninstall: (1-$NUMBER)?"
read CHOICE
(( CHOICE-- ))
i=0
while [[ $i -lt $NUMBER && $CORRECT_VERSION == "false" ]]; do
if [[ $CHOICE == $i ]]; then
CORRECT_VERSION="true"
CHOICE=$i
fi
(( i++ ))
done
if [[ $CORRECT_VERSION == "true" ]]; then
VERSION=${VERS[$CHOICE]##*/}
VERNAME=`cat ${VERS[$CHOICE]}`
else
echo " Please give an integer between 1 and $NUMBER"
fi
done
echo " Are you sure you wish to uninstall the version for"
echo " $VERNAME (Y/n)?"
YESNO=""
while [[ $YESNO != 'Y' && $YESNO != 'N' ]]; do
read YESNO
[[ $YESNO == "" ]] && YESNO="Y"
YESNO=`echo $YESNO | tr a-z A-Z`
done
if [[ $YESNO == 'Y' ]]; then
echo " Removing object files and libraries ... "
\rm -f -r $GALAHAD/objects/$VERSION
echo " Removing module information files ... "
\rm -f -r $GALAHAD/modules/$VERSION
echo " Removing AMPL executable ... "
\rm -f -r $GALAHAD/ampl_bin/$VERSION
echo " Removing environment information file ... "
\rm -f -r $GALAHAD/bin/sys/$VERSION
echo " Removing make information file ... "
\rm -f -r $GALAHAD/makefiles/$VERSION
python3 -V &>/dev/null
status=$?
if (( $status == 0 )); then
PYVERSION=$(python3 -V | awk '{print $2}')
PYTHONVERSION=$(echo ${PYVERSION%.*})
PYSITEPACKDIR=~/.local/lib/python${PYTHONVERSION}/site-packages
echo " Removing python information file ... "
\rm -f -r $PYSITEPACKDIR/galahad
\rm -f -r $PYSITEPACKDIR/galahad-1.0.dist-info
fi
echo " Removing version record file ... "
\rm -f -r $GALAHAD/versions/$VERSION
echo " Version for"
echo " $VERNAME"
echo " successfully removed."
fi
echo " "
echo " Do you wish to uninstall another version (N/y)?"
YESNO=""
while [[ $YESNO != 'Y' && $YESNO != 'N' ]]; do
read YESNO
[[ $YESNO == "" ]] && YESNO="N"
YESNO=`echo $YESNO | tr a-z A-Z`
done
[[ $YESNO == 'N' ]] && finished='true'
done