forked from XSEDE/ipf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
executable file
·86 lines (65 loc) · 1.68 KB
/
setup.sh
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
#!/bin/bash
# DO NOT RUN THIS BY HAND
# This file is for use by https://github.com/andylytical/quickstart
INSTALL_DIR="$(pwd)" #this is the directory from which the user invoked quickstart
BASE=$(readlink -e $( dirname $0 ) )
IPF_SRC="$BASE/ipf"
TS=$(date +%s)
YES=0
NO=1
DEBUG=$YES
VERBOSE=$YES
# Files that are renamed on install, map of SRC -> TGT
declare -A SPECIAL_MAP=(
[ipf/etc/ipf/init.d/ipf-WORKFLOW.wfm]=ipf/etc/ipf/init.d/ipf-WORKFLOW
)
die() {
echo "ERROR $*" >&2
kill -s TERM $BASHPID
exit 99
}
log() {
[[ $VERBOSE -eq $YES ]] || return
echo "INFO $*" >&2
}
debug() {
[[ $DEBUG -eq $YES ]] || return
echo "DEBUG (${BASH_SOURCE[1]} [${BASH_LINENO[0]}] ${FUNCNAME[1]}) $*"
}
update_files() {
[[ $DEBUG -eq $YES ]] && set -x
# Update any files that need INSTALL_DIR
local _pattern='___INSTALL_DIR___'
local _replacement="$INSTALL_DIR/ipf"
grep -r --files-with-matches -F "$_pattern" "$BASE" \
| while read; do
sed -i -e "s?$_pattern?$_replacement?" "$REPLY"
done
}
install_common() {
[[ $DEBUG -eq $YES ]] && set -x
rsync -v --recursive \
-b --suffix=."$TS" \
--checksum \
--exclude-from="$BASE"/setup.excludes \
"$IPF_SRC" \
"$INSTALL_DIR"
}
install_special() {
[[ $DEBUG -eq $YES ]] && set -x
for src in "${!SPECIAL_MAP[@]}"; do
tgt="${SPECIAL_MAP[$src]}"
cp "${BASE}/${src}" "${INSTALL_DIR}/${tgt}"
done
}
install_version() {
[[ $DEBUG -eq $YES ]] && set -x
local _version=$( awk -F '"' '/version=/ {print $2; exit;}' "$BASE"/setup.py )
log "VERSION = $_version"
echo "$_version" > "$INSTALL_DIR"/ipf/version
}
[[ $DEBUG -eq $YES ]] && set -x
update_files
install_common
install_special
install_version