<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guy Rutenberg &#187; Trac</title>
	<atom:link href="http://www.guyrutenberg.com/tag/trac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deleting Comments from Tickets in Trac</title>
		<link>http://www.guyrutenberg.com/2010/05/19/deleting-comments-from-tickets-in-trac/</link>
		<comments>http://www.guyrutenberg.com/2010/05/19/deleting-comments-from-tickets-in-trac/#comments</comments>
		<pubDate>Wed, 19 May 2010 12:42:06 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Trac]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=684</guid>
		<description><![CDATA[Spammers apparently love Trac. After trying to fighting spam tickets and later installing the SpamFilter plugin, I&#8217;ve managed to control spam tickets in the Open Yahtzee Trac site.. But now spammers started spamming in the ticket comments. The bad news is that Trac (at least in version 0.11) doesn&#8217;t have built-in facilities to completely remove [...]]]></description>
			<content:encoded><![CDATA[<p>Spammers apparently love Trac. After trying to fighting spam <a href="/2009/01/08/deleting-a-range-of-tickets-in-trac/">tickets</a> and later installing the SpamFilter plugin, I&#8217;ve managed to control spam tickets in the <a href="http://www.openyahtzee.org">Open Yahtzee</a> Trac site.. But now spammers started spamming in the ticket comments. The bad news is that Trac (at least in version 0.11) doesn&#8217;t have built-in facilities to completely remove ticket comments.</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2010/05/trac-comment.png"><img src="http://www.guyrutenberg.com/wp-content/uploads/2010/05/trac-comment.png" alt="" title="trac-comment" width="509" height="311" class="aligncenter size-full wp-image-688" /></a><br />
<span id="more-684"></span><br />
The solution is to directly delete them from Trac&#8217;s SQLite backend. There are several type of comments: Plain ones and comments that describe a change to the ticket&#8217;s properties. I&#8217;ll deal with only the plain comments, but the methods I describe should also be applicable to the other kinds.</p>
<p>First things you should note down the ticket number and the comment number. The comment number appears in the URL of the permalink to it. It is the number that is pointed by an arrow in the screenshot above, it will be displayed when you hover over the circled link. Now in the shell, <code>cd</code> to the <code>db</code> directory of you trac installation and do:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sqlite3 trac.db &quot;delete from ticket_change where ticket=&lt;TICKET NUM&gt; and field='comment' and oldvalue=&lt;COMMENT NUM&gt;&quot;</pre></div></div>

<p>For example for the ticket in the screenshot:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sqlite3 trac.db &quot;delete from ticket_change where ticket=12 and field='comment' and oldvalue=3&quot;</pre></div></div>

<p>You can delete different kinds of tickets by using other values in the <code>field</code> column, such as <code>keywords</code> and <code>summary</code>. Another useful column is the <code>author</code> column.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/05/19/deleting-comments-from-tickets-in-trac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting tracd without Root Privileges at Startup</title>
		<link>http://www.guyrutenberg.com/2009/02/17/starting-tracd-without-root-privileges-at-startup/</link>
		<comments>http://www.guyrutenberg.com/2009/02/17/starting-tracd-without-root-privileges-at-startup/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 17:28:20 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Trac]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=263</guid>
		<description><![CDATA[I use Trac for the Open Yahtzee website. I&#8217;ve decided to use tracd for serving the requests (due to a configuration issue I didn&#8217;t want to mess with), which required starting it each time the server restarts. I&#8217;ve already written one solution for it, in the form of an init.d script for tracd. However, it [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://trac.edgewall.org/">Trac</a> for the <a href="http://www.openyahtzee.org">Open Yahtzee</a> website. I&#8217;ve decided to use <code>tracd</code> for serving the requests (due to a configuration issue I didn&#8217;t want to mess with), which required starting it each time the server restarts. I&#8217;ve already written one solution for it, in the form of an <a href="/2008/06/04/start-trac-on-startup-initd-script-for-tracd/"><code>init.d</code> script for <code>tracd</code></a>. However, it bothered me that the <code>tracd</code> runs with root privileges which it doesn&#8217;t really requires.</p>
<p>After searching a bit I&#8217;ve found out that <code>cron</code> can run tasks on startup using the special <code>@reboot</code> keyword instead of the normal time fields. So edit your crontab and add the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">@reboot /usr/bin/tracd --daemonize --pidfile=~/run/tracd.pid --port=PORT --hostname=HOSTNAME -s TRAC_ENV</pre></div></div>

<p>Just replace <code>PORT</code>, <code>HOSTNAME</code> and <code>TRAC_ENV</code> with the appropriate values for your environment, and make sure you got a <code>run/</code> sub-directory in your home folder (or change the pidfile value).</p>
<p>To stop the server just do:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">kill `cat ~/run/tracd.pid`</pre></div></div>

<p>While there is no straight way to restart the server (like <code>/etc/init.d/tracd restart</code>), it&#8217;s a good compromise for dropping root privileges.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/02/17/starting-tracd-without-root-privileges-at-startup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting a Range of Tickets in Trac</title>
		<link>http://www.guyrutenberg.com/2009/01/08/deleting-a-range-of-tickets-in-trac/</link>
		<comments>http://www.guyrutenberg.com/2009/01/08/deleting-a-range-of-tickets-in-trac/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 20:28:37 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Trac]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=219</guid>
		<description><![CDATA[Recently the Open Yahtzee website which runs Trac has fallen victim to several spam attacks. The spammers submit large number of tickets containing links to various sites. This post was written mainly to allow me to copy paste a command to delete a range of tickets at once, but I thought it may be useful [...]]]></description>
			<content:encoded><![CDATA[<p>Recently the <a href="http://www.openyahtzee.org">Open Yahtzee</a> website which runs <a href="http://trac.edgewall.org/">Trac</a> has fallen victim to several spam attacks. The spammers submit large number of tickets containing links to various sites. This post was written mainly to allow me to copy paste a command to delete a range of tickets at once, but I thought it may be useful to others as well.<br />
<span id="more-219"></span></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">for i in `seq FROM TO`; do trac-admin TRAC_ENV ticket remove $i ; done</pre></div></div>

<p>Replace FROM and TO with the first and last ticket numbers of the range accordingly. TRAC_ENV should be the path to your project&#8217;s environment.</p>
<p>For example:<br />
<!--more--></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">for i in `seq 9 32`; do trac-admin www.openyahtzee.org/ ticket remove $i ; done</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/01/08/deleting-a-range-of-tickets-in-trac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Start Trac on Startup &#8211; Init.d Script for tracd</title>
		<link>http://www.guyrutenberg.com/2008/06/04/start-trac-on-startup-initd-script-for-tracd/</link>
		<comments>http://www.guyrutenberg.com/2008/06/04/start-trac-on-startup-initd-script-for-tracd/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 07:12:30 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Trac]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=59</guid>
		<description><![CDATA[As part of a server move, I went on to reinstall Trac. I&#8217;ve tried to install it as FastCGI but I failed to configure the clean URLs properly. I got the clean URLs to work if the user access them, but Trac insisted on addeing trac.fcgi to the beginning of every link it generated. So [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a server move, I went on to reinstall Trac. I&#8217;ve tried to install it as FastCGI but I failed to configure the clean URLs properly. I got the clean URLs to work if the user access them, but Trac insisted on addeing <code>trac.fcgi</code> to the beginning of every link it generated. So I&#8217;ve decided to use the Trac standalone server, <code>tracd</code>.</p>
<p>The next problem I faced was how to start the Trac automatically upon startup. The solution was to use an <code>init.d</code> script for stating Trac. After some searching, I didn&#8217;t find an <code>init.d</code> script for <code>tracd</code> that were satisfactory (mostly poorly written). So I went on an wrote my own <code>init.d</code> script for <code>tracd</code>.<br />
<span id="more-59"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:          tracd</span>
<span style="color: #666666; font-style: italic;"># Required-Start:    networking</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:     networking</span>
<span style="color: #666666; font-style: italic;"># Default-Start:     2 3 4 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:      0 1 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: Start the tracd standalone Trac web server.</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
<span style="color: #666666; font-style: italic;"># (C) 2008 Guy Rutenberg &lt;http://www.guyrutenberg.com&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Options you should probably change ##</span>
<span style="color: #007800;">HOSTNAME</span>=127.0.0.1 <span style="color: #666666; font-style: italic;"># to which hostname should we listen</span>
<span style="color: #666666; font-style: italic;"># If you only want to serve one project keep this variable</span>
<span style="color: #666666; font-style: italic;"># empty and set the PROJECT_ENV variable </span>
<span style="color: #007800;">ENV_PARENT_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>guyru<span style="color: #000000; font-weight: bold;">/</span>trac.guyrutenberg.com
<span style="color: #007800;">PROJECT_ENV</span>=
<span style="color: #007800;">PORT</span>=<span style="color: #000000;">9090</span>
<span style="color: #666666; font-style: italic;"># add any additional options (such as authentication) here. If you only have one</span>
<span style="color: #666666; font-style: italic;"># project you should probably add -s here</span>
<span style="color: #007800;">ADDITIONAL_OPTS</span>=
&nbsp;
<span style="color: #666666; font-style: italic;">## Options you should probably not change ##</span>
<span style="color: #007800;">DAEMON</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>tracd
<span style="color: #007800;">NAME</span>=tracd
<span style="color: #007800;">DESC</span>=<span style="color: #ff0000;">&quot;web server&quot;</span>
<span style="color: #007800;">PIDFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid
<span style="color: #007800;">SCRIPTNAME</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>
<span style="color: #007800;">SSD</span>=<span style="color: #ff0000;">&quot;/sbin/start-stop-daemon&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&nbsp;
. <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>lsb<span style="color: #000000; font-weight: bold;">/</span>init-functions
&nbsp;
<span style="color: #007800;">DAEMON_OPTS</span>=<span style="color: #ff0000;">&quot;--daemonize --pidfile=<span style="color: #007800;">$PIDFILE</span> --port=<span style="color: #007800;">$PORT</span> --hostname=<span style="color: #007800;">$HOSTNAME</span> <span style="color: #007800;">$ADDITIONAL_OPTS</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ENV_PARENT_DIR</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">DAEMON_OPTS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DAEMON_OPTS</span> --env-parent-dir=<span style="color: #007800;">$ENV_PARENT_DIR</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">DAEMON_OPTS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DAEMON_OPTS</span> <span style="color: #007800;">$PROJECT_ENV</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	log_daemon_msg <span style="color: #ff0000;">&quot;Starting <span style="color: #007800;">$DESC</span>&quot;</span> <span style="color: #007800;">$NAME</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$SSD</span> <span style="color: #660033;">--start</span> --quiet\
	<span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_OPTS</span> ; <span style="color: #000000; font-weight: bold;">then</span>
            log_end_msg <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
            log_end_msg <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	log_daemon_msg <span style="color: #ff0000;">&quot;Stopping <span style="color: #007800;">$DESC</span>&quot;</span> <span style="color: #007800;">$NAME</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">$SSD</span> <span style="color: #660033;">--stop</span> <span style="color: #660033;">--retry</span> <span style="color: #000000;">30</span>\
	<span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$PIDFILE</span>
	    log_end_msg <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">else</span>
	    log_end_msg <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #000000; font-weight: bold;">|</span>force-reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	$<span style="color: #000000;">0</span> stop
	<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span>  <span style="color: #007800;">$PIDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">pidof</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$NAME</span> <span style="color: #000000; font-weight: bold;">|</span>\
		 <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>; <span style="color: #000000; font-weight: bold;">done</span>
	$<span style="color: #000000;">0</span> start
	<span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$SCRIPTNAME</span> {start|stop|restart|force-reload}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>The script begins with a configuration section. You should go over each variable and make sure its value suits you need. The first part is configuration variables you are more likely to change. It includes:</p>
<ul>
<li><code>HOSTNAME</code> &#8211; This tells <code>tracd</code> on what hostname to listen. From my experience setting it to anything other than 127.0.0.1 or localhost will cause it to operate on all available hostnames. If you use <code>tracd</code> in conjunction with <ocde>mod_proxy</code> (this is usually the case if you have Lighttpd) you would want to leave the hostname on 127.0.0.1 so the <code>tracd</code> server won't be accessed directly.</li>
<li><code>ENV_PARENT_DIR</code> - If you have multiple projects (all under then same directory) set this to the parent directory. If you only want to serve one project you should leave this empty and set the next variable.</li>
<li><code>PROJECT_ENV</code> - Set this to the project environment directory of you project if you serve only one. This variable is ignored if <code>ENV_PARENT_DIR</code> is set to anything but empty.</li>
<li><code>PORT</code> - This simply tells <code>tracd</code> on what port to listen.</li>
<li><code>ADDITIONAL_OPTS</code> - This variable allows you to pass additional parameters to the <code>tracd</code>. It's the place to add you authentication flags. If you have only a single project and would like to omit the project name in the url (e.g. something like http://trac.example.com) add the <code>-s</code> flag to this variable.</li>
</ul>
<p>The other part of the configuration allows you to easily adjust the script to your machine. It has variables for specifying the path to the <code>tracd</code> executable and the paths of other things required of the correct operation of the script. In most cases you wouldn't have to change this part.</p>
<p>Now copy the script to <code>/etc/init.d/trac</code> and adjust the configuration to your needs. To enable the script on startup you should use your distro specific tools for managing the <code>rc</code> scripts. On fedora that means you will have to do <code>chkconfig trac on</code>. On Ubuntu you should do <code>update-rc.d trac defaults</code>.</p>
<p>I hope you will find the script useful. If you have any comments or suggestions regarding the script please comment.</p>
<p>UPDATE (13/10/2008):<br />
Here is an version of the script for <a href="/wp-content/uploads/2008/10/trac.gz">download</a>.<br />
UPDATE (17/2/2009):<br />
See <a href="/2009/02/17/starting-tracd-without-root-privileges-at-startup/">Starting tracd without Root Privileges at Startup</a> for a different way to start <code>tracd</code> that doesn't require root privileges.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/06/04/start-trac-on-startup-initd-script-for-tracd/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.557 seconds -->
