Archive

Archive for the ‘debian’ Category

Record and share shell activity via shelr.tv

April 22, 2012 Leave a comment

Terminal

Shelr.tv allows Unix/Linux command line users to record something interesting from their terminal and share it to followers.

It is a bit like YouTube for plain text shellcasts. A great feature is that you can copy and paste everything you see.

A nice intro with interesting comments from one of the core developers can be found on linuxaria.com.

A Debian package has been proposed through the Debian “package mentor” system.

Categories: bash, debian, mac os, opensuse

Move JPGs from camera to year/month folder using bash, exif and gphotofs

April 12, 2012 Leave a comment

Prerequisites:

  • Install the gphotofs and exif packages.
  • Make sure you have the folders $HOME/devices/camera (camera mount point) and $HOME/media/photos (base folder for photo folders) or edit the script below to use different locations.
  • Verify that your camera mounts fine using gphotofs and that it internally stores JPGs in a subfolder of “DCIM”.

Save this script as /usr/local/bin/copy-cam-jpgs.sh:

#! /bin/sh

mountpoint=$HOME/devices/camera
targetfolder=$HOME/media/photos

# check availability of cmdline tools
type gphotofs exif fusermount || exit

# mount camera if necessary
if ! mount|grep "$mountpoint"; then 
  gphotofs "$mountpoint"
fi

