How do I sign a Certificate Request?

January 18th, 2010

Quick not to myself since everytime I spend hours in searching it again.

The command line is:

openssl x509 –req –in <path>/<certificate_request>.csr  –signkey <path-to-CA-private-cert>/CA-private-cert.pem –out <path-to-certs-repository>/signed-cert-name.pem

Hopefully next time I do not have to search it again hours and hours ;)

Naturally this command required to have created the request before, and to have correctly setup the CA… but there is documentation on the ‘Net concerning these two operations.


Email this post Email this post

Want to know the IMAGE LABEL of my ISO file

January 18th, 2010

This is something not so easy to find on the internet, and once again Linux shows its immense power in the simplest way: CLI.

Question: I have a .ISO file representing the image of a DVD and I want to know the LABEL of that DVD.

Answer: Issue the command

dd if=/<path>/filename.iso bs=1 skip=32808 count=32

on whatever Linux terminal.

For example, here’s what is returned for a backup copy of DVD I legally own:

Input command:
dd if=Natale\ in\ Casa\ Muppets.iso bs=1 skip=32808 count=32

Output:
MUPPETS_CHRISTMAS_CAROL         32+0 records in
32+0 records out
32 bytes (32 B) copied, 0.00129793 s, 24.7 kB/s

Enjoy!


Email this post Email this post

uPnP Media Server with llink.

January 16th, 2010

Let’s start this new year by referencing an excellent system I happened to find on the Internet to perform uPnP server functionality on my Linux system.

The name of the thing is LLink and although I haven’t exploited at full yet, it looks VERY promising.

Some features:

  • Parses various video containers: vob, avi, ts, mkv, tp, mov, m2ts, evo.
  • Streams any file type the NMT player can handle: mp3, flac, jpeg, png etc.
  • Can play straight from rar files: no more need to unrar your media. (Comes with special unrar-3.7.8-seek.)
  • SSDP / UPnP discovery support (although minimal).
  • Skin support: make your own html templates or choose from pre-built.
  • Simple iMDb querying to look up media information for Jukebox skins.
  • Both HD and SD skins available.
  • Light, tiny and clean code for Unix, OsX and Windows.
  • Paginating: support to send listings in pages, with tags for Next/Prev.
  • PlayAll cgi tag, and PlayAllFrom.
  • External subtitles: subtitle files can be consolidated in one directory.
  • libdvdnav support (and libdvdcss): provides basic playback of DVD .iso and .img files and from DVD drives.
  • UDF 2.50 BD5-ISO support: provides basic playback of Bluray and HD-DVD.

Got interested? You can find more here.


Email this post Email this post

Scripting Galore – The beauty of randomic sort

December 31st, 2009

Although it could seem an oxymore, sort something in randomic order might be usefl sometimes.

Give a look to the script below, which I’m writing here for future reference.

#!/bin/bash
#
# This script creates a list of file or symbolic link to pictures in a directory
# The pictures are dynamically selected within a library of thousands
# This is to allow a wireless frame to display daily an ever changing list
# of pictures

# Define variable to be the target directory where we put the link/pictures
# This directory is regularly scanned by MediaTomb, the uPnP server talking to
# the digital frame

# Define variable to be the root directory where it will start to scan
scandir=/media/allphotos

# Clean previous contents of the directory used for streaming
cd /var/streampix
rm -rf *

# Define cycle to set the max number of photos to be displayed
# (like from 1 to 50 repeat)
for i in `seq 1 50`

# list the dir, pick a random file, add to the list
do
y="$(find $scandir -type f -iregex ‘.*\.\(bmp\|gif\|jpg\|png\)$’ | sort -R | head -1)"
cp "$y" /var/streampix/
done

Enjoy!


Email this post Email this post

Scripting Galore – Copy list of files from bigger repository into another location

November 29th, 2009

I don’t consider myself a script guru, but sometimes I like to create small pieces of bash code to ease operations on my linux box… and I guess it’s good idea to note here some of the recent solutions I’ve found for later remembering.

I’ll try to comment them, so that readers will be able to readapt them to their needs.

