CouchPotato on FreeBSD

For CouchPotato in FreeBSD, firstly acquaint yourself with my previous blog entry on Sabnzbd+Sickbeard on FreeBSD, and then perform the following additional steps:

At Step 3, fetch CouchPotato’s source code:

# cd /usr/local && git clone git://github.com/RuudBurger/CouchPotato.git couchpotato

Also, it is advisable to change the permission and ownership of the CouchPotato folder:

# chown root:_sabnzbd /usr/local/couchpotato

# chmod g+w /usr/local/couchpotato

At Step 4, add the following to /etc/rc.conf:

1
2
couchpotato_enable="YES"

.. and create /usr/local/etc/rc.d/couchpotato containing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
# PROVIDE: couchpotato
# REQUIRE: DAEMON sabnzbd
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# couchpotato_enable (bool): Set to NO by default.
# Set it to YES to enable it.
# couchpotato_user: The user account Couch Potato daemon runs as what
# you want it to be. It uses '_sabnzbd' user by
# default. Do not sets it as empty or it will run
# as root.
# couchpotato_dir: Directory where Couch Potato lives.
# Default: /usr/local/couchpotato
# couchpotato_chdir: Change to this directory before running Couch Potato.
# Default is same as couchpotato_dir.
# couchpotato_pid: The name of the pidfile to create.
# Default is couchpotato.pid in couchpotato_dir.
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
. /etc/rc.subr
name="couchpotato"
rcvar=${name}_enable
load_rc_config ${name}
: ${couchpotato_enable:="NO"}
: ${couchpotato_user:="_sabnzbd"}
: ${couchpotato_dir:="/usr/local/couchpotato"}
: ${couchpotato_chdir:="${couchpotato_dir}"}
: ${couchpotato_pid:="${couchpotato_dir}/couchpotato.pid"}
WGET="/usr/local/bin/wget" # You need wget for this script to safely shutdown Couch Potato.
HOST="127.0.0.1" # Set Couch Potato address here.
PORT="5000" # Set Couch Potato port here.
SBUSR="" # Set Couch Potato username (if you use one) here.
SBPWD="" # Set Couch Potato password (if you use one) here.
status_cmd="${name}_status"
stop_cmd="${name}_stop"
command="/usr/sbin/daemon"
command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags} --quiet"
# Check for wget and refuse to start without it.
if [ ! -x "${WGET}" ]; then
warn "Couchpotato not started: You need wget to safely shut down Couch Potato."
exit 1
fi
# Ensure user is root when running this script.
if [ `id -u` != "0" ]; then
echo "Oops, you should be root before running this!"
exit 1
fi
verify_couchpotato_pid() {
# Make sure the pid corresponds to the Couch Potato process.
pid=`cat ${couchpotato_pid} 2>/dev/null`
ps -p ${pid} | grep -q "python ${couchpotato_dir}/CouchPotato.py"
return $?
}
# Try to stop Couch Potato cleanly by calling shutdown over http.
couchpotato_stop() {
echo "Stopping $name"
verify_couchpotato_pid
${WGET} -O - -q --user=${SBUSR} --password=${SBPWD} "http://${HOST}:${PORT}/home/shutdown/?pid=${pid}" >/dev/null
if [ -n "${pid}" ]; then
wait_for_pids ${pid}
echo "Stopped"
fi
}
couchpotato_status() {
verify_couchpotato_pid && echo "$name is running as ${pid}" || echo "$name is not running"
}
run_rc_command "$1"

NTFS-Write in FreeBSD

NTFS-write in FreeBSD is possible with NTFS-3G from ports. From tuxera.com:

NTFS-3G is a stable, full-featured, read-write NTFS driver for Linux, Android, Mac OS X, FreeBSD, NetBSD, OpenSolaris, QNX, Haiku, and other operating systems. It provides safe handling of the Windows XP, Windows Server 2003, Windows 2000, Windows Vista, Windows Server 2008 and Windows 7 NTFS file systems.

To install NTFS-3G, do:

# portmaster sysutils/fusefs-ntfs

Next, create a symbolic link from the newly-installed /usr/local/bin/ntfs-3g into /usr/sbin/:

# ln -s $(which ntfs-3g) /usr/sbin/mount_ntfs-3g

Modify your /etc/rc.conf to contain:

1
2
fusefs_enable="YES"

Provided you know on which hard-disk (based on make/model/capacity of the device) your NTFS partition resides, you can figure out it’s exact device node in FreeBSD:

# egrep 'ad[0-9]|cd[0-9]|da[0-9]' /var/run/dmesg.boot

ad0: 35303MB  at ata0-master
ad2: 57240MB  at ata1-master
ad4: 286168MB  at ata2-master

My NTFS partition resides on a 300GB WD Velociraptor drive, ad4. To confirm that /dev/ad4 does indeed contain the NTFS partition, do:

# gpart show -p ad4

=>        34  586072064    ad4 GPT  (286G)
          34  586072064  ad4p1 ntfs (286G)

To mount the partition manually, do:

# ntfs-3g /dev/ad4s1 /mnt/windows7

Finally, add the appropriate line to /etc/fstab to have the NTFS partition mounted at the next system boot. For instance, my /etc/fstab contains:

/dev/ad4s1              /mnt/windows7            ntfs-3g rw,late         0       0

Code and Gists in Wordpress

