[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netatalk-devel
Subject:    [Netatalk-devel] simple script to upgrade from cnid.db to cnid2.db
From:       Olaf Hering <olh () suse ! de>
Date:       2006-03-20 21:00:05
Message-ID: 20060320210005.GA2303 () suse ! de
[Download RAW message or body]

I wrote this script to simplify the upgrading between versions.


#!/bin/bash
set -e
# set -x
afpd_pid=`pidof /usr/sbin/afpd || :`
if ! test -z "$afpd_pid"
then
	echo "afpd with pid $afpd_pid is still running, stop it before upgrading the databases"
	echo "try 'rcatalk stop', which disconnects all netatalk clients without warning!"
	exit 1
fi
wdir=
oldcwd=`pwd`
for export_dir in "$@"
do
	export_dir="${export_dir%/}"
	export_dir="${export_dir%.AppleDB}"
	if test -d "${export_dir}/.AppleDB"
	then
		cd "${export_dir}/.AppleDB"
		if test -f cnid2.db
		then
			echo " - `pwd` has already a cnid2.db, skipping"
			continue
		fi
		wdir=`pwd`
		# db_update doesnt like it when the dbfiles are in $PWD
		cd /
		echo " - upgrading ${wdir}"
		cnid_access=`stat -c '%U:%G %a' "${wdir}/cnid.db"`
		for i in cnid didname mangle devino
		do
			echo -n "${i} "
			cp -Laf --remove-destination "${wdir}/${i}.db" "${wdir}/${i}.db.$$.backup"
			db_upgrade "${wdir}/${i}.db"
			db_dump -f "${wdir}/${i}.dump" "${wdir}/${i}.db"
			rm -f "${wdir}/${i}.db"
		done
		echo "... dump done"
		echo " - running cnid2_create"
		cd "${wdir}"
		cnid2_create
		rm -fv __db.* log.* *.db
		echo " - creating cnid2.db"
		db_load -f cnid2.dump cnid2.db
		chown -v "${cnid_access%% *}" cnid2.db
		chmod -v "${cnid_access##* }" cnid2.db
		ls -Alt
		echo " - done with ${wdir}"
	else
		echo " * skipping $export_dir"
	fi
done

["upgrade_netatalk_AppleDB.sh" (application/x-shellscript)]

#!/bin/bash
set -e
# set -x
afpd_pid=`pidof /usr/sbin/afpd || :`
if ! test -z "$afpd_pid"
then
	echo "afpd with pid $afpd_pid is still running, stop it before upgrading the databases"
	echo "try 'rcatalk stop', which disconnects all netatalk clients without warning!"
	exit 1
fi
wdir=
oldcwd=`pwd`
for export_dir in "$@"
do
	export_dir="${export_dir%/}"
	export_dir="${export_dir%.AppleDB}"
	if test -d "${export_dir}/.AppleDB"
	then
		cd "${export_dir}/.AppleDB"
		if test -f cnid2.db
		then
			echo " - `pwd` has already a cnid2.db, skipping"
			continue
		fi
		wdir=`pwd`
		# db_update doesnt like it when the dbfiles are in $PWD
		cd /
		echo " - upgrading ${wdir}"
		cnid_access=`stat -c '%U:%G %a' "${wdir}/cnid.db"`
		for i in cnid didname mangle devino
		do
			echo -n "${i} "
			cp -Laf --remove-destination "${wdir}/${i}.db" "${wdir}/${i}.db.$$.backup"
			db_upgrade "${wdir}/${i}.db"
			db_dump -f "${wdir}/${i}.dump" "${wdir}/${i}.db"
			rm -f "${wdir}/${i}.db"
		done
		echo "... dump done"
		echo " - running cnid2_create"
		cd "${wdir}"
		cnid2_create
		rm -fv __db.* log.* *.db
		echo " - creating cnid2.db"
		db_load -f cnid2.dump cnid2.db
		chown -v "${cnid_access%% *}" cnid2.db
		chmod -v "${cnid_access##* }" cnid2.db
		ls -Alt
		echo " - done with ${wdir}"
	else
		echo " * skipping $export_dir"
	fi
done

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Netatalk-devel mailing list
Netatalk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/netatalk-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic