智能语音机器人开源代码\freeswitch\bin

#!/usr/bin/perl
#
# FreeSWITCH fsxs
#
# (C) 2006-2008 Stefan Knoblich <stkn@netdomination.org>
 
use strict;
 
#
# @FOO@ will be replaced by the freeswitch build process
#
my %vars = (
	CC => 'gcc',
	LD => 'gcc',
	MKDIR => '/usr/bin/mkdir -p',
	INSTALL => '/usr/bin/install -c',
	LIBS => '',
	CFLAGS => '-g -O2  -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE',
	INCLUDES => '-I/usr/local/freeswitch/include',
	LDFLAGS => '-L/usr/local/freeswitch/lib',
	SOLINK => '-shared -Xlinker -x',
 
	MODULESDIR => '/usr/local/freeswitch/mod',
	LIBDIR => '/usr/local/freeswitch/lib',
	BINDIR => '/usr/local/freeswitch/bin',
	INCLUDEDIR => '/usr/local/freeswitch/include/freeswitch',
	DBDIR => '/usr/local/freeswitch/db',
	CONFDIR => '/usr/local/freeswitch/conf',
	PREFIX => '/usr/local/freeswitch'
);
 
#
# Misc variables
#
my @files = ();
 
my $command;
my $target;
 
my $needs_target = 1;
my $debug = 0;
 
#
# functions 
#
 
sub do_exec {
	my $retval = system( "@_ >/dev/null" );
	if( $retval ) {
		exit $retval;
	}
}
 
sub fsxs_usage {
	print "FreeSWITCH fsxs\n(C) 2006-2008 Stefan Knoblich <stkn\@netdomination.org>\n";
	print "\n";
	print "Usage:\n";
	print "\t$0 compile [options] <file1 ...>\n";
	print "\t$0 link    [options] <target> <file1 ...>\n";
	print "\t$0 build   [options] <target> <file1 ...>\n";
	print "\t$0 install [options] <file1 ...>\n\n";
	print "\t$0 show    <var1 ...varN>\n";
	print "\t$0         <--var1 ...--varN>\n\n";
 
	print "Command description:\n";
	print "\tcompile: Compile source file(s) into object file(s)\n";
	print "\tlink:    Create module from object file(s)\n";
	print "\tbuild:   Build module from source file(s) (compile + link)\n";
	print "\tinstall: Install module(s) into FreeSWITCH module directory\n";
	print "\tshow:    Show defined variable(s)\n";
	print "\n";
 
	print "Options:\n";
	print "\t--add-cflags  Append custom cflags   [compile, build]\n";
	print "\t--set-cflags  Override cflags        [compile, build]\n";
	print "\n";
	print "\t--add-ldflags Append custom ldflags  [link, build]\n";
	print "\t--set-ldflags Override ldflags       [link, build]\n";
	print "\t--add-libs    Append additional libs [link, build]\n";
	print "\t--set-libs    Override libs          [link, build]\n";
	print "\n";
	print "\t--destdir     Installation prefix    [install]\n";
	print "\n";
 
	print "Variable names for \"fsxs show\" / \"fsxs --var\":\n";
	print "\tcflags ldflags libs solink includes cc ld mkdir install\n";
	print "\tprefix libdir modulesdir dbdir includedir confdir bindir\n";
	print "\n";
 
	print "Examples:\n";
	print "\t$0 compile --add-cflags=\"-DFOO=1 -DBAR\" mod_test.c mod_test2.c\n\n";
	print "\t$0 link --add-ldflags=\"-ltest\" mod_test.so mod_test.o mod_test2.o\n\n";
	print "\t$0 build --add-cflags=\"-DFOO\" --add-ldflags=\"-ltest\" mod_test.so mod_test.c mod_test2.c\n\n";
	exit 1;
}
 
sub fsxs_compile {
	my $cc_cmd;
 
	$cc_cmd = "$vars{CC}";
	if( defined( $vars{INCLUDES} ) && $vars{INCLUDES} ) {
		$cc_cmd = $cc_cmd . " $vars{INCLUDES}"
	}
	$cc_cmd = $cc_cmd . " $vars{CFLAGS} -c -o";
 
	foreach( @_ ) {
		chomp( $_ );
 
		# replace file extension
		my $outfile = $_;
		$outfile =~ s/\.(cpp|cc|c)$/.o/;
 
		print "CC\t$_\n";
		if( $debug ) {
			print "$cc_cmd $outfile $_\n"
		}
		do_exec( "$cc_cmd $outfile $_" );
	}
}
 
