Changes between Version 5 and Version 6 of RenameUsersScript
- Timestamp:
- 04/27/10 18:40:06 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RenameUsersScript
v5 v6 5 5 The following script renames user accounts in a SQLite database. This is particularly useful when you imported a database from Bugzilla, which uses e-mail addresses as user names, and want to use different user names in your Trac or Subversion. 6 6 7 The original version showed how to do it with a canned list of old and new names in the script. This version accepts an old name and a new name on the command line, making sure there are two arguments before proceeding. This seems more immediately useful to me. 8 7 9 {{{ 8 #!sh9 10 #!/bin/bash 10 11 11 for i in \ 12 "old1 new1"\ 13 "old2 new2" 14 do 15 OLDNAME=${i% *} 16 NEWNAME=${i#* } 17 sqlite3 trac.db <<EOF 12 if [ $# -ne 2 ] 13 then 14 echo "Usage: renameuser oldname newname" 15 exit 1 16 fi 17 18 OLDNAME=$1 19 NEWNAME=$2 20 21 sqlite3 trac.db <<EOF 18 22 UPDATE "permission" SET username='$NEWNAME' WHERE username='$OLDNAME'; 19 23 UPDATE "auth_cookie" SET name='$NEWNAME' WHERE name='$OLDNAME'; 30 34 UPDATE "component" SET owner='$NEWNAME' WHERE owner='$OLDNAME'; 31 35 EOF 32 done33 36 }}} 34 37

