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.
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/init.d/tor from Debian's Tor package.
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
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?