sub fsxs_link {
	my $target = shift;
	my @objs = @_;
	my $ld_cmd;
 
	$ld_cmd = "$vars{LD}";
	$ld_cmd = $ld_cmd . " $vars{LDFLAGS} $vars{SOLINK} -o";
 
	print "LD\t$target\t[@objs]\n";
	if( $debug ) {
		print "$ld_cmd $target @objs $vars{LIBS}\n"
	}
	do_exec( "$ld_cmd $target @objs $vars{LIBS}" );
}
 
sub fsxs_install {
	my @files = @_;
	my $destination = $vars{DESTDIR} . $vars{MODULESDIR};
 
	# check if destination exists, create if it doesn't
	if( ! -e $destination ) {
		if( $debug ) {
			print "$vars{MKDIR} $destination\n";
		}
		do_exec( "$vars{MKDIR} $destination" );
	}
	if( $debug ) {
		print "$vars{INSTALL} -m644 @files $destination\n";
	}
	do_exec( "$vars{INSTALL} -m644 @files $destination" );
}
 
sub fsxs_show {
	my @varlist = @_;
 
	if( $#varlist < 0 ) {
		# none requested, show all variables with names
		my $key;
		foreach $key ( keys %vars ) {
			print "$key: $vars{$key}\n";
		}
	}
	elsif( $#varlist > 0 ) {
		# more than one requested, show with name
		foreach( @varlist ) {
			if( defined $vars{$_} ) {
				print "$_: $vars{$_}\n";
			}
		}
	} else {
		# show only one variable, without name
		if( defined $vars{$varlist[0]} ) {
			print "$vars{$varlist[0]}\n";
		}
	}
}
 
