# # check nbd account # if [ -z "$(grep ^nbd /etc/group)" ]; then groupadd -g 316 nbd fi if [ -z "$(grep ^nbd /etc/passwd)" ]; then useradd -u 316 -g 316 -d /var/lib/nbd -s /bin/bash -c "Network Block Device Server" nbd fi if [ -z "$(groupmems -g disk -l | grep -w nbd)" ]; then groupmems -g disk -a nbd fi config() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r $OLD ]; then mv $NEW $OLD elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy rm $NEW fi # Otherwise, we leave the .new copy for the admin to consider... } config etc/nbd-server/config.new config etc/nbd-server/allow.new config etc/rc.d/rc.nbd-server.new