-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall_sifdecode
executable file
·93 lines (72 loc) · 2.36 KB
/
uninstall_sifdecode
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
#!/bin/bash
# Remove script for sifdecode
# version for Bourne/bash shell
# syntax: uninstall_sifdecode
# N. Gould, D. Orban & Ph. Toint
# ( Last modified on 20 October 2012 at 11:00 GMT )
# check input arguments (if any)
if [[ $# != 0 ]]; then
echo "Use: uninstall_sifdecode"
exit 1
fi
export SIFDECODE=`dirs -l`
export SIFDECODE=`echo $SIFDECODE | \sed 's"/tmp_mnt""'`
. $SIFDECODE/bin/sifdecode_envcheck
finished='false'
while [[ $finished != 'true' ]]; do
# VERS=( `\ls $SIFDECODE/versions/*` )
VERS=( `\ls $SIFDECODE/versions/* 2>/dev/null` )
NUMBER=${#VERS[@]}
if [[ $NUMBER == 0 ]]; then
warning "No versions of SIFDECODE are currently installed."
exit 1
fi
LIST=( ${VERS[@]} )
CORRECT_VERSION="false"
while [[ $CORRECT_VERSION == "false" ]]; do
echo -e " The following versions of SIFDECODE are currently installed.\n"
count=0
for i in ${LIST[@]}; do
(( count++ ))
(( cnt = count-1 )) # 0-based indexing
VERSION="`cat ${VERS[$cnt]}`"
echo " ($count) ${VERSION}"
done
echo -e "\n 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"
yesno_default_yes "$VERNAME"
if [[ $? == 1 ]]; then
echo " Removing object files and libraries ... "
\rm -f -r $SIFDECODE/objects/$VERSION
echo " Removing module information files ... "
\rm -f -r $SIFDECODE/modules/$VERSION
echo " Removing environment information file ... "
\rm -f -r $SIFDECODE/bin/sys/$VERSION
echo " Removing make information file ... "
\rm -f -r $SIFDECODE/makefiles/$VERSION
echo " Removing version record file ... "
\rm -f -r $SIFDECODE/versions/$VERSION
success " Version for
$VERNAME
successfully removed."
fi
yesno_default_no 'Do you wish to uninstall another version'
[[ $? == 0 ]] && finished='true'
done