chan_vpb: Fix a gcc 7 out-of-bounds complaint
[asterisk/asterisk.git] / build_tools / install_subst
1 #!/bin/sh
2
3 # install_subst: install a script while doing path substitution
4
5 # install_subst [-d] source destination
6 #
7 # -d: file is data (rather than script)
8
9 install_args=
10 if [ "$1" = '-d' ]; then
11         install_args="-m 644"
12         shift
13 fi
14
15 set -e
16
17 tmp=`mktemp install_subst_XXXXXX`
18
19 cleanup_tmp() {
20         rm -f "$tmp"
21 }
22
23 # Delete it on exit
24 trap cleanup_tmp 0
25
26 src="$1"
27 dst="$2"
28 sed <"$src" \
29         -e "s|__ASTERISK_DATA_DIR__|$ASTDATADIR|g" \
30         -e "s|__ASTERISK_DB_DIR__|$ASTDBDIR|g" \
31         -e "s|__ASTERISK_ETC_DIR__|$ASTETCDIR|g" \
32         -e "s|__ASTERISK_HEADER_DIR__|$ASTHEADERDIR|g" \
33         -e "s|__ASTERISK_LIB_DIR__|$ASTLIBDIR|g" \
34         -e "s|__ASTERISK_LOG_DIR__|$ASTLOGDIR|g" \
35         -e "s|__ASTERISK_MOD_DIR__|$ASTMODDIR|g" \
36         -e "s|__ASTERISK_MAN_DIR__|$ASTMANDIR|g" \
37         -e "s|__ASTERISK_SBIN_DIR__|$ASTSBINDIR|g" \
38         -e "s|__ASTERISK_SPOOL_DIR__|$ASTSPOOLDIR|g" \
39         -e "s|__ASTERISK_VARLIB_DIR__|$ASTVARLIBDIR|g" \
40         -e "s|__ASTERISK_VARRUN_DIR__|$ASTVARRUNDIR|g" \
41         > "$tmp"
42
43 install $install_args "$tmp" "$dst"