While WordPress.com doesn’t allow you to use potentially harmful code on your blog, it does allow you to post source code for general viewing. Provided that you enclose the source code within a [sourcecode] [/sourcecode] shortcode wrapper, you will be able to preserve the code’s formatting; enable syntax highlighting for the programming language used; and highlight specific lines in the code. For example, for a CSS snippet, do:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[sourcecode language="css" highlight="3,4,5,6,7"]
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
[/sourcecode]

Alternatively, wordpress.com permits embedding github.com gists by using the [gist] shortcode. With [gist]2927943[/gist], you’ll achieve:

… which certainly isn’t as pretty as wordpress.com‘s solution. You can make a gist more presentable by way of CSS customizations, but this isn’t possible on wordpress.com. It is also impossible to tell gists to highlight specific lines of code.

New Blog Host Adopted

As the future of ootput.bur.st remains bleak, I have been forced to seek alternative hosting locations. wordpress.com provides free hosting for blogs powered by WordPress, and I have chosen to use it as a temporary host while I wait for the outcome of bur.st‘s acquisition.

wordpress.com provides a decent service to the occasional blogger who has no intention of hosting their own site. I personally felt very much at home after successfully importing posts from the Habari-based ootput.bur.st. Of course, as wordpress.com wasn’t a self-hosted solution to the bur.st issue, I was limited to whatever functionality the blog was permitted to exhibit by the WordPress team. (read: no additional plugins allowed)

The transition from Habari to WordPress was not a straightforward process, however. In order to export all of Habari’s posts to a format recognised by wordpress.com, I had to host a WordPress blog on bur.st where I could create the appropriate MySQL tables for WordPress. wordpress.com does not provide direct MySQL access for its members, and this effectively prevents the Habari->Wordpress script from working.

Regardless, once I had exported data to the bur.st-hosted WordPress, I was then able to produce a WordPress->WordPress export file to be imported into wordpress.com

It was a tedious process, but it saved me a lot of time in transferring content onto the new blog.

In order to redirect users to my new wordpress.com blog, and to properly block search bots from accessing the domain (e.g. Google), I created the following two files in ootput.bur.st‘s root directory:
.htaccess:

1
2
3
4
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://ootput.github.io/$1 [R=301,L]

robots.txt:

1
2
3
User-agent: *
Disallow: /

Of course, these two files will be obliterated once the bur.st merger is officially complete.

NB: Interestingly, my final login to shell.bur.st showed new mail in my mailbox - where I had never received e-mail in the past. There was a total of 10 e-mails, and all of them were spam. I suppose it was someone’s last ditched effort to generate some income from bur.st members - which was kind of lame. As the account effectively expires on the 1st July, this desperate attempt seemed rather stupid.

Future of ootput.bur.st In Doubt

BUR.ST UPDATE

As you may recall from previous news emails, Bur.st Networking Inc. no longer receives sufficient donations to offer its services. Members of the committee have spent over $3000 of their own money since August 2011 to keep the service running, which is not sustainable. As a direct result of this, the West Australian Internet Association (WAIA) kindly offered to take over providing Bur.st’s services, and is already hosting our servers at no cost while we work to make this happen. WAIA was founded in 1995, operates the West Australian Internet Exchange and has full-time technical staff. Some existing Bur.st volunteers are also going to stick around and give WAIA a hand keeping things running.
After a transition period which will end on 30th June, WAIA will be requiring users to become members of WAIA in order to continue to use the Bur.st services. WAIA is committed to educating the public on the Internet and offers many services to the Internet community. Your membership means WAIA initiatives such as free member public meetings, conferences, arbitration, and increased member services can continue (such as the new offering of Bur.st-like services to members, but it needs your support if the services are to be viable!)

Individual people may obtain WAIA Professional membership, which costs $50 per year. For further details on how to sign up to WAIA please visit
https://www.waia.asn.au/membership

A big advantage of WAIA’s taking over is continuity - you won’t need to set up your website or email address anywhere else, @bur.st email addresses will continue to work, etc. If there is sufficient demand for Bur.st / WAIA hosting in the future, WAIA expects to overhaul the service a bit, particularly to make it easier to manage. However, we expect the functionality that most Bur.st users are using to remain intact. (One significant exception: we do not expect WAIA to continue to provide shell access.)

NOTICE OF SPECIAL GENERAL MEETING

A Special General Meeting of Bur.st Networking Inc. will be held on 5:30pm Wednesday 6 June 2012 at 43 Below Restaurant Lounge Bar, 43 Barrack St (cnr Hay St), Perth, WA

The following special resolution will be proposed: That Bur.st Networking Inc be voluntarily wound up as an incorporated association (under the Associations Incorporation Act 1987).

Voting is open to members of the voting membership class of Bur.st Networking Inc. Voting members who are unable to attend may nominate the secretary to cast a proxy vote on their behalf.

Emails have been sent to all registered voting members - if you believe you should have received one, and have not, please contact secretary@bur.st as soon as possible.

FINAL SIGN OFF

Further updates will be communicated from WAIA in the future. As always, we thank you for your support, albeit small or large, over the many years of Bur.st’s existence. And to all those people who have assisted in some way (you know who you are!) – our hats off to you for your dedication to a great not-for-profit organisation.

Bur.st Executive Committee & Staff
Stay tuned for more developments.