mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	install_subst: helper script for installing with path substitution
A helper script to copy a source file substituting any __ASTERISK_<foo>_DIR__ with the content of $AST<foo>DIR. Review: https://reviewboard.asterisk.org/r/3202/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408059 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										36
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								Makefile
									
									
									
									
									
								
							| @@ -566,9 +566,7 @@ bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall | ||||
| 	$(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/" | ||||
| 	$(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/" | ||||
| 	if [ ! -f "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" -a ! -f /sbin/launchd ]; then \ | ||||
| 		cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;s|__ASTERISK_LOG_DIR__|$(ASTLOGDIR)|;' > contrib/scripts/safe.tmp ; \ | ||||
| 		$(INSTALL) -m 755 contrib/scripts/safe.tmp "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" ; \ | ||||
| 		rm -f contrib/scripts/safe.tmp ; \ | ||||
| 		./build_tools/install_subst contrib/scripts/safe_asterisk "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk"; \ | ||||
| 	fi | ||||
| 	$(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)" | ||||
| 	$(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)" | ||||
| @@ -784,9 +782,7 @@ install-logrotate: | ||||
| config: | ||||
| 	@if [ "${OSARCH}" = "linux-gnu" ]; then \ | ||||
| 		if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \ | ||||
| 			cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \ | ||||
| 			rm -f contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \ | ||||
| 			if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \ | ||||
| 				$(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \ | ||||
| 			fi ; \ | ||||
| @@ -794,9 +790,7 @@ config: | ||||
| 				/sbin/chkconfig --add asterisk ; \ | ||||
| 			fi ; \ | ||||
| 		elif [ -f /etc/debian_version ] ; then \ | ||||
| 			cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ; \ | ||||
| 			rm -f contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			./build_tools/install_subst contrib/init.d/rc.debian.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \ | ||||
| 			if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \ | ||||
| 				$(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \ | ||||
| 			fi ; \ | ||||
| @@ -804,16 +798,12 @@ config: | ||||
| 				/usr/sbin/update-rc.d asterisk defaults 50 91 ; \ | ||||
| 			fi ; \ | ||||
| 		elif [ -f /etc/gentoo-release ] ; then \ | ||||
| 			cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ; \ | ||||
| 			rm -f contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \ | ||||
| 			if [ -z "$(DESTDIR)" ] ; then \ | ||||
| 				/sbin/rc-update add asterisk default ; \ | ||||
| 			fi ; \ | ||||
| 		elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \ | ||||
| 			cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \ | ||||
| 			rm -f contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \ | ||||
| 			if [ ! -f /etc/sysconfig/asterisk ] ; then \ | ||||
| 				$(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \ | ||||
| 			fi ; \ | ||||
| @@ -821,9 +811,7 @@ config: | ||||
| 				/sbin/chkconfig --add asterisk ; \ | ||||
| 			fi ; \ | ||||
| 		elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \ | ||||
| 			cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ;\ | ||||
| 			rm -f contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			./build_tools/install_subst contrib/init.d/rc.suse.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \ | ||||
| 			if [ ! -f /etc/sysconfig/asterisk ] ; then \ | ||||
| 				$(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \ | ||||
| 			fi ; \ | ||||
| @@ -831,19 +819,13 @@ config: | ||||
| 				/sbin/chkconfig --add asterisk ; \ | ||||
| 			fi ; \ | ||||
| 		elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \ | ||||
| 			cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/asterisk" ; \ | ||||
| 			rm -f contrib/init.d/rc.asterisk.tmp ; \ | ||||
| 			./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \ | ||||
| 		elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \ | ||||
| 			if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \ | ||||
| 				sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.asterisk.plist > asterisk.plist ; \ | ||||
| 				$(INSTALL) -m 644 asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \ | ||||
| 				rm -f asterisk.plist; \ | ||||
| 				./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \ | ||||
| 			fi; \ | ||||
| 			if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \ | ||||
| 				sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.muted.plist > muted.plist ; \ | ||||
| 				$(INSTALL) -m 644 muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \ | ||||
| 				rm -f muted.plist; \ | ||||
| 				./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \ | ||||
| 			fi; \ | ||||
| 		elif [ -f /etc/slackware-version ]; then \ | ||||
| 			echo "Slackware is not currently supported, although an init script does exist for it."; \ | ||||
|   | ||||
							
								
								
									
										43
									
								
								build_tools/install_subst
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								build_tools/install_subst
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,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" | ||||
		Reference in New Issue
	
	Block a user