summaryrefslogtreecommitdiff
path: root/build_tools/install_subst
blob: 5b5407aa8c3ef8ea5c15aeb1ee8d8de3333e841e (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
39
40
41
42
43
#!/bin/sh

# install_subst: install a script while doing path substitution

# install_subst [-d] source destination
#
# -d: file is data (rather than script)

install_args=
if [ "$1" = '-d' ]; then
	install_args="-m 644"
	shift
fi

set -e

tmp=`mktemp install_subst_XXXXXX`

cleanup_tmp() {
	rm -f "$tmp"
}

# Delete it on exit
trap cleanup_tmp 0

src="$1"
dst="$2"
sed <"$src" \
	-e "s|__ASTERISK_DATA_DIR__|$ASTDATADIR|g" \
	-e "s|__ASTERISK_DB_DIR__|$ASTDBDIR|g" \
	-e "s|__ASTERISK_ETC_DIR__|$ASTETCDIR|g" \
	-e "s|__ASTERISK_HEADER_DIR__|$ASTHEADERDIR|g" \
	-e "s|__ASTERISK_LIB_DIR__|$ASTLIBDIR|g" \
	-e "s|__ASTERISK_LOG_DIR__|$ASTLOGDIR|g" \
	-e "s|__ASTERISK_MOD_DIR__|$ASTMODDIR|g" \
	-e "s|__ASTERISK_MAN_DIR__|$ASTMANDIR|g" \
	-e "s|__ASTERISK_SBIN_DIR__|$ASTSBINDIR|g" \
	-e "s|__ASTERISK_SPOOL_DIR__|$ASTSPOOLDIR|g" \
	-e "s|__ASTERISK_VARLIB_DIR__|$ASTVARLIBDIR|g" \
	-e "s|__ASTERISK_VARRUN_DIR__|$ASTVARRUNDIR|g" \
	> "$tmp"

install $install_args "$tmp" "$dst"