2

I compiled tor from the source tarball annd configured it to run as a relay. The problem is that it won't start automatically on boot. I'm running raspbian jessie on a raspberry pi.

  • 1
    You don't have to compile from source anymore on the Pi 2 and newer. The Debian repository is fully compatible now. – SuperSluether Sep 7 '16 at 19:06
  • The Raspbian repository version of Tor is v2.5 and heavily deprecated. Version 2.8 is current, version 2.9 arrives soon. I recommend you not use the versions of Tor less than 2.7. – Alec Muffett Dec 6 '16 at 19:48
1

You can make Tor start on boot by running (as root):

update-rc.d tor enable

Because you compiled Tor from source, you may not have the files to automatically start Tor at boot. If it says some file is missing, you can extract /etc/default/tor and /etc/init.d/tor from Debian's Tor package.

1

The best way is to use a three components:

  • /etc/rc.local - It's a script that is executed on boot. I'm using it to start the components I need - see how downstrings.
  • A daemontools package - it's available via apt-get install daemontools. It's homepage is here. This package runs it's main binary in foreground and after that it is spawning a process-control mechanism. It works brilliantly on Linx and FreeBSD - chacked it myself.
  • A screen package - it's available via apt-get install screen. It's homepage is here, and it's a well-debugged app. What it does: it runs something "as in tty/screen", so the program thinks that it is running interactively.

How to elaborate it: I'm using a shellscript named as /service/tor/run to run the Tor interactively( = explicitly saying in torrc config RunAsDaemon 0 and User tor) like this:

#!/bin/bash
cd /path/to/your/tor/install/prefix
nice -n -12 /path/to/your/tor/install/prefix/bin/tor -f /etc/torrc 2>&1

That rises up Tor with altered priority and under tor username. Oki-doki! And in /etc/rc.local I'm using just this before it's exit 0 clause:

/usr/bin/screen -d -m -S dt /usr/sbin/svscan /service

And that will spawn the Screen that will take care of running the Daemontools to ensure starting and re-starting on crush the Tor binary.

That's it! This setup works 2+ years on RPi and no single failure even with auto-updates and release-upgrades: it's a fuckup-proof. Makes sense?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.