2014-12-07

Notes to Self: FreeNAS 9.3-Beta SMBD mDNS log spam

smbd[28586]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
smbd[28586]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
smbd[28586]: dnssd_clientstub ConnectToServer: connect() failed Socket:32 Err:-1 Errno:2 No such file or directory

Despite having mDNS turned off, smbd seems to want to talk to it. (Looking for avahi?).  Seems unchecking "zeroconf share discovery" (System -> Services -> CIFS) would fix -- doing so makes no modification to /usr/local/etc/smb4.conf (assuming it should - FreeNAS-9.3-BETA-201412062137).   

Adding "multicast dns register = no" to Auxiliary Parameters, however, seems to sort it. 

Or, one could do as is suggested by a wonderfully helpful FreeNAS developer, and just re-enable the service: even if you don't need it, cause, why not? (symlinking /usr/local/libexec/nas/register_mdns.py to /bin/true does nothing to fix this, of course...)

Bug #4562 - Logs full off "dnssd_clientstub ConnectToServer" errors

2014-07-28

Ugly Windows Batch Kludge - ffmpeg / tr /

Dealing with certain Youtube files (ie, from Rhino Entertainment) requires trimming off the 15 or so 'also recommended' seconds at the end of every video.   The number of seconds and starting position varies, so it'd be tricky to script (perhaps with -af silencedetect), so I'm doing it manually.  And on Windows, for some reason. (Obviously, this is all trivial on 'nix, without requiring any kludges.)

I have the unixtools for Windows installed; the version of tr and sed in it reads pipes or redirects at the end as additional input; Windows inserts "" around filenames by default with tab completion. tr -d "\"" (and the sed equivalent of s/\"//g) both barf removing it... (and, there doesn't seem to be a way of directly setting the output of a command to a variable with batch files...) This is ugly, inelegant, and mostly an exercise in unnecessary complexity, because after an hour, it was personal.  With a little more effort, this could be even more spectacularly nasty.

trkludge.bat:
@echo %1 | tr -d "\""

ytstrip.bat:
@echo off
call trkludge %1 >> temp.tmp
set /p output=<temp.tmp
del /q temp.tmp
ffmpeg -hide_banner -t %2 -i %1 -c copy -map_metadata 0 output\%output%
mv %1 pending_delete\

Usage example:

\tmp\in\mvid\inc>ytstrip "RhinoEntertainment-All_Saints-Black_Coffee_Official_Music_Video[v0Xej6Sz5nU].mp4" 4:14

To be more absurd, an improvement would be to use 'for' to loop through all the desired files, prompting just for the time on each one... or, prompting for both pre and post cut (to handle kontor.tv and Spinnin' Record files as well.)



2014-04-20

Uniform Server Zero + mod_wsgi + Falcon Framework on Windows 7

Setting up a local test environment before deployment on shared hosting (Dreamhost / Phusion Passenger) (assumes python already properly installed):
  • Install UniServerZ: Uniform Server - A lightweight mobile WAMP Server Solution.
  • Download1mod_wsgi library, extract,  and copy .so to UniserverZ\core\apache2\modules
  • Install Falcon: python -m pip install falcon
  • Edit httpd.conf:
  • add:
       LoadModule wsgi_module modules/mod_wsgi.so
       WSGIScriptAlias /app "${US_ROOTF_WWW}/passenger_wsgi.py"
  • Edit passenger_wsgi.py:
  • import falcon
    class Test:
       def on_get(self, req, resp):
          resp.status = falcon.HTTP_200
          resp.body = ('<h1>Test.</h1>')
    app = application = falcon.API('text/html')
    app.add_route('/', Test())
    
  • Hit local server(assumes default port): http://127.0.0.1/app/
1 Choosing the right library: match the version of python installed with downloads. Failure to do so results in the following errors:
\UniServerZ>httpd_z -t
httpd_z: Syntax error on line 187 of x:/xxx/UniServerZ/core/apache2/conf/httpd.conf: Cannot load modules/mod_wsgi.so into server: The specified module could not be found.
Occurs if the mod_wsgi.so version is different from python version installed. (What, the error should actually help you know that? ...)

\UniServerZ>httpd_z -t
httpd_z: Syntax error on line 187 of x:/xxx/UniServerZ/core/apache2/conf/httpd.conf: Cannot load modules/mod_wsgi.so into server: %1 is not a valid Win32 application.
Occurs if the .so is 64bit and installed UniServer is 32bit.

2014-04-01

Boar on Freenas


mount -uw /


cd /mnt/dataset

Method one (get valid token from 'Download')1:

wget "http://boar.googlecode.com/issues/attachment?aid=920000000&name=install_boar.sh&token=XXXXXXXX" -O install_boar.sh

Method two:

cat >> install_boar.sh
#!/usr/local/bin/bash
#
# Install boar on FreeBSD
# Writen by: Kellen Fox
#
if [ "$(whoami)" != "root" ]; then
echo "You need to be root for this."
exit 1
fi

### These variables can be changed for other systems ###
#Where to install the files. Since this is a python package site-packages works nicely
INSTALL_DIR=/usr/local/lib/python2.7/site-packages/
# Where to put the boar script
BIN_DIR=/usr/local/bin/
# Package url
BOAR_URL=http://boar.googlecode.com/files/boar.29-Jul-2012.tar.gz

cd $INSTALL_DIR
curl $BOAR_URL | gunzip | tar -xpf -
cd boar
echo "Editing setup.py"
# comment out the second line "import py2exe"
sed -i .tmp '2 s/[^ ]*/#&/' setup.py && rm setup.py.tmp
/usr/local/bin/python setup.py build
/usr/local/bin/python setup.py install

ln -s ${INSTALL_DIR}boar/boar ${BIN_DIR}boar

^D

vi install_boar.sh
  • Change BOAR_URL to current 2
chmod +x install_boar.sh
./install_boar.sh
mount -ur /


References:
1 - Issue 92: setup.py fails on FreeBSD
2 - Boar: Simple version control and backup for photos, videos and other binary files

2014-01-10

Using pre-formated text in a MediaWiki Template.

I needed to use <pre> tags in a MediaWiki template, which turned out to be non-trivial.  Using <code> and <poem> both fail to wrap single lines, as did the custom <div> styling.  It was easier to figure it out than add a bunch of <br>s to the source text.  For those looking for an ugly kludge, here you go. Enjoy.  (Non-salient bits removed: I do wrap the categories in <noinclude></noinclude>)

Template:P

pre style="margin-left:2em;font-weight: bold">

Template:PG

<{{p}}
{{{1|No Text Provided}}
</pre>

Usage:
{{PG|Some Text To Display Preformatted}}

Further Reading: