Intro
I went into this expecting it to be simply apt-get install asterisk.
I was SOOOOOO wrong.
The documentation for raspberry pi 5 + asterisk is so ass, I could only find tutorials of pi 4, and those tutorials showcased the asterisk apt binary. News flash: APT doesn't FUCKING have asterisk for some reason despite apt-cache
saying otherwise. Anwyays, let's delve into my suffering haha
First let's talk about asterisk for those who don't know:
Asterisk is basically a big engine that can be encapsulated as a daemon & 2 configs for your system that runs as a server doing phone-line-handling service using SIP. Search up about SIP and how it works, very interesting I must say.
Also search up about asterisk to learn more, but here I will do a briefing on its purpose:
It was meant to be a purely software-based precursor to traditional, hardware, ridiculous & hyper-complex giant box called a PBX (Private Branch Exchange) that just:
- Managed internal phone extensions internally
- Handled the call routing
- connected internal phone endpoints to external phone lines
- voicemails, holds, all that juicy stuff
These were basically insanely hard to maintain and far more susceptible to errors and somehow still held up well.
Now this is basically what runs your phone services. But instead of some giant ass apache server box, we're gonna do it on a tiny little pi.
LET'S GET IT
1. apt-get
failed me
I did what any sane human would have done:
sudo apt install asterisk
But guess what? I got this dumb error:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package asterisk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'asterisk' has no installation candidate
Even "apt-cache search asterisk" yielded nothing at all. Just a bunch of random utils that relate to some deprecated shit.
2. Tried to build from source (initially went well)
So then I decided hey, why not just go the old, "rough and tough" way and literally BUILD FROM SOURCE!!! >:)
We started of with le "wget https://github.com/asterisk/asterisk/" XD
Then tried to build and make as any sane human would but then I ran into dumb issues of pjsip modules not being loaded and trying to interfere with the global libs Could not get it to run in the native environment no matter what.
3. Rebuilding but with PJSIP support this time...
Even trying to get PJSIP built and then giving the option for asterisk to include PJSIP when getting made did not get the modules loaded. Remember, PJSIP modules are literally the soul of this damn thing. Basically FUCKING NECESSARY just to get asterisk to run.
I literally had to rebuild and make this like thousands of times only to be met with disappointment.
4. Switching to Docker
This is why we use shit like Docker, Kubernetes and other shit like that. Basically a stripped down, barebones environment that you can run processes in without having to worry about dependency hells and conflicts.
So I installed Docker, mounted a folder with all my system-wide Asterisk configs from the native host, and passed it into the container as a volume. That way, my Dockerized Asterisk instance uses the exact same configs I had working before—no rewrites, no surprises.
This is what I ran:
docker run -it --rm --name asterisk \
--network host \
--privileged \
-v ~/asterisk-config:/etc/asterisk \
asterisk-pjsip
Now, if you're thinking, "Let's just turn this into a systemd service and bam", well there's a catch. You can't use -it because that's designed for terminal use. But we are gonna make it a systemd service instead, so we don't have to run commands all the time.
5. My PC (which runs arch x86) and iPhone registered successfully
6. Next steps:
- Connecting some old ass analog phones to some SIP endpoints via ATA device
- Integrating with some Twilio SIP trunk to connect to PSTN (phoning numbers outside the LAN)
Update: These are both done hehe I will blog about this later :D
Conclusion?
I just built my own DAMN service provider for phoning but only works within the confines of my LAN as of now.
Very fun (and annoying) experience that I started the other day lel :P