diff --git a/Makefile b/Makefile
index 737ea8e98da5c21ec5c3705c5d77a8237318f66e..e565d6b932a55af102ac717d4a132950ea5504f3 100755
--- a/Makefile
+++ b/Makefile
@@ -598,7 +598,7 @@ bininstall: all
 	install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
 	install -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/	
 	if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
-		install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
+		cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
 	fi
 	for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
 	install -d $(DESTDIR)$(ASTHEADERDIR)
diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk
index 78013c9a087ce7157ed41ea05ededa2411e877af..2cfab55dae670fb3fd06a67a0619757a57f2f402 100755
--- a/contrib/scripts/safe_asterisk
+++ b/contrib/scripts/safe_asterisk
@@ -5,6 +5,7 @@ CONSOLE=yes		# Whether or not you want a console
 #NOTIFY=ben@alkaloid.net	# Who to notify about crashes
 MACHINE=`hostname`      # To specify which machine has crashed when getting the mail
 DUMPDROP=/tmp
+ASTSBINDIR=__ASTERISK_SBIN_DIR__
 #
 # Don't fork when running "safely"
 #
@@ -44,10 +45,10 @@ run_asterisk()
 		if [ "$TTY" != "" ]; then
 			cd /tmp
 			stty sane < /dev/${TTY}
-			asterisk ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}
+			${ASTSBINDIR}/asterisk ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}
 		else
 			cd /tmp
-			asterisk ${CLIARGS} ${ASTARGS}
+			${ASTSBINDIR}/asterisk ${CLIARGS} ${ASTARGS}
 		fi
 		EXITSTATUS=$?
 		echo "Asterisk ended with exit status $EXITSTATUS"