Changes between Version 5 and Version 6 of RenameUsersScript


Ignore:
Timestamp:
Apr 27, 2010, 6:40:06 PM (5 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RenameUsersScript

    v5 v6  
    55The 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.
    66
     7The 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
    79{{{
    8 #!sh
    910#!/bin/bash
    1011
    11 for i in \
    12         "old1 new1"\
    13         "old2 new2"
    14 do
    15   OLDNAME=${i% *}
    16   NEWNAME=${i#* }
    17   sqlite3 trac.db <<EOF
     12if [ $# -ne 2 ]
     13then
     14  echo "Usage: renameuser oldname newname"
     15  exit 1
     16fi
     17
     18OLDNAME=$1
     19NEWNAME=$2
     20
     21sqlite3 trac.db <<EOF
    1822UPDATE "permission" SET username='$NEWNAME' WHERE username='$OLDNAME';
    1923UPDATE "auth_cookie" SET name='$NEWNAME' WHERE name='$OLDNAME';
     
    3034UPDATE "component" SET owner='$NEWNAME' WHERE owner='$OLDNAME';
    3135EOF
    32 done
    3336}}}
    3437