Archive for December 2010
I was working on a customers project and I had to change a lot of files. This
could easily be done with the sed
and find
commands, but I wanted these
changes to be checked in into git
as well. And I also wanted the git
keywords expanded.
There was always the trick to edit all the files with sed
, then edit them
again with git.vi
and just press ZZ
for all files. This would be tedious, I
know.
So I decided to take the Geeks Shortcut and recode git.vi
so
everything can be be done automatic.
Read more »
Some users insist on using bash
. This is a good shell, but not as
good as zsh
. But, I do want them to be able to use the per
directory umask
as well as all the zsh
users.
So I started digging, as the bash
shell does not support a chpwd
hook.
This is what I came up with:
chpwd()
{ # Set the initial umask
case "${PWD}/"
in
/etc/puppet/*)
um=$(umask)
umask 007
;;
*)
[[ x"${um}" != x"" ]] && umask ${um}
;;
esac
}
function cd()
{
builtin cd "${@}"
chpwd
}
Now, when I change to the directory /etc/puppet
I do get a umask
of 007
and when I cd
somewhere else, I do get the original umask
.
I do redefine the intercal cd
command to run the chpwd
hook. There must be
a more elegant way to do this, but this does the job.
I've been working with Puppet some time now, and we are configuring our way
through a lot of hosts, with 6 persons, all working in the same Puppet master
directory.
This should work fine with all UNIX/Linux groups and setgid
directories. But
simple problem arose with the git
version control stuff.
Once in a while the complete git
repo was destroyed and quite a lot of
searching revealed the reason why.
We are all working as non-root and we are all members of the Puppet group. But:
When I edit a file and commit it, the corresponding files in the git repo are
made by me and the rights are set according to my umask
. When someone else
tries to edit the same file or something else which results in the same hash
files, writing is not permitted, because of my ownership. A chown
in a script
will not work, as a chown
is not honored as a non-root user.
This problem can simply be solved by setting the umask
to something like
007
(or u=gwx,g=gwx,o=
). But when I do edit stuff in my home-directory I do
not want an open umask
like that. So what to do, as ext[234]
do not support
per directory umasks.
I use zsh
as a shell and I found a nice function in the man-page. There is a
standard function, called chpwd()
that gets executed every time a directory
change is made. So I only had to fill in the blanks.
This is what I came up with:
chpwd()
{
case "${PWD}/"
in
/etc/puppet/*)
[[ ${UMSAVE} = 0 ]] &&
{ um=$(umask)
UMSAVE=1
}
umask 007
;;
*)
[[ x"${um}" != x"" ]] && umask ${um}
UMSAVE=0
;;
esac
}
Now, when I change to the directory /etc/puppet
I do get a umask
of 007
and when I cd
somewhere else, I do get the original umask
.
How much fun can it be 
The WikiLeaks site cannot be reached. This is because their
free DNS provider everydns.com
removed the DNS records.
The last IP address was 213.251.145.96
, but nobody is answering the http
requests.
Looks like they where shutdown.
I was playing around and configuring the MySQL backup on a customers database
server and I ran into little problems. One of the defaults was not parsed
correctly and a configuration setting made things run amok.
So I decided to streamline things and create some extra program options to set
and show the default settings and the settings after the configuration file.
The help
now shows:
mysqlbackup version 1.50
Syntax: mysqlbackup [ -h|-v|-s|-c|-d|]
-h Display this help and exit
-v Display the version number and exit
-s Show the defaults and their values
-d Show a description of the defaults and their values
-c Show a default configuration file
-a Show settings after the config file is processed
configfile Use this file as the configuration file
instead of the default.
Default: /usr/local/bin/mysqlbackup.conf
Come and g[ei]t it. It's in the download section or on GitHub.
Read more »