February 2012
M T W T F S S
« Jan   Mar »
 12345
6789101112
13141516171819
20212223242526
272829  
144

Refs

Categories

Archives

profile for slm on Stack Exchange, a network of free, community-driven Q&A sites

Delicious Bookmarks for February 21st through February 22nd

These are my links for February 21st through February 22nd:

[one-liner]: Using the Linux Command, dirsplit, to Dynamically Backup a Directory Over Multiple DVDs

Background

At my day job I deal with a fair amount of image data. We typically are shipping the data out on either hard drives, thumb drives, or via SFTP. On occasion we will some times burn it to a CD and/or a DVD. But until today all the data was either large sets (200-400GB) variety, or small, less than 1-2GB. However today’s shipment was 18GB. What to do? I didn’t have a spare USB thumb drive handy so I thought, ah I’ll just throw it on a couple of single layer DVDs. So my first order of business was to figure out how many. As it is with Linux/UNIX, there is pretty much already a tool for everything, if only you look hard enough 8-).

For this particular shipment all the image data was organized into a couple dozen folders, each weighing in a ~100-200MB. I quickly figured that 5 DVDs should be more than enough, but how to optimally fill each DVD? Luckily there’s a program called dirsplit which made this a breeze.

Solution

Again another tool I’ve never heard of, dirsplit is actually a Perl script that can analyze a directory and report the optimal way to burn it to a set of DVDs. Once it’s done analyzing a directory, it’ll report back a set of .list files, one per each DVDs worth of files. dirsplit is part of the package cdrkit which in addition to dirsplit, also includes the following programs:

  • dirsplit: dirsplit utility
  • genisoimage: Creates an image of an ISO9660 filesystem
  • icedax: A utility for sampling/copying .wav files from digital audio CDs
  • wodim: A command line CD/DVD recording program – (“write optical disk media”) – a cdrecord replacement

It can get a little confusing, but cdrkit, at least under Fedora & CentOS, is comprised of 4 individual RPMs, so we’re only going to be using dirsplit. I installed it like so:

1
yum install dirsplit

dirsplit’s basic usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
% dirsplit [options] [advanced options] < directory >
 
 -H|--longhelp Show the long help message with more advanced options
 -n|--no-act   Only print the commands, no action (implies -v)
 -s|--size     NUMBER - Size of the medium (default: 4488M)
 -e|--expmode  NUMBER - directory exploration mode (recommended, see long help)
 -m|--move     Move files to target dirs (default: create mkisofs catalogs)
 -p|--prefix   STRING - first part of catalog/directory name (default: vol_)
 -h|--help     Show this option summary
 -v|--verbose  More verbosity
 
The complete help can be displayed with the --longhelp (-H) option.
The default mode is creating file catalogs useable with:
    mkisofs -D -r --joliet-long -graft-points -path-list CATALOG
 
Example:
dirsplit -m -s 700M -e2 random_data_to_backup/

Once installed, cd <image data directory>, and run the following command:


…. Continue reading → [one-liner]: Using the Linux Command, dirsplit, to Dynamically Backup a Directory Over Multiple DVDs »»

Delicious Bookmarks for February 21st from 13:54 to 16:21

These are my links for February 21st from 13:54 to 16:21:

Delicious Bookmarks for February 20th through February 21st

These are my links for February 20th through February 21st:

Delicious Bookmarks for February 20th from 02:51 to 10:44

These are my links for February 20th from 02:51 to 10:44:

[one-liner]: Script to Cleanly Start Dropbox During a boot sequence on Linux (Fedora & CentOS)

Background

I’m an avid user of Dropbox. I run it on all my Linux and Windows systems, and it simply just works. However, one annoying thing that I’ve just dealt with for a while now on Linux, is when I reboot my laptop, Dropbox, doesn’t come up correctly due to the wireless network not being up just yet. I should mention here, that I’m using NetworkManager to manage my networks.

For whatever reason, this seems to hang Dropbox up and even after NetworkManager gets around to connecting to a wireless network, I still have to restart Dropbox.

Solution

So after dealing with this for over a year, I figured it was a good time to address this. My approach was to simply wrap the startup of Dropbox via a shell script, so that Dropbox wouldn’t start until my wireless network was available. It only runs during boot-up, after starting Dropbox, it simply exits.

Here’s my script, called start_dropbox.bash:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
 
# SCRIPT:      start_dropbox.sh
# DESCRIPTION: Guards dropbox from starting until the network is up and available.
# SWITCHES:    [-v] -- for verbose, only used during development + testing!
 
# ref: http://wiki.bash-hackers.org/commands/builtin/printf
# ref: http://stackoverflow.com/questions/3224878/what-is-the-purpose-of-the-colon-gnu-bash-builtin
 
progname="dropbox"
wireless="wlan0"
ifcfgCmd="ifconfig $wireless | grep \"inet addr:\" | cut -d\":\" -f2 | awk '{print \$1}'"
dropbCmd="dropbox start -i"
 
# verbose output?
if [ "$1" == "-v" ]; then
  vpf=printf
  vecho=echo
else
  vpf=":"
  vecho=":"
fi
 
check_process() {
  $vpf "%-25s" "$1 running?"
  [ "$1" = "" ] && return 0
  [ `pgrep -nx $1` ] && return 0 || return 1
}
 
check_network() {
  $vpf "%-25s" "device $1 running?"
  [ `eval $ifcfgCmd` ] && return 0 || return 1
}
 
$vecho "begin checking..."
 
# wait for network
while [ 1 ]; do
  # wlan0 up?
  check_network "$wireless"
  if [ $? -eq 0 ]; then
    $vecho "Yup" && break
  else
    $vecho "Nope"
  fi
  sleep 10
done
 
# wait for progname
while [ 1 ]; do
  # already running?
  check_process "$progname"
  if [ $? -eq 0 ]; then
    $vecho "Yup" && break
  else
    $vecho "Nope" && `eval $dropbCmd > /dev/null`
  fi
  sleep 10
done
 
$vecho -e "$progname running w/ PID:  $(pgrep -x "$progname")\n"
exit 0
# vim: set ts=2 :

So now when my laptop starts up the Dropbox entry under System -> Preferences -> Startup Applications now runs my script, /home/saml/bin/start_dropbox.bash instead of dropbox start -i. The script’s behavior looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# NOTE1: NetworkManager is off
# NOTE2: dropbox isn't running
 
# NOTE3: the output below is generated with the -v switch, this is used only for testing purposes!
 
# Shell #1
% start_dropbox.bash -v
begin checking...
device wlan0 running?    Nope
device wlan0 running?    Nope
device wlan0 running?    Nope
device wlan0 running?    Nope
...
 
# Shell #2
% sudo /etc/init.d/NetworkManager start
 
# Shell #1
device wlan0 running?    Nope
device wlan0 running?    Yup
dropbox running?         Nope
dropbox running?         Yup
dropbox running w/ PID:  27112

References

links

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

Page 4 of 9« First...23456...Last »