-
Notifications
You must be signed in to change notification settings - Fork 0
/
hs-index
executable file
·61 lines (50 loc) · 1.38 KB
/
hs-index
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
#!/bin/bash
# HepSim toolkit.
# S.Chekanov (ANL)
# Task: Index files and prepare the directory for the includion inside HepSim
if [[ -z "${HEPSIM_DIR}" ]]; then
echo "HEPSIM_DIR variable is unset"
echo "Exit.."
exit 1;
else
echo "hs-tools is set from $HEPSIM_DIR"
fi
if [ $# -eq 0 ]
then
echo "No arguments supplied. You should pass the directory name, such as 'events/ee/'"
echo "Exit.."
exit 1;
fi
export DIR=$1
# real path
export DIR=$(readlink -f $DIR)
# check the directory
if [ ! -d "$DIR" ]; then
echo "Directory $DIR does not exist!"
echo "Exit.."
exit 1;
fi
if [[ ! $DIR == *"events"* ]];
then
echo "The directory for indexing should contain 'events'. Example: 'events/ee/'"
echo "Exit.."
exit 1;
fi
chmod -R 755 $DIR/
read -r -p "Are you sure to index $DIR? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "ok, indexing $DIR"
find $DIR -type f -name "files*" -exec rm -f {} \;
find $DIR -name "*~" -delete
find $DIR -type f -name "dirs.i*" -exec rm -f {} \;
$HEPSIM_DIR/scripts/Make_sets $DIR
echo "Created index files from $DIR"
$HEPSIM_DIR/scripts/Make_metadata $DIR
echo "Rebuild ProMC metafile.txt from $DIR"
$HEPSIM_DIR/scripts/Make_promc_info $DIR
find $DIR -type d -exec cp -f $HEPSIM_DIR/scripts/index.php {} \;
else
echo "Exit since you say no.."
exit 1;
fi