ru Русский

Reticularium

NETWORKS PLACE

Well, I don’t know whether it was a good idea to make init scripts systems have dependencies, it had been perfectly simple and straightforward in FHS. And anyone could place scripts in needed order. Seems unnecessary automation to me, and KISS principle violation.

But what happened happened, and we have to live with it. Once it was a simple task to write a init script: just trivial case $1 in start) ;; stop) and so on. What we have now is a complete mess. If you google “missing LSB tags and overrides”, you’ll get the idea. Every init script needs special LSB headers now, but a lot of software just links some internal script to /etc/init.d during the install process, and there is no LSB headers. So you get a lot of complains from e.g. modern Debians and Ubuntus each time you install some package and even installation failures. Might be bad implementation though (insserv). Anyways, fortunately there is a good workaround (bad workaround that is often recommended being to uninstall insserv).

Just put the code below to an override file /etc/insserv/overrides/your_real_script_name

1
2
3
4
5
6
7
### BEGIN INIT INFO
# Provides:          your_init_script_name
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Required-Start:
# Required-Stop:
### END INIT INFO

Note one thing that is not obvious: the name of the override file must be the same as your real script name, but inside the file the header “Provides:” must point to the init script name. Normally it is the same name, but in case you have symlinked a real file to /etc/init.d, and the symlink has a different name, it needs to be done like this, otherwise won’t work.

Useful to sync gems across servers. Converts gem list --local output to a bunch of gem install commands. Rails related gems are removed from the initial list.


gem list --local | grep -v '\*' | grep -v ^$ | grep -v ^action | grep -v ^active | grep -v ^rails | grep -v ^rack | grep -v ^rake | sed 's|(|-v=|' | sed 's|)||' | sed 's|^\(.*\),|\1\n\1|' | sed 's|=.*[[:space:]]|=|' | sed 's|^|gem install |'

Command mount --rbind mounts recursively, which is handy, but umount has no recursive capabilities, so several umount commands are needed to unmount. The easiest way to do this is to look into /proc/mounts :

cat /proc/mounts

Even better:

cat /proc/mounts | awk '{print $2}'

Take a look and if you can grep needed mountpoints out of it, just add |grep <something> | sort -r | xargs umount to the above line.

I am used to ask Linux utility date about everything related to date/time, like date -d "next friday" or date -d "+245 min", but it doesn’t answer one question I have pretty often: what time is it now in certain timezone?

So I had to create a simple script for this:

1
2
3
4
5
6
7
#!/bin/bash

localtime=`date +"%x %X"`
zonediff=`date -d "$1" +"%H:%M"`
hours="`echo $zonediff | cut -d':' -f1` hours"
minutes="`echo $zonediff | cut -d':' -f2` minutes"
date -d "-$hours -$minutes" +"%x %X"

Zone here is represented by alphabetic abbreviation, that is if you named this script e.g. “timein”, you use it like this:

timein EDT

Taken from the Fedora forum

..........

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#modprobe dm-mod
#vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2
# vgchange -a y VolGroup00
# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
. . .
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
# mkdir /mnt/VolGroup00/01
# mount /dev/VolGroup00/LogVol01 /mnt/VolGroup00/01

Reference the man pages for lvm, pvdisplay, vgdisplay, lvcreate, lvdisplay, lvextend

..........

As you can see, you need two things: dm-mod kernel module and LVM2 package (apt-get install lvm2 on Debian, emerge lvm2 on Gentoo and so on)

My personal note: LVM provides several useful features but has one huge drawback. If your disk or file system crashes, you won’t be able to access your LVM partitions using any liveCD. At least I don’t know any that would have both dm-mod module and LVM2 package.

Well, quite self-explanatory. Only Bash and Ruby. Options “folder” and “name” are examples, replace them with what you need… Shared in hope this can help someone.

Read the article

The subject is extremely annoying. I am not that lazy to add a comment symbol myself. This would have been a good idea though, if it wasn’t sometimes needed to insert blocks of code via clipboard. With auto-comment on, if I insert

some line
# some comment
some line

I get

some line
# some comment
# some line

because there is a CR at the end of commented line and the auto-comment function adds the # symbol to the next line automatically.

The real problem begins when you try to insert many lines with some of them commented. You end up with each line after the first comment commented, the next comment commented twice so the next lines all commented twice and so on.

The solution:

Add this to your vimrc file:


au FileType * setl fo-=cro

where:

  • au = autocmd
  • FileType * – any file type
  • setl = setlocal
  • fo = formatoptions
  • -=cro disables c, r and o options ( see documentation )

This is a really annoying problem we meet pretty often. You can meet it even if you don’t use Bash. For example, you upload an image named “my lovely cat.jpg” to your website and find no image there. Or it has no thumbnail. This may happen because you are using some program for making thumbnails that is being called from, say, PHP via backtick operator (that is, using unix shell) and that program interprets the file name passed to it as three different command line options: my, lovely and cat.jpg.

Read the article

I was doing a simple test of pwgen (handy utility to generate passwords) and since this test was creating a lot of files in a folder I decided to combine it with a test of ls speed vs find speed:

Read the article

For some reason there is no obvious way to enable it (Gnome 2.26.3)

  1. Open GConf editor: Applications -> System Tools -> Configuration Editor
  2. apps -> metacity -> general -> compositing manager (check box there)

That’s all. Enjoy numerous visual effects like shadows, real transparency (underlying windows become visible) etc.