sub fsxs_showq {
	my @varlist = @_;
	my $count = 0;
 
	if( $#varlist >= 0 ) {
		foreach( @varlist ) {
			if( defined $vars{$_} ) {
				print "$vars{$_}" . (($count < $#varlist) ? " " : "");
			}
			$count++;
		}
	}
}
 
#
# main part
#
if( $#ARGV < 0 ) {
	fsxs_usage;
}
 
if( @ARGV[0] =~ /^\--.+$/ ) {
	# 'show' shortcut for using fsxs in scripts
	$needs_target = 0;
	$command = "showq";
}
else {
	chomp( $command = shift @ARGV );
 
	if( $command =~ /^install|build|link|compile|show$/ ) {
 
		# add -lfreeswitch to the front of the library list
		# we don't want it to be in the show / showq output
		# but we still want to be able to override it with --set-libs
		if( $command ne "show" ) {
			$vars{LIBS} = "-lfreeswitch $vars{LIBS}";
		}
 
		if( $command =~ /^show|compile|install$/ ) {
			$needs_target = 0;
		}
	}
	else {
		print STDERR "Unknown command: $command\n";
		fsxs_usage;
	}
}
 
# parse environment variables
if( defined $ENV{DEBUG} && $ENV{DEBUG} ) {
	$debug = 1;
}
 
# parse arguments
foreach(@ARGV) {
	chomp( $_ );
 
	if( $command ne "show" && $command ne "showq" )
	{
		if( /^\--add-cflags=(.*)$/ ) {
			$vars{CFLAGS} = "$vars{CFLAGS} $1";
		}
		elsif( /^\--set-cflags=(.*)$/ ) {
			$vars{CFLAGS} = "$1";
		}
		elsif( /^\--add-ldflags=(.*)$/ ) {
			$vars{LDFLAGS} = "$vars{LDFLAGS} $1";
		}
		elsif( /^\--set-ldflags=(.*)$/ ) {
			$vars{LDFLAGS} = "$1";
		}
		elsif( /^\--add-libs=(.*)$/ ) {
			$vars{LIBS} = "$vars{LIBS} $1";
		}
		elsif( /^\--set-libs=(.*)$/ ) {
			$vars{LIBS} = "$1";
		}
		elsif( /^\--destdir=(.*)$/ ) {
			$vars{DESTDIR} = "$1";
		}
		elsif( /^\--debug$/ ) {
			$debug = 1;
		}
		elsif( /^(DESTDIR|CFLAGS|CC|LDFLAGS|LD|LIBS)=(.*)$/ ) {
			if( $debug ) {
				print "Overriding $1 (new value: $2)\n";
			}
			$vars{$1} = "$2";
		}
		elsif( /^([^\-]+.*)$/ ) {
			if( $needs_target ) {
				$target = "$1";
				$needs_target = 0;
			} else {
				push(@files, "$1");
			}
		}
	} else {
		# show command has different parameter handling
		if( /^\--(.*)$/ ) {
			push( @files, uc "$1" );
		}
		elsif( /^([^\-]+.*)$/ ) {
			push( @files, uc "$1" );
		}
	}
}
 
#
# execute commands
#
if( $command eq 'link' ) {
	fsxs_link( $target, @files );
}
elsif( $command eq 'compile' ) {
	fsxs_compile( @files );
}
elsif( $command eq 'build' ) {
	my @objs = ();
 
	fsxs_compile( @files );
 
	foreach( @files ) {
		chomp( $_ );
		$_ =~ s/\.(cpp|cc|c)$/.o/;
		push( @objs, "$_" );
	}
 
	fsxs_link( $target, @objs );
}
elsif( $command eq 'show' ) {
	fsxs_show( @files );
}
elsif( $command eq 'showq' ) {
	fsxs_showq( @files );
}
elsif( $command eq 'install' ) {
	fsxs_install( @files );
}
else {
	fsxs_usage;
}
 
exit 0;
#!/bin/sh
 
CONFDIR=/usr/local/freeswitch/certs
DAYS=2190
KEY_SIZE=2048
export KEY_SIZE=${KEY_SIZE}
 
TMPFILE="/tmp/fs-ca-$$-$(date +%Y%m%d%H%M%S)"
 
COMMON_NAME="FreeSWITCH CA"
ALT_NAME="DNS:test.freeswitch.org"
ORG_NAME="FreeSWITCH"
OUTFILE="agent.pem"
 
umask 037
 
check_ca() {
	for x in cacert.pem cakey.pem config.tpl; do
		if [ ! -e "${CONFDIR}/CA/${x}" ]; then
			return 1
		fi
	done
 
	return 0
}
 
setup_ca() {
	if check_ca; then
		echo "Existing CA found in \"${CONFDIR}/CA\""
		echo "(Use \"gentls_cert remove\" to delete)"
		exit 1
	fi
 
	echo "Creating new CA..."
 
	if [ ! -d "${CONFDIR}/CA" ]; then
		mkdir -p -m 750 "${CONFDIR}/CA" || exit  1
	fi
 
	if [ -e "${CONFDIR}/CA/config.tpl" ]; then
		if [ $0 -nt "${CONFDIR}/CA/config.tpl" ]; then
			echo "WARNING! genttls_cert has a modified time more recent than ${CONFDIR}/CA/config.tpl remove config.tpl to re-generate it"
		fi
	else
		cat > "${CONFDIR}/CA/config.tpl" <<-EOF
			[ req ]
			default_bits            = \$ENV::KEY_SIZE
			prompt                  = no
			distinguished_name      = req_dn
			x509_extensions         = v3_ca
 
			[ req_dn ]
			commonName              = %CN%
			organizationName	= %ORG%
 
			[ server ]
			nsComment="FS Server Cert"
			basicConstraints=CA:FALSE
			subjectKeyIdentifier=hash
			authorityKeyIdentifier=keyid,issuer:always
			subjectAltName=%ALTNAME%
			nsCertType=server
			extendedKeyUsage=serverAuth
 
			[ client ]
			nsComment="FS Client Cert"
			basicConstraints=CA:FALSE
			subjectKeyIdentifier=hash
			authorityKeyIdentifier=keyid,issuer:always
			subjectAltName=%ALTNAME%
			nsCertType=client
			extendedKeyUsage=clientAuth
 
			[ v3_ca ]
			subjectKeyIdentifier=hash
			authorityKeyIdentifier=keyid:always,issuer
			basicConstraints=CA:TRUE
 
		EOF
	fi
 
	sed \
		-e "s|%CN%|$COMMON_NAME|" \
		-e "s|%ORG%|$ORG_NAME|" \
		-e "/%ALTNAME%/d" \
		-e "s|CA:FALSE|CA:TRUE|" \
		"${CONFDIR}/CA/config.tpl" \
			> "${TMPFILE}.cfg" || exit 1
 
	openssl req -out "${CONFDIR}/CA/cacert.pem" \
		-new -x509 -keyout "${CONFDIR}/CA/cakey.pem" \
		-config "${TMPFILE}.cfg" -nodes -days ${DAYS} -sha1 >/dev/null || exit 1
	cat "${CONFDIR}/CA/cacert.pem" > "${CONFDIR}/cafile.pem"
	cp $TMPFILE.cfg /tmp/ssl.cfg
	rm "${TMPFILE}.cfg"
 
	echo "DONE"
}
 
generate_cert() {
	local val=""
 
	if ! check_ca; then
		echo "No existing CA found, please create one with \"gentls_cert setup\" first"
		exit 1
	fi
 
	echo "Generating new certificate..."
 
	echo
	echo "--------------------------------------------------------"
	echo "CN: \"${COMMON_NAME}\""
	echo "ORG_NAME: \"${ORG_NAME}\""
	echo "ALT_NAME: \"${ALT_NAME}\""
	echo
	echo "Certificate filename \"${OUTFILE}\""
	echo
	echo "[Is this OK? (y/N)]"
	read val
	if [ "${val}" != "y" ] && [ "${val}" != "Y" ]; then
		echo "Aborted"
		return 2
	fi
 
	sed \
		-e "s|%CN%|$COMMON_NAME|" \
		-e "s|%ALTNAME%|$ALT_NAME|" \
		-e "s|%ORG%|$ORG_NAME|" \
		"${CONFDIR}/CA/config.tpl" \
			> "${TMPFILE}.cfg" || exit 1
 
	openssl req -new -out "${TMPFILE}.req" \
		-newkey rsa:${KEY_SIZE} -keyout "${TMPFILE}.key" \
		-config "${TMPFILE}.cfg" -nodes -sha1 >/dev/null || exit 1
 
	openssl x509 -req -CAkey "${CONFDIR}/CA/cakey.pem" -CA "${CONFDIR}/CA/cacert.pem" -CAcreateserial \
		-in "${TMPFILE}.req" -out "${TMPFILE}.crt" -extfile "${TMPFILE}.cfg" \
		-extensions "${EXTENSIONS}" -days ${DAYS} -sha1 >/dev/null || exit 1
 
	cat "${TMPFILE}.crt" "${TMPFILE}.key" > "${CONFDIR}/${OUTFILE}"
 
	rm "${TMPFILE}.cfg" "${TMPFILE}.crt" "${TMPFILE}.key" "${TMPFILE}.req"
 
	echo "DONE"
}
 
remove_ca() {
	echo "Removing CA"
 
	if [ -d "${CONFDIR}/CA" ]; then
		rm "${CONFDIR}/CA/"*
		rmdir "${CONFDIR}/CA"
	fi
 
	echo "DONE"
}
OUTFILESET="0"
command="$1"
shift
 
while [ $# -gt 0 ]; do
	case $1 in
		-cn)
			shift
			COMMON_NAME="$1"
			;;
		-alt)
			shift
			ALT_NAME="$1"
			;;
		-org)
			shift
			ORG_NAME="$1"
			;;
		-out)
			shift
			OUTFILE="$1"
			OUTFILESET="1"
			;;
		-days)
			shift
			DAYS="$1"
			;;
	esac
	shift
