Mercurial > hgrepos > hgweb.cgi > s4
annotate s4-start.sh @ 522:9060df7f079b
Move index.cgi before comparison
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 06 Apr 2019 17:42:41 +0900 |
parents | 356320f803dc |
children | 9cf0b6b7bb90 |
rev | line source |
---|---|
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
1 #!/bin/sh |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
2 # 愛 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
3 # Start s4 - Generate s4.cgi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
4 mydir=`dirname $0` |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
5 myname=`basename $0` |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
6 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
7 script_dir=${SCRIPT_DIR:-scripts} |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
8 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
9 ADMIN="" |
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
10 TYPE="form1" |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
11 ex=examples |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
12 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
13 usage() { |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
14 cat<<EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
15 $myname `sed -n 3p $0` |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
16 Usage: $myname [Options] |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
17 Options are as follows: |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
18 -h Show this help |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
19 -a ADM Set ADMIN email address to ADM |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
20 -f Force overwriting |
88 | 21 -g Guestonly mode(No login required) |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
22 -t TYPE Construction type (defaults to $TYPE) |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
23 -w Create CGI wrapper |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
24 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
25 TYPEs are one of directory names in examples except \`common'. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
26 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
27 exit 0 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
28 } |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
29 while getopts a:fght:w f; do |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
30 case $f in |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
31 a) ADMIN=$OPTARG;; |
87 | 32 g) guest=1;; |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
33 f) force=1;; |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
34 w) wrap=1;; |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
35 t) TYPE=$OPTARG;; |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
36 \?|h) usage; exit 1;; |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
37 esac |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
38 done |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
39 shift $(expr $OPTIND - 1) |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
40 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
41 if [ ! -d $ex/$TYPE ]; then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
42 cat<<EOF 1>&2 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
43 Invalid type($TYPE). |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
44 Types are one of as follows. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
45 `ls $ex|grep -v common | sed 's/^/ /'` |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
46 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
47 exit 1 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
48 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
49 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
50 if [ -z "$ADMIN" ]; then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
51 cat<<EOF 1>&2 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
52 Administrator's email not specified. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
53 Please feed administrator email with \`-a' option. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
54 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
55 exit 1 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
56 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
57 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
58 if ! cd $mydir; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
59 echo "Script(s4-funcs.sh) not found in \`$mydir'." 1>&2 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
60 exit 1 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
61 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
62 |
88 | 63 . ./s4-funcs.sh |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
64 if ! checkdomain $ADMIN; then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
65 cat<<EOF 1>&2 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
66 Administrator's email - $ADMIN - is invalid(host not found). |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
67 Please specify existing email address. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
68 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
69 exit 3 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
70 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
71 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
72 if [ -d templ/form ]; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
73 if [ -z "$force" ]; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
74 echo "templ/ directory already exists. Remove it, then try again." 1>&2 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
75 exit 4 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
76 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
77 rm -rf templ/* |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
78 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
79 mkdir templ |
104 | 80 if (cd templ && cp -r ../examples/$TYPE/* .); then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
81 if ./s4-init.sh; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
82 cat<<EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
83 -------- The s4 System Successfully Installed -------- |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
84 EOF |
110 | 85 if [ -s scripts/s4-$TYPE.case ]; then |
86 casefile=scripts/s4-$TYPE.case | |
107 | 87 else |
110 | 88 casefile=scripts/s4-default.case |
107 | 89 fi |
96 | 90 m4 -P -I scripts -D_SHELL_=`which sh` \ |
107 | 91 -D_CASE_=$casefile s4.cgi.m4 > index.cgi && chmod +x index.cgi |
522
9060df7f079b
Move index.cgi before comparison
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
92 if [ "$wrap" ]; then |
9060df7f079b
Move index.cgi before comparison
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
93 mv -f index.cgi s4.cgi |
9060df7f079b
Move index.cgi before comparison
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
94 fi |
87 | 95 (echo "ADMIN=$ADMIN" |
95 | 96 [ "$guest" ] && echo "guestonlymode=1") >> s4-config.sh |
519
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
97 sq $db "REPLACE INTO user VALUES('$ADMIN');" |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
98 cat > .htaccess <<-EOF |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
99 DirectoryIndex index.cgi |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
100 AddHandler cgi-script .cgi |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
101 EOF |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
102 if [ -n "$wrap" -a pwrap.c -nt index.cgi ]; then |
519
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
103 ${CC:-gcc} -o index.cgi pwrap.c \ |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
104 && chmod u+s index.cgi \ |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
105 && rc=0 |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
106 fi |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
107 else |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
108 echo Calling s4-init.sh 'FAILED!!' |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
109 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
110 else |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
111 echo Failed |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
112 fi 1>&2 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
113 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
114 exit ${rc:-5} |