diff --git a/.gitignore b/.gitignore index d833a11..2cec9aa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ gcp.json data_volume/ -tmpAudio/ \ No newline at end of file +tmpAudio/ + +.idea +*.iml \ No newline at end of file diff --git a/cloudformation/jambonz-scalable-production.yaml b/cloudformation/jambonz-scalable-production.yaml index b3c618f..5169d0d 100644 --- a/cloudformation/jambonz-scalable-production.yaml +++ b/cloudformation/jambonz-scalable-production.yaml @@ -15,6 +15,26 @@ Parameters: Default: "name of an aws keypair that you have downloaded and will use to access the EC2 instances via ssh" Type: "AWS::EC2::KeyPair::KeyName" + TlsDomain: + Default: "" + Description: "TLS domain name" + Type: String + + TlsKey: + Default: "" + Description: "TLS .key certificate" + Type: "AWS::SSM::Parameter::Value" + + TlsCert: + Default: "" + Description: "TLS .cert certificate" + Type: "AWS::SSM::Parameter::Value" + + TlsFullchain: + Default: "" + Description: "TLS .fullchain certificate" + Type: "AWS::SSM::Parameter::Value" + InstanceTypeSbcSip: Description: "the EC2 instance type for the SBC SIP server" Type: String @@ -1060,8 +1080,32 @@ Resources: sudo systemctl restart telegraf echo "restarting drachtio server" + + #If TLS build out certificates from SSM params + if ["${TLS_DOMAIN}" != ""] && ["${TLS_KEY}" != ""] && ["${TLS_CERT}" != ""] && ["${TLS_FULLCHAIN}" != ""]; then + + #create certificate based on SSM values + sudo mkdir -p "/etc/certs/$TLS_DOMAIN" + echo "$TLS_KEY" > "/etc/certs/$TLS_DOMAIN/$TLS_DOMAIN.key" + echo "$TLS_CERT" > "/etc/certs/$TLS_DOMAIN/$TLS_DOMAIN.cert" + echo "$TLS_FULLCHAIN" > "/etc/certs/$TLS_DOMAIN/$TLS_DOMAIN.fullchain.crt" + + #update drachtio.conf.xml with newly created certs + sudo sed -i "/udp-mtu/a \ + + /etc/certs/$TLS_DOMAIN/$TLS_DOMAIN.key + /etc/certs/$TLS_DOMAIN/$TLS_DOMAIN.crt + /etc/certs/$TLS_DOMAIN/$TLS_DOMAIN.fullchain.crt + " /etc/drachtio.conf.xml + + #update drachtio.service add contact for tls + sudo sed -i -e "s/--contact sip:${LOCAL_IP};transport=tcp/a --contact sips:${LOCAL_IP}:5061;transport=tls --external-ip ${PUBLIC_IP} \/g" /etc/systemd/system/drachtio.service + sudo sed -i -e "s/--contact sip:${LOCAL_IP};transport=tcp/a --contact sips:${LOCAL_IP}:8443;transport=wss --external-ip ${PUBLIC_IP} \/g" /etc/systemd/system/drachtio.service + fi + # point drachtio server to the HEP endpoint on the monitoring server sudo sed -i -e "s/--address 0.0.0.0 --port 9022/--address 0.0.0.0 --port 9022 --homer ${MONITORING_SERVER_IP}:9060 --homer-id 10/g" /etc/systemd/system/drachtio.service + sudo systemctl daemon-reload sudo systemctl restart drachtio @@ -1082,6 +1126,11 @@ Resources: MONITORING_SERVER_IP: !GetAtt MonitoringServerEC2.PrivateIp AWS_SNS_TOPIC_ARN: !Ref SbcSipServerSNSTopic JAMBONES_TIME_SERIES_HOST: !GetAtt MonitoringServerEC2.PrivateIp + TLS_DOMAIN: !Ref TlsDomain + TLS_KEY: !Ref TlsKey + TLS_CERT: !Ref TlsCert + TLS_FULLCHAIN: !Ref TlsFullchain + SbcSipServerPlacementGroup: Type: AWS::EC2::PlacementGroup Properties: diff --git a/packer/jambonz-feature-server/files/mrf_sip_profile.xml b/packer/jambonz-feature-server/files/mrf_sip_profile.xml index ba7559c..9ed0723 100644 --- a/packer/jambonz-feature-server/files/mrf_sip_profile.xml +++ b/packer/jambonz-feature-server/files/mrf_sip_profile.xml @@ -18,7 +18,8 @@ - + + diff --git a/packer/jambonz-feature-server/scripts/install_datadog.sh b/packer/jambonz-feature-server/scripts/install_datadog.sh index a4a3ea2..206a338 100755 --- a/packer/jambonz-feature-server/scripts/install_datadog.sh +++ b/packer/jambonz-feature-server/scripts/install_datadog.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ "$1" == "yes" ]; then +if [ "$1" == "yes" ] && [ "$DD_KEY" != "" ]; then echo installing datadog... - DD_INSTALL_ONLY=true DD_API_KEY=your-dd-key-here bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)" + DD_INSTALL_ONLY=true DD_API_KEY=${DD_KEY} bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)" fi \ No newline at end of file diff --git a/packer/jambonz-feature-server/scripts/install_freeswitch.sh b/packer/jambonz-feature-server/scripts/install_freeswitch.sh index cc830bc..f4d2ccc 100644 --- a/packer/jambonz-feature-server/scripts/install_freeswitch.sh +++ b/packer/jambonz-feature-server/scripts/install_freeswitch.sh @@ -130,8 +130,9 @@ sudo cp /usr/local/src/freeswitch/conf/vanilla/autoload_configs/modules.conf.xml sudo cp /tmp/freeswitch.service /etc/systemd/system sudo chown root:root -R /usr/local/freeswitch sudo chmod 644 /etc/systemd/system/freeswitch.service -sudo sed -i -e 's/global_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8/global_codec_prefs=PCMU,PCMA,OPUS,G722/g' /usr/local/freeswitch/conf/vars.xml -sudo sed -i -e 's/outbound_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8/outbound_codec_prefs=PCMU,PCMA,OPUS,G722/g' /usr/local/freeswitch/conf/vars.xml +sudo sed -i -e "s/global_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8/global_codec_prefs=${CODEC_LIST}/g" /usr/local/freeswitch/conf/vars.xml +sudo sed -i -e "s/outbound_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8/outbound_codec_prefs=${CODEC_LIST}/g" /usr/local/freeswitch/conf/vars.xml +sudo sed -i -e "s/outbound_codec_prefs=PCMU,PCMA,OPUS,G722/a " /usr/local/freeswitch/conf/vars.xml sudo systemctl enable freeswitch sudo cp /tmp/freeswitch_log_rotation /etc/cron.daily/freeswitch_log_rotation sudo chown root:root /etc/cron.daily/freeswitch_log_rotation diff --git a/packer/jambonz-feature-server/template.json b/packer/jambonz-feature-server/template.json index b67db8c..8651109 100644 --- a/packer/jambonz-feature-server/template.json +++ b/packer/jambonz-feature-server/template.json @@ -7,7 +7,10 @@ "drachtio_version": "v0.8.13-rc1", "jambonz_version": "v0.6.7-rc8", "install_telegraf": "yes", - "install_datadog": "no" + "install_datadog": "no", + "datadog_key" : "", + "mediaserver_name" : "jambonz", + "preferred_codec_list" : "PCMU,PCMA,OPUS,G722" }, "builders": [{ "type": "amazon-ebs", @@ -63,8 +66,8 @@ "ssh-keyscan github.com >> ~/.ssh/known_hosts", "mkdir ~/apps", "cd ~/apps", - "git clone git@github.com:jambonz/jambonz-feature-server.git -b {{user `jambonz_version`}}", - "git clone git@github.com:jambonz/fsw-clear-old-calls.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/jambonz-feature-server.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/fsw-clear-old-calls.git -b {{user `jambonz_version`}}", "sudo find / -name authorized_keys | sudo xargs -0 -r rm -Rf" ] }, @@ -83,6 +86,9 @@ }, { "type": "shell", + "environment_vars": [ + "DD_KEY={{user `datadog_key`}}" + ], "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_datadog`}}", "script": "scripts/install_datadog.sh" }, @@ -93,6 +99,10 @@ }, { "type": "shell", + "environment_vars": [ + "USER_AGENT_STRING={{user `mediaserver_name`}}", + "CODEC_LIST={{user `preferred_codec_list`}}" + ], "script": "scripts/install_freeswitch.sh" }, { diff --git a/packer/jambonz-sbc-sip/scripts/install_datadog.sh b/packer/jambonz-sbc-sip/scripts/install_datadog.sh index ddca0d0..d066ef7 100755 --- a/packer/jambonz-sbc-sip/scripts/install_datadog.sh +++ b/packer/jambonz-sbc-sip/scripts/install_datadog.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ "$1" == "yes" ]; then +if [ "$1" == "yes" ] && [ "$DD_KEY" != "" ]; then - DD_INSTALL_ONLY=true DD_API_KEY=your-dd-key-here bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)" + DD_INSTALL_ONLY=true DD_API_KEY=$DD_KEY bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)" fi diff --git a/packer/jambonz-sbc-sip/template.json b/packer/jambonz-sbc-sip/template.json index 0e5f3d2..9bb8863 100644 --- a/packer/jambonz-sbc-sip/template.json +++ b/packer/jambonz-sbc-sip/template.json @@ -7,6 +7,7 @@ "drachtio_version": "v0.8.13-rc1", "jambonz_version": "v0.6.7-rc8", "install_datadog": "no", + "datadog_key" : "", "install_telegraf": "yes" }, "builders": [{ @@ -63,12 +64,12 @@ "ssh-keyscan github.com >> ~/.ssh/known_hosts", "mkdir ~/apps", "cd ~/apps", - "git clone git@github.com:jambonz/sbc-options-handler.git", - "git clone git@github.com:jambonz/sbc-outbound.git -b {{user `jambonz_version`}}", - "git clone git@github.com:jambonz/sbc-inbound.git -b {{user `jambonz_version`}}", - "git clone git@github.com:jambonz/sbc-registrar.git -b {{user `jambonz_version`}}", - "git clone git@github.com:jambonz/jambonz-smpp-esme.git -b {{user `jambonz_version`}}", - "git clone git@github.com:jambonz/sbc-call-router.git" + "git clone https://github.com/jambonz/sbc-options-handler.git", + "git clone https://github.com/jambonz/sbc-outbound.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-inbound.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-registrar.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/jambonz-smpp-esme.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-call-router.git" ] }, { @@ -87,6 +88,9 @@ }, { "type": "shell", + "environment_vars": [ + "DD_KEY={{user `datadog_key`}}" + ], "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_datadog`}}", "script": "scripts/install_datadog.sh" },