PageSourceSearch

https://toraritte.github.io/progress-notes/how-to-properly-deploy-TR2.html

html toraritte.github.io collected 2026-10-03 10:05:42 UTC 15,665 bytes, 245 lines download raw bytes

1<!DOCTYPE html>
2<html lang="en-US">
3  <head>
4    <meta charset="UTF-8">
5    <meta http-equiv="X-UA-Compatible" content="IE=edge">
6    <meta name="viewport" content="width=device-width, initial-scale=1">
7
8<!-- Begin Jekyll SEO tag v2.8.0 -->
9<title>SFTB: How to properly deploy TR2? | Attila Gulyas</title>
10<meta name="generator" content="Jekyll v3.10.0" />
11<meta property="og:title" content="SFTB: How to properly deploy TR2?" />
12<meta property="og:locale" content="en_US" />
13<link rel="canonical" href="https://toraritte.github.io/progress-notes/how-to-properly-deploy-TR2.html" />
14<meta property="og:url" content="https://toraritte.github.io/progress-notes/how-to-properly-deploy-TR2.html" />
15<meta property="og:site_name" content="Attila Gulyas" />
16<meta property="og:type" content="website" />
17<meta name="twitter:card" content="summary" />
18<meta property="twitter:title" content="SFTB: How to properly deploy TR2?" />
19<script type="application/ld+json">
20{"@context":"https://schema.org","@type":"WebPage","headline":"SFTB: How to properly deploy TR2?","url":"https://toraritte.github.io/progress-notes/how-to-properly-deploy-TR2.html"}</script>
20
21<!-- End Jekyll SEO tag -->
22
23    <link rel="stylesheet" href="/assets/css/style.css?v=2e4e05398716835f452dd1bc0a0a558d983a598a">
24    <!-- start custom head snippets, customize with your own _includes/head-custom.html file -->
25
26<!-- Setup Google Analytics -->
27
28
29
30<!-- You can set your favicon here -->
31<!-- link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" -->
32
33<!-- end custom head snippets -->
34
35  </head>
36  <body>
37    <div class="container-lg px-3 my-5 markdown-body">
38
39      <h1 id="sftb-how-to-properly-deploy-tr2">SFTB: How to properly deploy TR2?</h1>
40
41<p>Been down this road before so picking up the thread (or more like re-tracing my steps) from <a href="https://discourse.nixos.org/t/nixos-images-on-azure/7062">NixOS images on Azure</a>.</p>
42
43<h2 id="2022">2022</h2>
44<h3 id="2022-09-06-nixos-on-azure">2022-09-06: NixOS on Azure</h3>
45
46<p>The premise was to use configure TR2 (FreeSWITCH + Erlang script) on NixOS, and deploy it on Azure, but that is put on hold because</p>
47
48<blockquote>
49  <p>The Azure platform SLA applies to virtual machines running the Linux OS only when one of the <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/endorsed-distros">endorsed distributions</a> is used.</p>
50</blockquote>
51
52<p>(See <a href="https://discourse.nixos.org/t/nixos-images-on-azure/7062/22">this reply</a> in the above Discourse thread for context.)</p>
53
54<blockquote>
55  <p>QUESTION: How does one add NixOS to the Azure Marketplace to make it an “endorsed distribution”?</p>
56</blockquote>
57
58<blockquote>
59  <p>HISTORICAL NOTE</p>
60
61  <p>Before moving on: did spend some time on Cole Mickens’ <a href="https://github.com/NixOS/nixpkgs/tree/master/nixos/maintainers/scripts/azure-new"><code class="language-plaintext highlighter-rouge">azure-new</code></a> script, and the result is <a href="https://github.com/society-for-the-blind/nixos-azure-deploy">society-for-the-blind/nixos-azure-deploy</a>. It may already be obsolete as he already wrote a follow-up that is a <a href="https://github.com/colemickens/flake-azure-demo/tree/dev">Rust-based and flakified version</a> of <code class="language-plaintext highlighter-rouge">azure-new</code>.</p>
62
63  <p>The latest (and probably most up-to-date) contender is <a href="https://github.com/Plommonsorbet/nixos-azure-gen-2-vm-example">Plommonsorbet/nixos-azure-gen-2-vm-example</a>.</p>
64
65  <p>Notable mentions along this journey:</p>
66
67  <ul>
68    <li>
69      <p><a href="https://github.com/colemickens/nixcfg/">colemickens/nixcfg</a> (Cole Mickens’ configuration repo)</p>
70    </li>
71    <li><a href="https://github.com/nix-community/nixos-generators">nix-community/nixos-generators</a>
72      <blockquote>
73        <p>The nixos-generators project allows to take the same NixOS configuration, and generate outputs for different target formats.</p>
74      </blockquote>
75    </li>
76    <li>
77      <p><a href="https://pkgs.on-nix.com/nixpkgs/azure-vhd-utils/">nixpkgs/azure-vhd-utils</a></p>
78
79      <blockquote>
80        <p>Go package to read Virtual Hard Disk (VHD) file, a CLI interface to upload local VHD to Azure storage and to inspect a local VHD</p>
81      </blockquote>
82    </li>
83    <li>
84      <p><a href="https://github.com/MicrosoftDocs/azure-docs/issues/52340">Why Choose Gen2? aka Timeline for Gen2 Disk Encryption? #52340</a></p>
85    </li>
86    <li>
87      <p><a href="https://github.com/sauryadas/NixOS_Azure">sauryadas/NixOS_Azure</a></p>
88    </li>
89    <li><a href="https://nix-community.github.io/awesome-nix/">Awesome Nix</a></li>
90  </ul>
91</blockquote>
92
93<h3 id="2022-09-07-use-nix-on-linux-to-deploy-tr2">2022-09-07: Use Nix on Linux to deploy TR2</h3>
94
95<p>Current Linux choice is Debian, because</p>
96
97<blockquote>
98  <p>Debian (preferred) The development team uses and builds against Debian. They recommend Debian because of its operationally stable, yet updated, kernel and wide library support.<br />
99<sup><a href="https://freeswitch.org/confluence/display/FREESWITCH/Installation">from FreeSWITCH docs</a></sup></p>
100</blockquote>
101
102<p>Did <a href="https://www.google.com/search?q=manage+system+services+with+nix&amp;oq=manage+system+services+with+nix+&amp;aqs=chrome..69i57j33i160l4j33i299.10263j0j4&amp;sourceid=chrome&amp;ie=UTF-8">a search for <code class="language-plaintext highlighter-rouge">manage system services with nix</code></a>, and the first result was <a href="https://unix.stackexchange.com/questions/349199/how-does-nix-manage-systemd-modules-on-a-non-nixos">
102How does Nix manage SystemD modules on a non-NixOS?</a> on UNIX &amp; Linux Stackexchange.</p>
103
104<h3 id="2022-09-08-systemd-disnix">2022-09-08: systemd, Disnix</h3>
105
106<p>Tons of great info in there that I’m unable to absorb yet, so created the Discourse thread <a href="https://discourse.nixos.org/t/how-does-nix-manage-systemd-modules-on-a-non-nixos/21499">How does Nix manage SystemD modules on a non-NixOS?</a> to track similar topics from Discourse which, surprisingly, have very little information on this matter.</p>
107
108<p>Opened as many tabs as I could from the search (obviously..), and one of the results was from Sander van der Burg’s blog, an article titled <a href="http://sandervanderburg.blogspot.com/2021/03/using-nix-process-management-framework.html">Using the Nix process management framework as an infrastructure deployment solution for Disnix</a>. (<a href="/progress-notes/assets/2021-03-12_Using-the-Nix-process-management-framework-as-an-infrastructure-deployment-solution-for-Disnix.pdf">annotations</a>)<sup><b>♠</b></sup></p>
109
110<p><sup>[♠]: First, here’s the <a href="https://gist.github.com/toraritte/419f9012e62fc05486acdf7b1e272341">JavaScript snippet</a> used to format Sander’s blogspot articles to be properly print them to PDF to do annotations with Xodo. Second, there may be no annotation in there because I accidentally deleted the file, and syncthing diligently propagated that change across every devices. (TODO: set up versioning and/or add a crontab entry to back up periodically.)</sup></p>
111
112<p>Got stuck quickly because I’m missing the basics, so jumped over to <a href="https://sandervanderburg.blogspot.com/2011/02/disnix-toolset-for-distributed.html">Disnix: A toolset for distributed deployment</a>, where Sander first announced Disnix (<a href="/progress-notes/assets/2011-02-16_Disnix--A-toolset-for-distributed-deployment.pdf">annotations</a>).</p>
113
114<p>The Disnix intro article above doesn’t mention systemd (it was written only a couple months after systemd was announced), but services come up a lot, and most other posts I skimmed talk heavily about systemd. That is another topic I know little about, so switched again to learn it.</p>
115
116<h3 id="2022-09-26-systemd-still-and-tr2-dev">2022-09-26: systemd still, and tr2-dev</h3>
117
118<h4 id="systemd">systemd</h4>
119
120<p>Finished reading and annotating the (only) systemd book I could find, <a href="https://www.amazon.com/Linux-Service-Management-Made-systemd/dp/1801811644">Linux Service Management Made Easy with systemd</a>; it has tons of good info, but the style made me almost quit, and clarity is not it’s strongest suit.</p>
121
122<p>There’s still plenty of good resources, will continue there.</p>
123
124<h4 id="tr2-dev">tr2-dev</h4>
125
126<p>Finally summoned the courage to re-create the TR2 service to use it as a backup and as a development server; it will nice not to hack on the production server:) Hoping to nixify the whole process, and maybe even to create a NixOS counterpart (as it is currently running on Debian).</p>
127
128<h5 id="step-1-re-create-tr2">Step 1. Re-create TR2</h5>
129
130<ol>
131  <li>
132    <p>Set up new Debian VM.</p>
133  </li>
134  <li>
135    <p><a href="https://nixos.org/download.html">Install Nix</a> by using the multi-user installation.</p>
136  </li>
137</ol>
138
139<blockquote>
140  <p>QUESTION Why does SELinux need to be disabled? And how does one check if it is enabled?</p>
141</blockquote>
142
143<ol>
144  <li>
145    <p><code class="language-plaintext highlighter-rouge">nix-shell -pv git</code></p>
146  </li>
147  <li>
148    <p>Clone the <a href="https://github.com/access-news/phone-service">access-news/phone-service</a> GitHub repo.</p>
149  </li>
150</ol>
151
152<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  mkdir clones
153  cd clones
154  git clone https://github.com/access-news/phone-service.git
155</code></pre></div></div>
156
157<ol>
158  <li>Follow the <a href="https://freeswitch.org/confluence/display/FREESWITCH/Debian">FreeSWITCH wiki’s Debian install instructions</a> up to the installation, but stop before that because:</li>
159</ol>
160
161<blockquote>
162  <p>WARNING: Use <code class="language-plaintext highlighter-rouge">sudo su</code> to execute the commands in the root shell; at least, prefixing these with <code class="language-plaintext highlighter-rouge">sudo</code> doesn’t always seem to work because of all the redirections going on. While this is not ideal 
162(no logs, etc.), this way it <strong>will</strong> work, and only doing this to re-establish understanding of the project anyway before trying to nixify it.</p>
163</blockquote>
164
165<blockquote>
166  <div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>TOKEN=YOURSIGNALWIRETOKEN
167</code></pre></div>  </div>
168
169  <p>(Go <a href="https://freeswitch.org/confluence/display/FREESWITCH/HOWTO+Create+a+SignalWire+Personal+Access+Token">here</a> to get the token.)</p>
170
171  <div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>apt-get update &amp;&amp; apt-get install -y gnupg2 wget lsb-release
172
173wget --http-user=signalwire --http-password=$TOKEN -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg
174
175echo "machine freeswitch.signalwire.com login signalwire password $TOKEN" &gt; /etc/apt/auth.conf
176chmod 600 /etc/apt/auth.conf
177echo "deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" &gt; /etc/apt/sources.list.d/freeswitch.list
178echo "deb-src [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" &gt;&gt; /etc/apt/sources.list.d/freeswitch.list
179</code></pre></div>  </div>
180</blockquote>
181
182<p>Didn’t bother with the warning below, just went ahead and installed it, because this is what I did in the past apparently based on <a href="https://github.com/access-news/phone-service/blob/6b49f27a8d6831aa917d59e632694d135966f937/deploy.bash"><code class="language-plaintext highlighter-rouge">deploy.bash</code></a> (which renames the vanilla config in <code class="language-plaintext highlighter-rouge">/etc/freeswitch</code> to <code class="language-plaintext highlighter-rouge">/etc/freeswitch_old</code>).</p>
183
184<blockquote>
185  <div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code># you may want to populate /etc/freeswitch at this point.
186# if /etc/freeswitch does not exist, the standard vanilla configuration is deployed
187apt-get update &amp;&amp; apt-get install -y freeswitch-meta-all
188</code></pre></div>  </div>
189</blockquote>
190
191<p>c(“outbound_erl2/content”), c(“outbound_erl2/filog”), c(“outbound_erl2/fs”), c(“outbound_erl2/futil”), c(“outbound_erl2/ivr”), c(“outbound_erl2/menus”), c(“outbound_erl2/tts”), c(“outbound_erl2/user_db”), filog:start(), user_db:start(), content:start
192().</p>
193
194<ol>
195  <li>Test out the install</li>
196</ol>
197
198<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  sudo service freeswitch start
199  fs_cli
200</code></pre></div></div>
201<blockquote>
202  <p>NOTE / QUESTION: The <code class="language-plaintext highlighter-rouge">freeswitch</code> group and user are added by the installer automatically. Does the Nix package takes care of this too? Probably does because there is a systemd service for it in Nixpgks, and it is probably (and hopefully) not started as root.</p>
203</blockquote>
204
205<ol>
206  <li>
207    <p>Copy the config from TR2 to TR2-DEV</p>
208
209    <p>That would mostly mean <code class="language-plaintext highlighter-rouge">/etc/freeswitch</code>, but it is more nuanced than that, because Google’s TTS is also used in the service at the moment, so there is a JSON file for authenticating for that, and some Lua stuff. The latter was supposed to be dropped, but forgot if I already did, and never updated to docs, so…</p>
210
211    <p>QUESTION: How are the phone numbers 916.732.4000 and 800.665.4667 configured? (This part is crucial, because I didn’t want to set up a backup that disrupts the service in production.)</p>
212
213    <p>ANSWER: Will annotate the relevant config files and document it here as well, but the real answer is that this is set up in the SignalWire Dashboard (i.e., in our case, at <a href="https://sftb.signalwire.com">sftb.signalwire.com</a>); the <a href="https://sftb.signalwire.com/phone_numbers"><code class="language-plaintext highlighter-rouge">mod_signalwire</code></a> explains this in details, but re-iterating here just in case:</p>
214  </li>
215  <li>
216    <p>Generate a token in <code class="language-plaintext highlighter-rouge">fs_cli</code> with the <code class="language-plaintext highlighter-rouge">signalwire token</code> command.</p>
217  </li>
218  <li>
219    <p>Create a new SignalWire integration (go to “Integrations” on the <a href="https://sftb.signalwire.com">Dashboard</a>); enter the token when asked for it, and fill out the forms. (NOTE: An outgoing phone number needs to be specified even if there will be no outgoing calls.)</p>
220  </li>
221  <li>
222    <p>Go to “Phone Numbers” &gt; (click on number) &gt; “Edit Settings”, and add the connector/integration for the desired FreeSWITCH instance.</p>
223  </li>
224</ol>
225
226<p>The config files seem to play little role here for TR2 at the moment, but will dive into them just in case.</p>
227
228<hr />
229
230<p>QUESTION: Started looking at the API, and was wondering if a FreeSWITCH instance is necessary at all? Could it be recreated in JavaScript/TypeScript, and just done with it?</p>
231
232<hr />
233
234<p>QUESTION: How to send texts? Would probably be a good thing for authentication purposes later on.</p>
235
236<hr />
237
238
239
240      
241    </div>
242    
242<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.0/anchor.min.js" integrity="sha256-lZaRhKri35AyJSypXXs4o6OPFTbTmUoltBbDCbdzegg=" crossorigin="anonymous"></script>
242
243    
243<script>anchors.add();</script>
243
244  </body>
245</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.