#!/bin/bash STACK_VERSION="" get_stack_version() { if [ $# -gt 0 ]; then STACK_VERSION="$1" else STACK_VERSION=$(curl -X 'GET' 'https://api.callabacloud.com/getCallabaCloudVersion' --header "Content-Type: application/json" -d '{"version_name":"parrot"}' | jq -r '.[].version_number') fi if [[ $? -ne 0 ]]; then echo "Error: Failed to get stack version" exit 1 fi export STACK_VERSION } start_docker_compose() { echo $STACK_VERSION sudo -E docker-compose -f docker-compose.cc-full-run-linux.yml up -d if [[ $? -ne 0 ]]; then echo "Error: Failed to start docker-compose with Callaba Cloud" exit 1 fi sudo -E docker-compose -f webrtc/docker-compose.cc-webrtc.yml up -d if [[ $? -ne 0 ]]; then echo "Error: Failed to start docker-compose with Callaba Cloud" exit 1 else echo ' ###################################################################### ########### Callaba Cloud has been installed successfully ########### ######################################################################' fi } set_iptables() { if [ ! -d /etc/iptables/ ]; then sudo mkdir /etc/iptables/ fi sudo chmod 666 /etc/iptables/rules.v4 sudo iptables -I INPUT -i lo -j ACCEPT sudo iptables -A INPUT -p tcp --dport 3000 -j DROP sudo iptables -A INPUT -p tcp --dport 3021 -j DROP sudo iptables -A INPUT -p tcp --dport 3031 -j DROP sudo iptables -A INPUT -p tcp --dport 27017 -j DROP if [[ $? -ne 0 ]]; then echo "Error: Failed to set iptables" exit 1 fi sudo iptables-save > /etc/iptables/rules.v4 if [[ $? -ne 0 ]]; then echo "Error: Failed to save iptables rules" exit 1 fi } main() { get_stack_version start_docker_compose set_iptables } main