-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoturn.sh
136 lines (120 loc) · 3.63 KB
/
coturn.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
sudo apt-get install -y lsb-release
# No promtheus support in Ubuntu 20.04 apt version 4.5.1 - for this you need >= 4.5.2
# For 4.5.2 with prometheus support you need to compile from scratch for Ubuntu.
# Debian repo has 4.5.2 now for bookworm and Ubuntu >22.04
version="4.5.2"
detect_linux_distribution() {
# Function to see if a specific linux distribution is supported by this script
# If it is supported then the global variable SETUP_ENTRYPOINT is set to the
# function to be executed for the FS setup
local distro_name=$(lsb_release -si)
local distro_version=$(lsb_release -sr)
local distro_codename=$(lsb_release -sc)
DISTRO="$distro_name"
DISTRO_VERSION="$distro_version"
DISTRO_CODENAME="$distro_codename"
case "$distro_name" in
Ubuntu ) case "$distro_version" in
20.04* | 22.04* ) SETUP_ENTRYPOINT="ubuntu_choice"
return 0 ;; # Suported Distribution
* ) return 1 ;; # Unsupported Distribution
esac
;;
Debian ) case "$distro_version" in
10* | 11* | 12* ) SETUP_ENTRYPOINT="setup_apt"
return 0 ;; # Suported Distribution
* ) return 1 ;; # Unsupported Distribution
esac
;;
* ) return 1 ;; # Unsupported Distribution
esac
}
ubuntu_choice() {
# Also get entrypoint for the install
echo "Press 1 to use apt (No Prometheus support for 20.04 - ok for other Debian based distros)"
echo "Press 2 to install manually (with Prometheus support for 20.04)"
options=("1" "2")
select choice in "${options[@]}"
do
case $choice in
"1")
SETUP_ENTRYPOINT="setup_apt"
break
;;
"2")
SETUP_ENTRYPOINT="setup_manual"
break
;;
*)
echo "Invalid option"
;;
esac
done
}
setup_apt() {
sudo apt-get install -y coturn
}
setup_manual() {
apt update
cd /usr/
apt install -y make git build-essential pkg-config libssl-dev libevent-dev libmicrohttpd-dev libsystemd-dev libhiredis0.14 libmysqlclient21 libpq5 mysql-common sqlite3
wget https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libprom-dev-0.1.3-Linux.deb
wget https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libpromhttp-dev-0.1.3-Linux.deb
sudo dpkg -i libprom-dev-0.1.3-Linux.deb
sudo dpkg -i libpromhttp-dev-0.1.3-Linux.deb
git clone --branch $version --single-branch https://github.com/coturn/coturn.git
cd /usr/coturn
nano configure
# Change CONFDIR location to /etc
# Change the PREFIX location as /usr - was /usr/local
# Or simlink after testing this
./configure
make && make install
mkdir /var/log/coturn
}
reboot_selection() {
echo "Install done. Press 1 to reboot..."
echo "Otherwise press any other key to exit"
options=("1")
select choice in "${options[@]}"
do
case $choice in
"1")
echo "Rebooting now..."
sudo reboot
break
;;
*)
echo "You pressed a key! Exiting..."
break
;;
esac
done
}
banner_start() {
clear;
echo "Installing CoTURN on $distro_name"
echo "Standby"
echo;
}
banner_end() {
clear;
echo "Hopefully CoTURN is now installed on $distro_name"
echo "Run turnserver to be sure after rebooting"
echo;
}
# Actual install logic
start_app() {
detect_linux_distribution
banner_start
$SETUP_ENTRYPOINT
banner_end
reboot_selection
}
######################################################################
#
# Start of main script
#
######################################################################
[[ "$0" == "$BASH_SOURCE" ]] && start_app