Mercurial > hgrepos > hgweb.cgi > s4
changeset 786:809caeb20758 feature-world
Migration caller set arguments beforehand
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 13 Jun 2020 13:19:07 +0900 |
parents | 1f310d682c07 |
children | c5b61d23052b |
files | s4-funcs.sh s4-migrate.sh |
diffstat | 2 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-funcs.sh Sat Jun 13 13:16:24 2020 +0900 +++ b/s4-funcs.sh Sat Jun 13 13:19:07 2020 +0900 @@ -11,6 +11,9 @@ echo S4WORLD=$S4WORLD >&2 worldconf=s4-config-${S4WORLD}.sh ;; + *) + worldconf=s4-config.sh + ;; esac echo worldconf=$worldconf >&2 @@ -99,7 +102,8 @@ worldlistfile=cache/worldlist worldoptionfile=cache/worldoption if [ ! -e $worldlistfile -o $worldlistfile -ot s4-config.sh \ - -o ! -e $worldoptionfile -o $worldoptionfile -ot s4-config.sh ] + -o ! -e $worldoptionfile -o $worldoptionfile -ot s4-config.sh \ + -o s4-funcs.sh -nt $worldoptionfile ] then echo S4MASTERURL=$S4MASTERURL >> tmp/debug.out cat <<-EOF > $worldlistfile @@ -120,12 +124,9 @@ <option title="$d" value="$conf">$name</option> EOF } - if [ -n "$S4MASTERDB" ]; then - echo "<option value=\"s4-config.sh\">Base</option>" \ - >> $worldoptionfile - fi done if [ -s "$worldoptionfile" ]; then + echo "<option value=\"s4-config.sh\">Base</option>" >> $worldoptionfile echo "</table>$nl</div>" >> $worldlistfile else true > $worldoptionfile; true > $worldlistfile # Remove contents @@ -1968,8 +1969,9 @@ _m4 -D_TITLE_="移住操作" -D_BODYCLASS_="" $layout/html.m4.html echo "移住操作" | html h1 echo '<pre>' - # err ./s4-migrate.sh "$srcconf" "$destconf" "$rowid" - . ./s4-migrate.sh "$srcconf" "$destconf" "$rowid" + set -- "$srcconf" "$destconf" "$rowid" + err ./s4-migrate.sh "$srcconf" "$destconf" "$rowid" + . ./s4-migrate.sh # Dot(.) sourcing might not pass arguments rc=$? echo "</pre>" if [ $rc -eq 0 ]; then
--- a/s4-migrate.sh Sat Jun 13 13:16:24 2020 +0900 +++ b/s4-migrate.sh Sat Jun 13 13:19:07 2020 +0900 @@ -13,7 +13,7 @@ esac htmlworld=`echo "$world"|htmlescape` -err "--- Migration Started at `date` ---" +err "--- Migration Started with \$1=$1 \$2=$2 at `date` ---" err srcdb=$srcdb dstdb=$dstdb err URL=$URL err dstURL=$dsturl @@ -93,6 +93,7 @@ WHERE key='owner' AND val=$qgrp); EOF ) + err d2="$d2" # article d3=$(query <<-EOF SELECT * FROM main.article @@ -106,6 +107,7 @@ WHERE blogid IN ($blogs); EOF ) + err d3="$d3" if [ -z "$d1$d2$d3" ]; then echo "Copying done, rewriting article links..." echo "Old URL: $URL" @@ -120,14 +122,14 @@ EOF # Create blog-rowid conversion table sedfile=$tmpd/arttrans.sed - sedfile=tmp/arttrans.sed + # sedfile=tmp/arttrans.sed query <<-EOF > $sedfile WITH arttrans AS ( SELECT s.rowid srcrid, d.rowid dstrid FROM main.article s JOIN dst.article d ON s.id=d.id WHERE s.id in (SELECT id FROM article WHERE blogid IN ($blogs)) - ) SELECT printf("/^>/s/\#%s\([^0-9]*\)/\#%s\1/g", srcrid, dstrid) + ) SELECT printf("/^>/s/\#%s($|[ ,\#])/\#%s\1/g", srcrid, dstrid) FROM arttrans; EOF query <<-EOF > $tmpd/repl.art.rowid @@ -138,7 +140,7 @@ sql=$tmpd/update.sql for arid in `cat $tmpd/repl.art.rowid`; do newval=`query "SELECT hex(val) FROM dst.article_s WHERE rowid=$arid;" \ - | unhexize | sed -f "$sedfile" | hexize` + | unhexize | sed -Ef "$sedfile" | hexize` echo "UPDATE dst.article_s SET val=X'$newval' WHERE rowid=$arid;" >>$sql done # Rewrite blog-links in the group