3 # DON'T RUN THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING
5 # bash script to md5-hash all passwords: RUN ONLY ONCE!
6 # md5sum needs to be installed
8 # this script is not enough to use md5-hashed passwords: an
9 # appropriate localizer needs to be set up as well.
13 echo "usage: $0 dbname"
22 # to get a backslash in the first pass sql script
\r
24 # to get a backslash in the second pass sql script
\r
26 # to get an escaped backslash in the second pass sql script:
\r
30 SCRIPT_FILE="/tmp/hashpasswords.$$.sql"
32 echo psql $1 -P format=unaligned -t -X -F "" -c \
33 "select '${s2}set hashedpassword ${s1}'${s2}${s1}'${s1}' \`echo -n \"'||password||'\" | md5sum \` \
\r
34 \"${TEXT_SOURCE_PATH}\$(basename \"' || trim($2) || '\")\"\` ${s1}'${s2}${s1}'\\'\n', \
\r
35 'update webdb_users set password=:hashedpassword where id = '||id from webdb_users" > $SCRIPT_FILE
\r
39 #psql -f ${SCRIPT_FILE} -d template1