Update of /cvsroot/devil-linux/build/scripts/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv27621/scripts/scripts
Modified Files:
upgrade-config
Log Message:
Add migration of passwd/shadow/group/gshadow files.
Index: upgrade-config
===================================================================
RCS file: /cvsroot/devil-linux/build/scripts/scripts/upgrade-config,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- upgrade-config 30 Dec 2003 15:24:38 -0000 1.11
+++ upgrade-config 30 Dec 2003 18:44:50 -0000 1.12
@@ -104,6 +104,14 @@
[ $f = "etc/sysconfig/software" ] && continue
[ $f = "etc/mtab" ] && continue
[ $f = "etc/.pwd.lock" ] && continue
+ [ $f = "etc/passwd" ] && continue
+ [ $f = "etc/passwd-" ] && continue
+ [ $f = "etc/group" ] && continue
+ [ $f = "etc/group-" ] && continue
+ [ $f = "etc/shadow" ] && continue
+ [ $f = "etc/shadow-" ] && continue
+ [ $f = "etc/gshadow" ] && continue
+ [ $f = "etc/gshadow-" ] && continue
[ "$(expr substr "$f" 1 12)" = "etc/modules/" ] && continue
[ "$(expr substr "$f" 1 20)" = "etc/sysconfig/config" ] && continue
[ "$(expr substr "$f" 1 17)" = "etc/ssh/ssh_host_" ] && onoff="on"
@@ -220,12 +228,58 @@
cp -f etc/sysconfig/config newconfig/etc/sysconfig/config.old
cp -f newconfig/etc/sysconfig/config newconfig/etc/sysconfig/config.default
. etc/sysconfig/config
- echo "Migrating /etc/sysconfig/config values "
+ echo "Migrating /etc/sysconfig/config values ..."
echo
for bs in $(grep -v -e '^ *#' -e '^ *$' etc/sysconfig/config|cut -f1 -d'=')
do
eval mod_config newconfig/etc/sysconfig/config ${bs} \"\$${bs}\"
done
+fi
+
+if askyesno "User and Group migration" "Do you want to migrate your old users, groups and passwords?" yes ; then
+ migrateid ()
+ {
+ cp -f newconfig/${1} newconfig/${1}-
+ cp -f newconfig/${2} newconfig/${2}-
+ > newconfig/${2}
+
+ # Migrate passwords for existing users/groups
+ while read id ; do
+ name="$(echo $id|cut -d: -f1)"
+ if [ $(grep -c "^${name}:" ${2}) -ne 1 ]; then
+ grep "^${name}:" newconfig/${2}- >> newconfig/${2}
+ else
+ grep "^${name}:" ${2} >> newconfig/${2}
+ fi
+ [ "$(grep "^${name}:" ${2})" != "$(grep "^${name}:" newconfig/${2}-)" ] && \
+ echo ${name} - info migrated. | tee -a $LOGF
+ done < newconfig/$1
+
+ # Add all non-existing users/groups to new config
+ while read id ; do
+ name="$(echo $id|cut -d: -f1)"
+ [ "$(grep -c "^${name}:" newconfig/${1})" -gt 0 ] && continue
+ grep "^${name}:" ${1} >> newconfig/${1}
+ grep "^${name}:" ${2} >> newconfig/${2}
+ echo ${name} - created. | tee -a $LOGF
+ done < $1
+ }
+
+ echo >> $LOGF
+ echo | tee -a $LOGF
+ echo "User migration:" | tee -a $LOGF
+ echo "---------------" >> $LOGF
+ echo | tee -a $LOGF
+
+ migrateid etc/passwd etc/shadow
+
+ echo >> $LOGF
+ echo | tee -a $LOGF
+ echo "Group migration:" | tee -a $LOGF
+ echo "----------------" >> $LOGF
+ echo | tee -a $LOGF
+
+ migrateid etc/group etc/gshadow
fi
rm -fr $TMPD $RESULT
|