105 lines
3.3 KiB
Bash
Executable File
105 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
STACK_VERSION=$1
|
|
PROCESSOR_TYPE=$2
|
|
$COMPOSE_FILE
|
|
|
|
get_stack_version() {
|
|
if [[ -n "$STACK_VERSION" ]]; then
|
|
echo 'use provided version'
|
|
echo $STACK_VERSION
|
|
else
|
|
STACK_VERSION=$(curl -X 'GET' 'https://api.callabacloud.com/getCallabaCloudVersion' \
|
|
--header "Content-Type: application/json" \
|
|
-d '{"version_name":"parrot"}' | jq -r '.[].version_number')
|
|
echo 'use version by default'
|
|
fi
|
|
|
|
if [[ $? -ne 0 || -z "$STACK_VERSION" ]]; then
|
|
echo "Error: Failed to get stack version"
|
|
exit 1
|
|
fi
|
|
echo $STACK_VERSION >STACK_VERSION.txt
|
|
export STACK_VERSION
|
|
}
|
|
|
|
start_docker_compose() {
|
|
echo $STACK_VERSION
|
|
if [[ "$PROCESSOR_TYPE" == "nvidia" ]]; then
|
|
echo 'Installing with NVIDIA CUDA...'
|
|
COMPOSE_FILE="docker-compose.cc-full-run-linux-nvidia.yml"
|
|
else
|
|
echo 'Installing...'
|
|
COMPOSE_FILE="docker-compose.cc-full-run-linux.yml"
|
|
fi
|
|
sudo -E docker-compose -f $COMPOSE_FILE 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
|
|
sudo -E docker exec callabacloud-api rm /opt/installation-unfinished
|
|
sudo -E docker restart callabacloud-api
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Error: Failed to start docker-compose with Callaba Cloud"
|
|
exit 1
|
|
else
|
|
echo "Callaba on-premise $STACK_VERSION has installed successfully"
|
|
fi
|
|
}
|
|
|
|
set_iptables() {
|
|
# Ensure the /etc/iptables directory exists
|
|
if [ ! -d /etc/iptables/ ]; then
|
|
sudo mkdir -p /etc/iptables/
|
|
fi
|
|
|
|
# Create the rules.v4 file if it doesn't exist
|
|
if [ ! -f /etc/iptables/rules.v4 ]; then
|
|
sudo touch /etc/iptables/rules.v4
|
|
fi
|
|
|
|
# Set permissions for the rules.v4 file
|
|
sudo chmod 600 /etc/iptables/rules.v4
|
|
|
|
# Add iptables rules
|
|
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
|
|
sudo iptables -A INPUT -p tcp --dport 27019 -j DROP
|
|
sudo iptables -A INPUT -p tcp --dport 6379 -j DROP
|
|
# Check if iptables rules were set successfully
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Error: Failed to set iptables rules"
|
|
exit 1
|
|
fi
|
|
|
|
# Save iptables rules
|
|
sudo iptables-legacy-save >/etc/iptables/rules.v4
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Error: Failed to save iptables rules"
|
|
exit 1
|
|
fi
|
|
|
|
echo "iptables rules set and saved successfully."
|
|
}
|
|
|
|
main() {
|
|
echo "Are you sure you want to install Callaba $STACK_VERSION ? (y/yes to confirm)"
|
|
read -r confirmation
|
|
if [[ "$confirmation" == "y" || "$confirmation" == "yes" ]]; then
|
|
get_stack_version
|
|
start_docker_compose
|
|
echo -e "Within 2-3 minutes, Callaba Dashboard will be available at \033[4;34mhttp://public-ip\033[0m, for example, \033[4;34mhttp://127.0.0.1\033[0m."
|
|
echo -e "For the first login, use the username \033[1madmin\033[0m and the password \033[1mpassword\033[0m."
|
|
echo -e "Don't forget to change it to a new password."
|
|
#set_iptables
|
|
else
|
|
echo "Operation cancelled."
|
|
fi
|
|
}
|
|
|
|
main
|