annotate s4-newworld.sh @ 996:a50f5b0b2c3d draft

Media player built in viewer box
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 16 Oct 2022 07:56:34 +0859
parents edd96c59c8a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1 #!/bin/ksh
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
2 #!/bin/sh
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3 # Create New Wolrd in s4
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
4 # Arguments:
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
5 # $1 = World Display Name in UTF-8
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
6 # $2 = World ShortName in alpha-numeric
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
7 # $3 = World Description in UTF-8
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
8 dispname=$1
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
9 shortname=$2
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
10 desc=$3
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
11
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
12 readvar() { # $1=varname $2=PromptString
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
13 echo -n "${2:-$1=:} "
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
14 read $1
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
15 }
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
16
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
17 if [ -z "$HTTP_HOST" ]; then
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
18 while true; do
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
19 dispname=`echo $dispname | tr -d ': \t\n"' | fold -w 28 | head -1`
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
20 test -n "$dispname" && break
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
21 readvar dispname "分かりやすいWorld名14字以内"
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
22 done
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
23 while true; do
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
24 shortname=`echo $shortname | tr -c -d '_0-9A-Za-z.-' | colrm 11`
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
25 test -n "$shortname" && break
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
26 readvar shortname "英数字のみ10字以内のWorldシンボル(URLの一部)"
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
27 done
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
28 while true; do
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
29 desc=`echo $desc | tr -d ': \t\n"'`
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
30 test -n "$desc" && break
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
31 readvar desc "概要(どのような基準でこのWorldを使うかなど)"
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
32 done
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
33 fi
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
34 echo "wl=$S4WORLDLIST"
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
35 echo "$dispname:$shortname:$desc"
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
36 # Create config
965
b6d1384e1b2c s4-newworld fixed so that account sychronization done at the time
HIROSE Yuuji <yuuji@gentei.org>
parents: 940
diff changeset
37 S4INITDB=db/$shortname.sq3; export S4INITDB
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
38 `dirname $0`/s4-init.sh
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
39 . `dirname $0`/s4-config.sh
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
40 if ! type htmlescape >/dev/null 2>&1; then
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
41 . `dirname $0`/s4-funcs.sh ### > /dev/null 2>&1
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
42 trap 'exit 1' INT QUIT
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
43 fi
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
44
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
45 newworld=$(
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
46 { echo $S4WORLDLIST | tr ' ' '\n' \
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
47 | awk -F: "\$2 != \"$shortname\"{print}"
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
48 echo "$dispname:$shortname:$desc"
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
49 } | tr '\n' ' ' | sed 's/ $//' | tr -d '"'
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
50 )
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
51 if [ -z "$newworld" ]; then
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
52 exit
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
53 fi
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
54
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
55 masterdb=`(unset DB; . ./s4-config.sh; echo $DB)`
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
56 S4MASTERDB=${masterdb:-db/cgi.sq3}
965
b6d1384e1b2c s4-newworld fixed so that account sychronization done at the time
HIROSE Yuuji <yuuji@gentei.org>
parents: 940
diff changeset
57 DB=$newdb; export DB
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
58 echo Synching account: db=$db URL=$URL isCGI=$isCGI mas=$S4MASTERDB
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
59 . ./s4-world.sh && syncaccount 'force'
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
60 echo Synching done
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
61 bgcolor=$(
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
62 od -An -tu1 -N3 < /dev/urandom \
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
63 | { read r g b
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
64 r=$((192+r/4)); g=$((192+g/4)); b=$((192+b/4))
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
65 printf "#%x%x%x" $r $g $b
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
66 })
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
67 cat<<-EOF > s4-config-$shortname.sh
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
68 S4MASTERURL=\$URL
785
1f310d682c07 Treat dirname of path/of/url/ as itself
HIROSE Yuuji <yuuji@gentei.org>
parents: 771
diff changeset
69 URL=`dirname ${URL}.`/s4-world-$shortname$cgiext
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
70 S4COLOR="$bgcolor" # Change this!
968
edd96c59c8a2 Fix reference of S4MASTERDB
HIROSE Yuuji <yuuji@gentei.org>
parents: 965
diff changeset
71 S4MASTERDB=$S4MASTERDB # master database
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
72 DB=$dbdir/$shortname.sq3
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
73 S4CSS=$shortname.css
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
74 TMPDIR=$tmpdir/$shortname
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
75 EOF
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
76 # Create CSS
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
77 cat<<-EOF > $shortname.css
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
78 body {background: $bgcolor;}
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
79 body.moderated {background: $bgcolor; border: 3px gold solid;}
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
80 EOF
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
81 mkdir -m 1775 $tmpdir/$shortname
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
82 # Update s4-config.sh
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
83 cat<<-EOF | ed s4-config.sh
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
84 g/^S4WORLDLIST=/d
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
85 wq
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
86 EOF
817
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
87 echo "S4WORLDLIST=\"$newworld\"" >> s4-config.sh
d2c4c473e08e Account synchronization more prudent
HIROSE Yuuji <yuuji@gentei.org>
parents: 791
diff changeset
88
771
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
89 (cd `dirname $0`; ln -s s4$cgiext s4-world-$shortname$cgiext)
b97f1c84bdb1 New script s4-newworld supports NewWorld creation
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
90 echo $newworld added

yatex.org