02 January 2013

302. Surfraw on debian (and goosh)

I like shells, so I was pretty chuffed to discover this: http://goosh.org
This is basically a google shell simulator running in a gui browser -- not a true shell in any respect, so while it's really neat, but not terribly useful in itself. See below for how to get it set up.

It got me looking for true command line alternatives though, such as surfraw. While it was originally started by Julian Assange in 2000 it has been maintained by others during the past ten years.

Regardless, surfraw really does bring the power of the command line and the web together in a useful way.

To get set up with surfraw, do
sudo apt-get install surfraw
sr wikipedia surfraw

which opens a new window in your default browser -- e.g. chromium if that's what you have. This means that while you shoot of your command in the terminal, you'll then have to switch to your desktop environment. To force surfraw to use a more sensible alternative, e.g. w3m, install w3m and then create ~/.surfraw.conf and put
SURFRAW_text_browser=w3m SURFRAW_text_browser_args=-dump SURFRAW_graphical=no
in it. The -dump allows you to grep through the output but makes the whole experience less interactive -- remove that line to make things open properly in w3m instead.

w3m takes a bit of getting used to, so a cheat sheet might help: http://wiki.titan2x.com/index.php?title=W3m_cheat_sheet

A lot of it makes sense if you're used to vim though.

The next step is to explore what modules (elvi) are available e.g.
sr -elvi
acronym -- Look for acronyms definitions (www.acronymfinder.com) ask -- Question the web using Ask Jeeves (www.ask.com) bbcnews -- Search BBC News (news.bbc.co.uk) bing -- Search the web using Microsoft's Bing (www.bing.com) currency -- Convert currencies with the Universal Currency Converter (www.xe.net/ucc) debbugs -- Search the debian BTS (bugs.debian.org) duckduckgo -- Securely search the web using duckduckgo (www.duckduckgo.com) google -- Search the web using Google (www.google.com) pgpkeys -- Search the PGP key database scholar -- Search Google Scholar (scholar.google.com) wikipedia -- Search the free encyclopedia wikipedia youtube -- Search YouTube (www.youtube.com)

Hours of fun to be had:
sr wikipedia surfraw|less
sr google -results=100 -q "nwchem cosmo"|grep verahill

etc. It's probably not going to change your life, but time will tell whether there's an advantage of using surfraw over just (e)links or w3m.


Goosh
There's an unofficial script which will help you install it. If you haven't got $EDITOR set, you can do export EDITOR=/usr/bin/vim or export EDITOR=/usr/bin/nano first. For some reason the value set using update-alternatives --config editor doesn't translate into $EDITOR. The editor is needed to edit the config file during installation.
cd ~/tmp
wget "https://raw.github.com/tolecnal/goosh-installer/master/goosh.sh"
chmod +x goosh.sh
./goosh.sh
sudo mkdir /var/www/goosh
sudo cp $HOME/goosh/index.php /var/www/goosh

and open http://localhost/goosh in your browser. This offers  basically no advantage over just navigating to http://goosh.org

23 December 2012

301. Building Mosquitto 1.0.5 on debian stable

Here's what I did in a chrooted Stable while writing up a reply for this post: http://forums.debian.net/viewtopic.php?f=10&t=90444

I've changed the commands a little bit from http://mosquitto.org/2012/11/making-mosquitto-packages-for-debian-yourself/ to be more faithful to my own style. Edit your /etc/apt/sources.list so that it has both stable and testing e.g.

deb http://ftp.au.debian.org/debian stable main
deb http://ftp.au.debian.org/debian testing main

and edit /etc/apt/preferences
Package: *
Pin: release a=stable
Pin-Priority: 990

Package: *
Pin: release a=testing
Pin-Priority: 800

Followed by

sudo apt-get update
sudo apt-get install build-essential python quilt libwrap0-dev libssl-dev devscripts python-setuptools
sudo apt-get install libssl-dev=1.0.1c-4 python3


Then

mkdir ~/tmp
cd ~/tmp
wget http://mosquitto.org/files/source/mosquitto-1.0.5.tar.gz -O mosquitto_1.0.5.orig.tar.gz
tar xvf mosquitto-1.0.5.orig.tar.gz
cd mosquitto-1.0.5/
wget http://mentors.debian.net/debian/pool/main/m/mosquitto/mosquitto_1.0.5-1.debian.tar.gz
tar xvf mosquitto_1.0.5-1.debian.tar.gz
debuild -us -uc
sudo dpgk -i ../*mosquitto*.deb


and you'll find the .debs in the parent folder.


Links to this page:
http://jtlog.wordpress.com/2013/01/04/raspberry-pi-mosquitto/

300. Briefly: Sharing a folder using SAMBA on Debian

I don't ever use samba, but it's not a bad thing to know how to set up in case you need to share files with someone using Windows in a pinch.

First install samba:
sudo apt-get install samba samba-common smbclient

To get a share up with samba, create an /etc/samba/smb.conf and stick the following in it:


[global]
workgroup=WORKGROUP
guest account=nobody
security=shared


[asharedfolder]
path=/home/lindqvist/shared
guest ok=yes
read only=no
writable=yes
browsable=yes
comment= SMB share

Restart samba:
sudo service samba restart

1. This is an insecure share i.e. <b>anyone can access it</> and edit everything.
2.. Also, by omitting "netbios name=  " you can use the IP address of the server as the hostname, but you could also specify e.g. "netbios name=niobium" and use that as the hostname in nautilus when you connect to the host server.

To set up a user- and password-based share, do



[global]
workgroup=WORKGROUP
security=user


[asharedfolder]
path=/home/lindqvist/shared
guest ok=no
read only=no
writable=yes
browsable=yes
comment= SMB share

You need to add and set the samba password, and enable the linux user you want to give access as well:
sudo smbpasswd -L -a -e lindqvist


There are a lot of other options that can be set. Two of the more interesting ones are probably

[asharedfolder]
createmask=0755
valid users=me myself irene

which means that any new files created in that share via samba gets chmod 755, and only the users me, myself and irene can connect.

But often a basic smb.conf is easier to manage and will do what you want it to.