Raspberry + Transmission

Let’s begin with the basics. We’ll need to upgrade the system to the latest, and update the apt-get database. Once ready, we’ll proceed with the transmission’s daemon + cli binaries, as follows:

sudo
apt-get update
apt-get upgrade
apt-get install transmission-cli transmission-common transmission-daemon transmission-remote-cli

Authentication:
By default, transmission requires you to setup username / password. Since our goal is *not* to expose Transmission to the open internet (and we’ll only use it via SSH), we’ll simply neutralize any kind of authentication:

nano /etc/transmission-daemon/settings.json

Once there, edit this snippet:

rpc-authentication-required: false

Logging:
We want Transmission to keep an events log. Anything that goes wrong during setup… must be persisted, otherwise, debugging it will be a nightmare.

The only way i’ve found to set this up, is by means of the Daemon Service Descriptor:

nano /lib/systemd/system/transmission-daemon.service

Once there, you want to add the logfile’s path. Make sure that the file exists, and Transmission’s user has enough permissions to edit it:

OPTIONS="--config-dir $CONFIG_DIR  --logfile /var/log/transmission.log"

Filesystem Permissions:

Transmission’s user is specified in the transmission-daemon.service descriptor (which is debian-transmission). So… you really wanna make sure whatever shared folder you end up using, belongs to Transmission’s group.

usermod -a -G debian-transmission YOUR_USER
chgrp debian-transmission /DOWNLOADS/PATH
chmod 770 /DOWNLOADS/PATH

Magnets!

In order to begin downloading a magned, try the following:

transmission-remote-cli
(And press 'A')

Restarting Stopped

Last tip: If you need to restart all of your downloads at once, this command becomes quite handy:

transmission-remote -t all -s

Raspbian: Disabling Graphic Mode

Why: because i’m setting up my Raspberry as a private server, and i really don’t need the XWindow overhead!

How: As follows!

systemctl get-default

Verify that the output is: graphical.target.
Now… type the following!

sudo systemctl set-default multi-user.target

Ref. Here

Update:

Simpler way? just run raspi-config and change the setting right there!

Spotify: Multiuser Issues

I’ve recently hit an annoying issue: if you share your mac with, say, your brother… you’ll figure out that Spotify will only work in one of the two accounts.

It doesn’t really matter if you actually have two seats or not. It won’t run at all.

Solution?. As ever… bash and…

cd /Applications
sudo chmod -R 755 Spotify.app/

Twilio, the Cloud… and Me!

Today, we’ll briefly detail how to setup a Twilio VoIP number in a way that it’ll allow us to:

– Receive SMS’s via Email
– Send SMS’s via CLI
– Receive Voice Calls via Landline, and if nobody picks up, fallback to Softphone
– Make Voice Calls via Softphone

Before we begin, you’ll need to:

1. Signup!
2. Register a Number!
3. Create a SIP Domain
4. Add a User under the SIP Domains > Credential Lists
5. Setup this “SMS to Email” PHP script”, in your favorite EC2 box

Once ready, let’s open the Developer Center, and opening the TwiML bins. Once there, add the following TwiML’s:

Name: Incoming Voice to Softphone:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
      <Dial>
       <Sip>USER@SIP-DOMAIN.sip.us1.twilio.com</Sip>
    </Dial>
</Response>

Name: Incoming Voice to Landline:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>Please, hold on the line while i put you through.</Say>
  <Dial callerId="TWILIO-NUMBER" timeout="5" action="URL-OF-VOICE-TO-SOFTPHONE-TWIML">
   <Number>YOUR-LANDLINE-NUMBER</Number>
  </Dial>
</Response>

Name: Incoming SIP to Destination:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial callerId="TWILIO-NUMBER">{{#e164}}{{To}}{{/e164}}</Dial>
</Response>

Name: Incoming SMS to Email:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Redirect method="POST">URL-MAPPED-TO-YOUR-SEND-MAIL-SCRIPT</Redirect>
</Response>

Once ready, open Phone Numbers > Manage Numbers > Active Numbers and map everything as follows:

A call comes in: Incoming voice to Landline TwiML
A message comes in: Incoming SMS to email Script’s URL

Finally, we need to map the “Incoming Voice to Softphone” TwiML, as follows:

– Open Programmable Voice
– Open SIP Domains and click over your domain
– Set the “Incoming Voice to Softphone” TwiML URL in the Voice Configuration > Request URL field

That should be it, pretty much. As per Soft Phones available for macOS, the most common one is X-Lite, which offers a free version (and it’s also available for iOS).

Hope that helps!

P.s.: With the following snippet, placed in you ~/.profile, you should be also able to send SMS’s via CLI:

function sms() {
   curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/ACCOUNT-KEY/Messages.json' \
       --data-urlencode "To=${@:1:1}" \
       --data-urlencode "From=YOUR-TWILIO-PHONE" \
       --data-urlencode "Body=${@:2:1}" \
       -u USER-KEY:USER-SECRET
}