s4

diff s4-newworld.sh @ 917:070e933c7896

Calling gs silently
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 08 Jan 2021 19:34:27 +0900
parents 567980314463
children 102c2b14c5d8
line diff
     1.1 --- a/s4-newworld.sh	Sat Jun 13 17:31:27 2020 +0900
     1.2 +++ b/s4-newworld.sh	Fri Jan 08 19:34:27 2021 +0900
     1.3 @@ -5,11 +5,6 @@
     1.4  #   $1 = World Display Name in UTF-8
     1.5  #   $2 = World ShortName in alpha-numeric
     1.6  #   $3 = World Description in UTF-8
     1.7 -. `dirname $0`/s4-config.sh
     1.8 -if ! type htmlescape >/dev/null 2>&1; then
     1.9 -  . `dirname $0`/s4-funcs.sh ### > /dev/null 2>&1
    1.10 -  trap 'exit 1' INT QUIT
    1.11 -fi
    1.12  dispname=$1
    1.13  shortname=$2
    1.14  desc=$3
    1.15 @@ -19,8 +14,7 @@
    1.16    read $1
    1.17  }
    1.18  
    1.19 -echo db=$db URL=$URL isCGI=$isCGI
    1.20 -if ! $isCGI; then
    1.21 +if [ -z "$HTTP_HOST" ]; then
    1.22    while true; do
    1.23      dispname=`echo $dispname | tr -d ': \t\n"' | fold -w 28 | head -1`
    1.24      test -n "$dispname" && break
    1.25 @@ -39,17 +33,30 @@
    1.26  fi
    1.27  echo "wl=$S4WORLDLIST"
    1.28  echo "$dispname:$shortname:$desc"
    1.29 +# Create config
    1.30 +DB=db/$shortname.sq3; export DB
    1.31 +`dirname $0`/s4-init.sh
    1.32 +. `dirname $0`/s4-config.sh
    1.33 +if ! type htmlescape >/dev/null 2>&1; then
    1.34 +  . `dirname $0`/s4-funcs.sh ### > /dev/null 2>&1
    1.35 +  trap 'exit 1' INT QUIT
    1.36 +fi
    1.37 +
    1.38  newworld=$(
    1.39 -  { echo "$S4WORLDLIST" | tr ' ' '\n' \
    1.40 +  { echo $S4WORLDLIST | tr ' ' '\n' \
    1.41        | awk -F: "\$2 != \"$shortname\"{print}"
    1.42      echo "$dispname:$shortname:$desc"
    1.43 -  } | tr '\n' ' ' | tr -d '"'
    1.44 +  } | tr '\n' ' ' | sed 's/ $//' | tr -d '"'
    1.45  	)
    1.46  if [ -z "$newworld" ]; then
    1.47    exit
    1.48  fi
    1.49  
    1.50 -# Create config
    1.51 +masterdb=`(unset DB; . ./s4-config.sh; echo $DB)`
    1.52 +S4MASTERDB=${masterdb:-db/cgi.sq3}
    1.53 +echo Synching account: db=$db URL=$URL isCGI=$isCGI mas=$S4MASTERDB
    1.54 +. ./s4-world.sh && syncaccount 'force'
    1.55 +echo Synching done
    1.56  bgcolor=$(
    1.57    od -An -tu1 -N3 < /dev/urandom \
    1.58      | { read r g b
    1.59 @@ -75,12 +82,9 @@
    1.60  # Update s4-config.sh
    1.61  cat<<-EOF | ed s4-config.sh
    1.62  	g/^S4WORLDLIST=/d
    1.63 -	\$a
    1.64 -	S4WORLDLIST="`echo $newworld`"
    1.65 -	.
    1.66  	wq
    1.67  EOF
    1.68 -DB=db/$shortname.sq3 `dirname $0`/s4-init.sh
    1.69 -(S4MASTERDB=$db; db=db/$shortname.sq3; . ./s4-world.sh)
    1.70 +echo "S4WORLDLIST=\"$newworld\"" >> s4-config.sh
    1.71 +
    1.72  (cd `dirname $0`; ln -s s4$cgiext s4-world-$shortname$cgiext)
    1.73  echo $newworld added