done
 
 
case ${command} in
	setup)
		setup_ca
		;;
 
	create)
		EXTENSIONS="server"
		generate_cert
		;;
	create_server)
		EXTENSIONS="server"
		generate_cert
		;;
	create_client)
		EXTENSIONS="client"
		if [ "${OUTFILESET}" = "0" ]; then
			OUTFILE="client.pem"
 		fi
		generate_cert
		;;
 
	remove)
		echo "Are you sure you want to delete the CA? [YES to delete]"
		read val
		if [ "${val}" = "YES" ]; then
			remove_ca
		else
			echo "Not deleting CA"
		fi
		;;
 
	*)
		cat <<-EOF
		$0 <setup|create_server|create_client|clean> [options]
 
		  * commands:
 
		    setup  - Setup new CA
		    remove - Remove CA
 
		    create_server - Create new certificate (overwriting existing!)
		    create_client - Create a new client certificate (overwrites existing!)
 
		  * options:
 
		   -cn       Set common name
		   -alt      Set alternative name (use prefix 'DNS:' or 'URI:')
		   -org      Set organization name
		   -out      Filename for new certificate (create only)
		   -days     Certificate expires in X days (default: 365)
 
		EOF
		exit 1
		;;
esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
(韩国源人形机器人)DARwIn-OP_ROBOTIS_v1.5.0 You can get the latest version at below link. https://sourceforge.net/projects/darwinop/ ===================================== DARwIn-OP v1.5.0 ===================================== >>> Date: 19 Mar 2012 >>> New functionality/features * FSR tutorial has been added. * FSR firmware added. >>> Changes * LinuxMotionTimer has been changed to use clock_nanosleep function. >>> Bug fixes * None. ===================================== DARwIn-OP v1.4.0 ===================================== >>> Date: 16 Jan 2012 >>> New functionality/features * None. >>> Changes * MX-28 firmware updated. * Stand-up motion changed. >>> Bug fixes * Cannot change the camera gain/exposure value from a web page bug fixed. * offset tuner 'set' command bug fixed. ===================================== DARwIn-OP v1.3.0 ===================================== >>> Date: 20 Sep 2011 >>> New functionality/features * offset_tuner added. * walk_tuner web page added. >>> Changes * CM-730 firmware updated. * roboplus support 4096 resolution(MX-28 firmware ver 27 or higher). * dxl_monitor : can change baudrate (control table addr 4) * Get-up motion changed. * read_write tutorial : left arm P gain value changed. (1 -> 8) >>> Bug fixes * None. ===================================== DARwIn-OP v1.2.0 ===================================== >>> Date: 01 Jun 2011 >>> New functionality/features * BulkRead instruction added. * Support FSR sensor. >>> Changes * Actuator Model name changed (RX-28M -> MX-28) * MX-28 firmware updated. * dxl_monitor : can change ID (control table addr 3) * Get-up motion changed. * Sensor calibration routine changed. (use standard deviation) * demo & walk_tuner share the config.ini file. (/darwin/Data/config.ini) >>> Bug fixes * action_editor : command line bug fixed. (can't input space or number) linux terminal backspace bug fixed. * walk_tuner : linux terminal backspace bug fixed. * read_write : at the start, torque off the right arm. * firmware installer : seperate firmware of the controller and actuator ===================================== DARwIn-OP v1.1.0 ===================================== >>> Date: 8 Apr 2011 >>> New functionality/features * firmware_installer : CM-730 & RX-28M firmware installer * CM-730 : Low battery alert added. >>> Changes * RX-28M resolution changed from 1024 to 4096. >>> Bug fixes * Action class : type casting bug fixed. * dxl_monitor : CM-730 control table dump bug fixed. * action_editor : command line first char backspace bug fixed. save command bug fixed. * walk_tuner : command line first char backspace bug fixed. * some minor bug fixed. ===================================== DARwIn-OP v1.0.1 ===================================== >>> Date: 28 Mar 2011 >>> Changes * LinuxCM730 : Move semaphore init code to constructor * action_script : Stand-up motion page number changed from 16 to 1. * demo : at the start of soccer mode, reset the gyro sensor calibration * Some walking parameters changed. >>> Bug fixes * action_editor : page 255 access problem fixed. * Walking : Y move amplitude bug fixed. ===================================== DARwIn-OP v1.0.0 ===================================== >>> Date: 1 Feb 2011 >>> New functionality/features * First released. >>> Changes * First released. >>> Bug fixes * First released.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值