diff --git a/configure.in b/configure.in
index 78e0180733166f998325faebc708aa47e269add1..186f80a5ec4dd8f9fd73e490daf28ae2df102b99 100644
--- a/configure.in
+++ b/configure.in
@@ -159,5 +159,30 @@ AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
 AC_CHECK_SIZEOF(__int64)
 
-AC_OUTPUT(Makefile src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)
+# $prefix stores the value of the --prefix command line option, or
+# NONE if the option wasn't set.  In the case that it wasn't set, make
+# it be the default, so that we can use it to expand directories now.
+if test "x$prefix" = "xNONE"; then
+  prefix=$ac_default_prefix
+fi
+
+# and similarly for $exec_prefix
+if test "x$exec_prefix" = "xNONE"; then
+  exec_prefix=$prefix
+fi
+
+CONFDIR=`eval echo $sysconfdir/tor`
+AC_SUBST(CONFDIR)
+AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
+AC_DEFINE([CONFDIR], [], [tor's configuration directory])
+
+BINDIR=`eval echo $bindir`
+AC_SUBST(BINDIR)
+
+LOCALSTATEDIR=`eval echo $localstatedir`
+AC_SUBST(LOCALSTATEDIR)
+
+echo "confdir: $CONFDIR"
+
+AC_OUTPUT(Makefile tor.sh src/config/torrc src/config/sample-server-torrc src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)
 
diff --git a/src/config/Makefile.am b/src/config/Makefile.am
index a4401b369b76ad49337077228f7022fdd587256c..8ff9132e7dca2e5b38ec49dc54100acbefb96104 100644
--- a/src/config/Makefile.am
+++ b/src/config/Makefile.am
@@ -1,3 +1,5 @@
+confdir = $(sysconfdir)/tor
 
-EXTRA_DIST = dirservers oprc sample-orrc
+EXTRA_DIST = dirservers
 
+conf_DATA = dirservers torrc sample-server-torrc
diff --git a/src/config/sample-server-torrc.in b/src/config/sample-server-torrc.in
new file mode 100644
index 0000000000000000000000000000000000000000..d0005fd81fb388ce08f7d669f2a1febe74e1505c
--- /dev/null
+++ b/src/config/sample-server-torrc.in
@@ -0,0 +1,20 @@
+# Configuration file for a typical tor node
+
+# The directory for keeping all the config/data for this node
+DataDirectory @LOCALSTATEDIR@/lib/tor
+# A unique handle for this node
+Nickname moria4
+
+# Ports for various services. Comment out or set to 0 if you're not
+# offering that service.
+ORPort 9004 # listening for cell-speaking connections
+APPort 9024 # listening for socks-speaking connections
+#DirPort 0
+
+# Leave this set, or we'll be treated like a client.
+OnionRouter 1
+
+# List of routers. Tor nodes only know about the directory servers
+# at the beginning, and from them they get a list of currently up nodes.
+RouterFile @CONFDIR@/dirservers
+
diff --git a/src/config/torrc.in b/src/config/torrc.in
new file mode 100644
index 0000000000000000000000000000000000000000..eabdabe2e6642d2e5b80669f9807760a2c4026dc
--- /dev/null
+++ b/src/config/torrc.in
@@ -0,0 +1,12 @@
+# Configuration file for a typical tor client
+# (listen for applications only)
+
+# List of routers. Tor nodes only know about the directory servers
+# at the beginning, and from them they get a list of currently up nodes.
+RouterFile @CONFDIR@/dirservers
+
+# Ports for various services. Comment out if you're not running that
+# service.
+#ORPort 9001
+APPort 9050
+
diff --git a/src/or/config.c b/src/or/config.c
index ae14d3bff762b3e8bdeb80cdc96ae7900e42785e..2402a64e9b31116d427571237811259c2d6d6a6e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -220,8 +220,8 @@ int getconfig(int argc, char **argv, or_options_t *options) {
   }
   if(i < argc-1) { /* we found one */
     fname = argv[i+1];
-  } else { /* didn't find one, try /etc/torrc */
-    fname = "/etc/torrc";
+  } else { /* didn't find one, try CONFDIR */
+    fname = CONFDIR "/torrc";
   }
   log(LOG_DEBUG,"Opening config file '%s'",fname);
 
diff --git a/tor.sh.in b/tor.sh.in
new file mode 100644
index 0000000000000000000000000000000000000000..37e338f4d2cd370e0f96b42f1933566f6ca64ff0
--- /dev/null
+++ b/tor.sh.in
@@ -0,0 +1,75 @@
+#! /bin/sh
+
+TORBIN=@BINDIR@/tor
+TORPID=@LOCALSTATEDIR@/run/tor.pid
+TORLOG=@LOCALSTATEDIR@/log/tor/tor.log
+TORCONF=@CONFDIR@/torrc
+RETVAL=0
+
+case "$1" in
+
+    start)
+    if [ -f $TORPID ]; then
+        echo "tor appears to be already running (pid file exists)"
+        echo "Maybe you should run: $0 restart ?"
+        RETVAL=1
+    else 
+        echo -n "Starting tor..."
+        $TORBIN -f $TORCONF -l warning >$TORLOG 2>&1 &
+        RETVAL=$?
+        if [ $RETVAL -eq 0 ]; then
+            echo " ok"
+        else
+            echo " ERROR!"
+        fi
+    fi
+    ;;
+
+    stop)
+    if [ -f $TORPID ]; then
+        echo -n "Killing tor..."
+        kill `cat $TORPID`
+        RETVAL=$?
+        if [ $RETVAL -eq 0 ]; then
+            echo " ok"
+        else
+            echo " ERROR!"
+        fi
+    else
+        echo "Unable to kill tor: $TORPID does not exist"
+        RETVAL=1
+    fi
+    ;;
+
+    restart)
+    $0 stop
+    if [ -f $TORPID ]; then
+            rm -f $TORPID
+    fi
+    $0 start
+    ;;
+
+    status)
+    PID=`cat $TORPID 2>/dev/null`
+    if [ "$PID" != "" ]; then
+        torstat=`ps -p $PID | grep -c "^$PID"`
+        if [ $torstat ]; then
+            echo "tor is running ($PID)"
+        else
+            echo "tor is not running (looks like it crashed, look for core?  $PID)"
+        fi
+    else
+        echo "tor is not running (exited gracefully)"
+    fi
+    ;;
+
+    log)
+    cat $TORLOG
+    ;;
+    
+    *)
+    echo "Usage: $0 (start|stop|restart|status|log)"
+    exit 1
+esac
+
+exit $RETVAL