Need: I have a list of files in subdirectories under main one and I want to copy only some of them to new location. I have the list of files I need in a text file.

#!/bin/bash
#
DIR=root # Location where the list I want to extract is located
FILE=wantedlist # with the name of the file
DIR_VIDEO=”/media/bigdisk” # Master repository containing iles in subdirectories
COPY_DEST=”/media/externalHDD/backup” # where I want to put my files
y=`cat /$DIR/$FILE|wc -l` # counting how many files I want to copy
for i in `seq 1 $y` # starting the cycle
do
# I’ll copy file mentioned in every line in the text list in new location
cp -R /$DIR_VIDEO/”`cat /$DIR/$FILE | tail -$i|head -1`” $COPY_DEST
done

Please note the usage of head and tail to go line by line in reverse order ;) , while the cycle allows me to repeat this for each line in the text list.

#!/bin/bash
#
DIR=root
FILE=listarmando
DIR_VIDEO=”/media/video”
COPY_DEST=”/media/roarinnas/secondodisco”
y=`cat /$DIR/$FILE|wc -l`
for i in `seq 1 $y`
do
cp -R /$DIR_VIDEO/”`cat /$DIR/$FILE | tail -$i|head -1`” $COPY_DEST
d

Email this post Email this post

Extending an ext3 partition on Linux (without losing data)

November 3rd, 2009

Here’s another successful operation done on fantastic Linux OS that is a pure dream for other operating systems.

Situation: I have a virtual machine with 20 GB HDD, partitioned as follows:

95% ext3 on primary partition

5% swap on first partition of extended partition

I certainly can expand my hard disk, by setting the new size in VMware configuration… so I brought it to 60 GB… but then I have a problem, since I cannot use tools like gparted to extend the main partition since the swap is in the middle between the two.

What to do? Well, again Google has been a best friend.

Well done, well written, clear and… working!


Email this post Email this post

Tunneling Apps in SSH

July 4th, 2009

Yesterday I found a very handy functionality in Putty: tunneling apps in SSH.

Not that I did not know that this technique exist ;) but for the first time I tried it and worked out of the box.

The idea is to enable tunneling of insecure applications inside an established and authenticated SSH encrypted session, using Putty as a client.

Scenario in my case is that I have few web based appliances at home acting as a media center, a NAS, etc… each of them being manageable by a web based interface on various ports.

I could certainly open destination PAT on my router, but it would increase the risk… and I don’t trust level of security implemented in such systems.

Therefore I’ve done something represented in picture below

ssh tunnel

How to configure it in Putty? Well, when you launch the session to connect to SSHD Server, check in SSH options – Tunnels.

There you find the chance to add the port forwarding parameters to be set as follows:

putty-tunnels

Enjoy!


Email this post Email this post

Enabling SPDIF sound on Ubuntu with Dell Docking station

April 13th, 2009

Should you come across the same need, I just found a working solution, even if quite odd.

The trick to get it working is to go into sound settings and enable IEC958 Playback AC97-SPSA, checking that volume is set to… 0.

Magically sound will begin to flow out of the SPDIF interface.


Email this post Email this post

Bulk File Rename

March 24th, 2009

Situation:

I have multiple files with extension .sh.modified and I need to rename them all into .sh extension.

Solution:

for file in *.sh.modified; do mv ${file} ${file%sh.modified}.sh; done


Email this post Email this post

How to check for new files in a directory

March 21st, 2009

Made this small script for this purpose…

#!/bin/bash
#
# Script to check a directory and write in file the new files
# since last check.
#
# Written by RoarinPenguin (
roarinpenguin@rottigni.net) on
#
21 march 2009
# Released under GPL License
#
# You need to create a file called lastcheck.time in same
# directory of this script
#

ADMIN="change to administrator email address"
DIR2MON=/var/www/dir-clienti

> ./newfiles.list
echo "Last check for new files, done on "`date` >> ./newfiles.list
find $DIR2MON -maxdepth 5 -newer ./lastcheck.time >> ./newfiles.list
touch ./lastcheck.time


Email this post Email this post