Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, 30 March 2013

Tiny Tiny RSS init.d Script

Shamelessly taken from
http://tt-rss.org/forum/viewtopic.php?f=16&t=1135&start=15#p14282

I've finally switched to an upstart script for booting tt-rss with some minor modifications to create a lock folder before starting the service.

description "TT-RSS Feed Updater"
author "The Epyon Avenger <epyon_avenger on TT-RSS forums>"

start on started mysql
stop on stopping mysql

respawn

pre-start script

        if [ ! -d "/var/lock/tt-rss/" ]; then
                # be sure there is a /var/lock/tt-rss, even with tmpfs
                mkdir --mode 750 --parents /var/lock/tt-rss/
                chown www-data:www-data /var/lock/tt-rss/
        fi

end script


setuid www-data
setgid www-data

chdir /opt/tt-rss


exec php ./update_daemon2.php

Sunday, 5 February 2012

rTorrent & Screen Upstart 1.3 (Updated)

Upstart script for rTorrent for Upstart 1.3 (and older?)
Upstart 1.4 supports setting uid and gid so we can use that instead of start-stop-daemon or sudo or su to correctly track the process id using expect daemon and tell it to send the proper kill signal (for rTorrent is SIGINT)

So what do we do for Upstart 1.3?
Well, we're forced to use either start-stop-daemon or sudo or su to start a process as another user. Even with expect daemon it always tracks the wrong process id and in my case causes shutdown to freeze as it tries to kill a process that doesn't exist.

My solution is to start a job that cleanly kills (by sending a SIGINT) rTorrent when you'd expect it to. In my case runlevels [016]

#rtorrent-start.conf

description     "rTorrent - ncurses BitTorrent client based on LibTorrent"

start on (local-filesystems and net-device-up IFACE=eth0 and runlevel [2345])
stop on runlevel [016]

console none

exec start-stop-daemon --start -c <user> --exec /usr/bin/screen -- -dmUS rtorrent /usr/bin/rtorrent
##

#rtorrent-stop.conf

description "Correctly ensure rTorrent shuts down gracefully"

start on runlevel [016]

console none
task

script
 if [ -f /home/ <user> /.rtorrent/rtorrent.lock ]; then
   kill -s 2 $(cat /home/ <user> /.rtorrent/rtorrent.lock | awk -F+ '{ print $2 }')
   rm -f /home/ <user> /.rtorrent/rpc.socket
 fi
end script
##

.lock file cleaning should be left for rTorrent as it usually removes it when correctly killed. If an old .lock file remains its a clear indicator that rTorrent did not correctly shutdown.
Won't hurt to remove the socket file though (if you use it). Saves adding it in .rtorrent.rc

UPDATE:
I've recently had some issues with UDP trackers and DHT causing some torrents to not start downloading at all even when the swarm is healthy. I've since given up on rTorrent and have started using Deluge, which is nice and compact with a sweet web gui.

Wednesday, 28 December 2011

XBMC with External FFMPEG

I used to do this awhile ago on my HTPC. Its pretty slow building XBMC on an Atom CPU. I gave up building my own builds because I ended up running in to problems (segfaults etc). When I installed 10.04 I decided I didn't want to install various build dependencies and libraries on my HTPC
Now I want Hi10P support on XBMC. An XBMC build compiled to use external FFmpeg libraries is the only way to achieve that until XBMC developers update the internal libraries (due after Eden apparently)
I now build XBMC and FFmpeg in a VM using VMware Player (which features (since version 3.0) the ability to create new virtual machines YAY!). Configure switches have been customised for myself. YMMV.

XBMC Dependencies
sudo apt-get install git-core make g++ gcc gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound2-dev python-sqlite libglew-dev libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmpeg3-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs python-dev libyajl-dev libboost-thread-dev libplist-dev libudev-dev


Necessary for VAAPI
sudo apt-get install libva-dev


FFMpeg Dependencies
sudo apt-get install build-essential checkinstall git libx11-dev libxfixes-dev zlib1g-dev


Building FFMpeg
git clone --depth 1 -b release/0.9 git://source.ffmpeg.org/ffmpeg

./configure --disable-static --disable-debug --cpu=sse3 --target-os=linux --disable-muxers --enable-muxer=spdif --enable-muxer=adts --disable-encoders --enable-encoder=ac3 --enable-encoder=aac --disable-decoder=mpeg_xvmc --disable-devices --disable-ffprobe --disable-ffplay --disable-ffserver --disable-ffmpeg --enable-shared --disable-doc --enable-postproc --enable-gpl --enable-nonfree --enable-version3 --disable-vdpau --enable-pthreads --enable-pic --enable-hardcoded-tables --disable-demuxer=oss --disable-demuxer=jack --disable-muxer=oss --disable-demuxer=v4l --disable-demuxer=v4l2 --disable-altivec --disable-neon --disable-amd3dnow --disable-amd3dnowext --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-armvfp --disable-iwmmxt --disable-mmi --disable-vis --disable-dxva2 --enable-sram --disable-bsfs --enable-vaapi --disable-vda --disable-w32threads --disable-os2threads --disable-safe-bitstream-reader

make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(./version.sh)" --backup=no --deldoc=yes --default
sudo ldconfig


Building XBMC
git clone git://github.com/xbmc/xbmc.git

sudo apt-get install libbluray rtmpdump

./configure --disable-debug --enable-vaapi --disable-crystalhd --disable-vdadecoder --disable-vtbdecoder --disable-openmax --disable-joystick --disable-rsxs --disable-projectm --disable-ccache --disable-pulse --enable-rtmp --disable-samba --disable-nfs --disable-afpclient --disable-airplay --disable-airtunes --disable-hal --disable-avahi --disable-webserver --enable-libbluray --disable-libusb --disable-libcec --disable-vdpau --enable-external-ffmpeg

make
sudo checkinstall --pkgname=xbmc --pkgversion="`date +%Y%m%d%H%M`-git" --backup=no --deldoc=yes --default

Updated:
Move to VAAPI and updated FFmpeg Git URL for 0.9 branch. Ubuntu 10.11