blob: 7b97cd0fbf64055e4215436b8aff339cecb3ca7f (
plain)
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
|
#!/bin/bash
pre_upgrade(){
G4LIBRARY_PATH=/opt/Geant4/Libraries
G4LIBRARY_BACKUP=/opt/Geant4/Lib-backup
file_check=/tmp/.G4_Library.tmp
[ "$(ls -A $G4LIBRARY_PATH)" ] && mv $G4LIBRARY_PATH $G4LIBRARY_BACKUP && touch $file_check
}
post_upgrade(){
G4LIBRARY_PATH=/opt/Geant4/Libraries
G4LIBRARY_BACKUP=/opt/Geant4/Lib-backup
file_check=/tmp/.G4_Library.tmp
[ "$(ls $file_check)" ] && mkdir -p $G4LIBRARY_PATH && mv $G4LIBRARY_BACKUP/* $G4LIBRARY_PATH && rmdir $G4LIBRARY_BACKUP && rm $file_check
#TODO: need to automatically cleanup old libraries from the Library folder
PREVFILE=NONE
PREVFILEBASE=NONE
for file in $(ls /opt/Geant4/Libraries)
do
CURRFILEBASE=$(echo $file | sed -e "s/[0-9]*.[0-9]$//")
CURRFILE=$file
if [[ $CURRFILEBASE == $PREVFILEBASE ]]
then
sudo rm -Rf /opt/Geant4/Libraries/$PREVFILE && echo "removing old $PREVFILE"
fi
PREVFILE=$CURRFILE
PREVFILEBASE=$CURRFILEBASE
#echo "$CURRFILE $CURRFILEBASE $PREVFILE $PREVFILEBASE"
done
}
pre_remove(){
echo "Backing up Geant4 Libraries. To remove them, please run\n $ sudo rm -Rf /opt/Geant4/Libraries"
mv /opt/Geant4/Libraries /opt/Geant4/Lib-backup
}
|