cd $mountpoint/*/DCIM/*

for jpg in *.JPG; do
  year_month=$(exif --tag=0x9003 -m $jpg \
         | cut -f1,2 -d: \
         | tr ':' '/')
  folder="$targetfolder/$year_month"
  mkdir -p "$folder"
  mv -v "$jpg" "$folder"
done

cd
fusermount -u $mountpoint

Make it executable like this:

chmod ugo+x /usr/local/bin/copy-cam-jpgs.sh

Then plug in your digital photo camera and run “copy-cam-jpgs.sh“. It will move all JPGs from the camera to $target_folder/yyyy/mm where yyyy is the 4 digit year and mm is the two digit month of the date the photo was taken (as per EXIF data in the JPG).

Categories: bash, coding, debian, opensuse

Backup/restore XFCE desktop icons

March 8, 2012 Leave a comment

Sometimes the XFCE desktop icons get messed up, for example by games that temporarily change the screen resolution to 800×600.

A solution to this problem has been mentioned here. It suggests using “sudo chattr +i” to lock the config file where XFCE stores the icon positions.

Alternatively (and without the repeated need for sudo and chattr) you can also backup and restore the ~/.config/xfce4/desktop/icons* file(s) like this:

Create a script /usr/local/bin/save-xfce-desktop-icons.sh like this:

#! /bin/sh
mkdir -p ~/.config/xfce4/desktop.bak
cp -f ~/.config/xfce4/desktop/icons* ~/.config/xfce4/desktop.bak

Create another script /usr/local/bin/load-xfce-desktop-icons.sh like this:

#! /bin/sh
cp -f ~/.config/xfce4/desktop.bak/icons* ~/.config/xfce4/desktop

Make the scripts executable like this

sudo chmod ugo+x /usr/local/bin/save-xfce-desktop-icons.sh
sudo chmod ugo+x /usr/local/bin/load-xfce-desktop-icons.sh

Then in the XFCE start menu, go to “Settings” – “Keyboard” – “Application Shortcuts” and configure 2 keyboard shortcuts:

Command Shortcut
save-xfce-desktop-icons.sh <Control><ALT>S
load-xfce-desktop-icons.sh <Control><ALT>L

Then you will be able to backup and restore your icons like this:

  • Backup: Press F5 then <Control><ALT>S then F5
  • Restore: Press F5 then <Control><ALT>L then F5

The F5 is necessary to synchronize what you see on the screen with the content of ~/.config/xfce4/desktop/icons*.

Categories: bash, coding, debian, foss, opensuse

Jenkins on minimalistic Debian Virtualbox VM (64bit)

November 23, 2011 Leave a comment

A Jenkins build server (LTS release) can now be easily installed on the minimalistic Debian VM:

  1. Download and install Virtualbox
  2. Download debian-stable-amd64-minimal.ova and import it into Virtualbox
  3. Start the “debian-stable-amd64-minimal” VM in Virtualbox
  4. If you are outside Nova Scotia, please review debian-stable-amd64-minimal.txt and adjust locale, timezone and Debian mirror based on your location
  5. Start an ssh session to localhost, port 1111 (using PuTTY, for example)
  6. Log in as user (default password is “user”)
  7. Issue “sudo install.sh jenkins” (default root password is “root”)
  8. Press enter for any questions during installation
  9. Open http://localhost:8888/ in a browser on the host OS for Jenkins web ui

You can go to “Manage Jenkins” – “Configure System” and see that JDK, Ant and Maven entries are already configured for you.

Important: Make sure to change root and user passwords to something secure, as mentioned in debian-stable-amd64-minimal.txt.

Categories: debian, java, virtualization

Convert Virtualbox VDI for VMware Player

November 15, 2011 Leave a comment

Regarding the VM that I mentioned in my previous post – this way I also got it to work in VMware Player:

  • Install and start Virtualbox (https://www.virtualbox.org/wiki/Downloads)
  • Go to File – Import Appliance (and import the ova file mentioned in my last post)
  • Close Virtualbox
  • Use VBoxManage on the command line to clone the VDI to VMDK, roughly as described here (but do not try to uninstall guest additions):  http://scottlinux.com/2011/06/24/convert-vdi-to-vmdk-virtualbox-to-vmware/
  • Create a new empty Linux/Debian VM in VMware Player
  • Close VMware Player
  • Edit the new vmx file so that it points to the cloned vmdk
  • Then open the VM in VMware player again. Now it should boot into Debian.
Categories: debian, virtualization

Minimalistic Debian VM (64bit)

November 10, 2011 Leave a comment

I uploaded a VM image to doepner.net: It is a minimalistic Debian VM that can be used as a base for lean servers. It is in OVA format, exported from Virtualbox 4.1.6. Details are in the corresponding txt file.

You can add the VM to your Virtualbox using “File” – “Import Appliance …”. VMware should also work but might require some compatibility conversion of the ova file.

Recipes for specific Nexus, Jenkins, Wiki, Bugzilla setups will follow … I will publish those as scripts/instructions relative to the minimal base image, rather than maintaining several VMs.

Categories: debian, foss, virtualization

bash script to recursively sanitize folder and file names

October 13, 2011 Leave a comment

bash script to recursively sanitize folder and file names:

#! /bin/bash

shopt -s extglob; 
 
find $1 -depth -print | while read path
do
  filename=$(basename "$path")
  directory=$(dirname "$path")

  filename_clean="${filename//+([^[:alnum:]_-\.])/_}"

  if (test "$filename" != "$filename_clean")
  then
    mv -v "$directory/$filename" "$directory/$filename_clean"
  fi
done

Categories: bash, debian, opensuse

My /etc/apt/sources.list (for Debian squeeze)

October 11, 2011 Leave a comment

My sources.list entries:

# local repo (manually downloaded debs, etc.):
deb file:/usr/local/packages ./

# The closest Debian mirror is at Dalhousie University, Halifax:
deb http://mirror.its.dal.ca/debian/ squeeze main contrib non-free
deb http://mirror.its.dal.ca/debian/ squeeze-updates main
deb http://mirror.its.dal.ca/debian/ squeeze-proposed-updates main
# See http://www.debian.org/mirror/list for mirrors closer to you

# Security updates (not mirrored)
deb http://security.debian.org/ squeeze/updates main

# Official backports repo for squeeze (I install the Linux kernel from it)
deb http://backports.debian.org/debian-backports squeeze-backports main

# Debian multimedia, a must-have for mplayer et al.
deb http://mirror.its.dal.ca/debian-multimedia squeeze main non-free

# Repo that provides latest Iceweasel (aka Firefox)
deb http://mozilla.debian.net/ squeeze-backports iceweasel-release

Categories: debian, firefox

Simple webradio playback

October 8, 2011 Leave a comment

I listen to web radio stations but I don’t want to use any player ui for that. All I want is:

  1. Select a station from a list of my favorites and listen to it
  2. Be able to stop current web-radio playback
  3. Never have more than one station playing at the same time

I do it like this:

  • For each radio station save a playlist file (*.pls, *.m3u or sometimes *.asx) in a folder called “radio” on my local machine. I download most of them from the shoutcast or icecast stream directories. I also add one special (empty) file called “none.pls” (which serves to turn of all radio).
  • Add a toolbar to the taskbar that lists the content of the radio folder, i..e. all the webradio playlist files as clickable items. In XFCE this requires a Gnome applet (Debian packages xfce4-xfapplet-plugin, file-browser-applet).
  • Configure the default app for the playlist mime types mentioned above to be my bash script “mplayer-radio.sh”. It kills any existing webradio playback and plays the selected playlist file. See below for how to configure mime-type association defaults.
  • Make sure that I have a “nogui” version of mplayer installed so that no window pops up. Don’t use gmplayer, kplayer or any of that crap to play audio. I like mplayer because it supports all codecs out of the box.

This is my little “mplayer-radio.sh” script (requires the pkill command):

#! /bin/bash
pkill -f "mplayer -playlist" 
mplayer -playlist "$@"

To set my script as the default handler for the most common playlist file types, put the following into ~/.local/share/applications/defaults.list:

[Default Applications]
audio/x-mpegurl=mplayer-radio.sh.desktop
audio/x-scpls=mplayer-radio.sh.desktop

Make sure you have a file “mplayer-radio.sh.desktop” in ~/.local/share/applications or in /usr/local/share/applications with contents like this:

[Desktop Entry]
Exec=mplayer-radio.sh %U
MimeType=audio/x-mpegurl;audio/x-scpls;video/x-ms-asf
Name=mplayer-radio.sh
StartupNotify=false
Terminal=false
Type=Application

If I have to use M$ Windows then I do something similar using a taskbar toolbar for the radio folder and the lightweight Foobar2000 player, configured to run minimized as systray icon.

Categories: debian, opensuse

Set up sudo on Debian

August 20, 2011 Leave a comment

Debian does not use sudo by default. I like sudo for admin tasks when being logged in as a regular user (mostly based on my experience with Ubuntu) for several reasons:

  • No risk of an open root shell
  • Logging of “who did it”
  • Selective access can be configured flexibly

What I don’t like in Ubuntu is that the sudo password is the regular user’s password and that the root account is actually disabled:

  • We lose one level of security (root password) and the regular user password is often not carefully chosen and maybe not kept secret enough (because maybe your wife or others know it to do “regular user stuff” using your account.
  • In a “one admin person” system like your typical laptop or desktop there is no concern that the root password would have to be shared among several admins.

So for these reasons I usually configure a “one admin person” Debian system like this (replace REGULAR_USERNAME with your regular username that will be the admin):

su -
apt-get install sudo
adduser REGULAR_USERNAME sudo
visudo

In the visudo editor edit the “Defaults” line to use “targetpw”:

Defaults env_reset,targetpw

Then exit the root shell, logout the regular user and login as regular user again (required to activate group membership).

Now your regular user should be able to do everything that root can do using sudo and the root password.

Categories: debian
Follow

Get every new post delivered to your Inbox.