Mercurial > hgrepos > hgweb.cgi > s4
annotate s4-start.sh @ 970:10803d78f07c draft
Create tmp/
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 22 May 2022 12:18:08 +0900 |
parents | 4f66dc71ad2a |
children | 0ac251f04f21 |
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` |
541
4f66dc71ad2a
Default password rule fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
538
diff
changeset
|
6 dp="password" |
4f66dc71ad2a
Default password rule fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
538
diff
changeset
|
7 # Default password: "$dp of $ADMIN" |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
8 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
9 script_dir=${SCRIPT_DIR:-scripts} |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
10 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
11 ADMIN="" |
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
12 TYPE="form1" |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
13 ex=examples |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
14 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
15 usage() { |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
16 cat<<EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
17 $myname `sed -n 3p $0` |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
18 Usage: $myname [Options] |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
19 Options are as follows: |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
20 -h Show this help |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
21 -a ADM Set ADMIN email address to ADM |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
22 -f Force overwriting |
88 | 23 -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
|
24 -t TYPE Construction type (defaults to $TYPE) |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
25 -w Create CGI wrapper |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
26 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
27 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
|
28 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
29 exit 0 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
30 } |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
31 while getopts a:fght:w f; do |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
32 case $f in |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
33 a) ADMIN=$OPTARG;; |
87 | 34 g) guest=1;; |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
35 f) force=1;; |
521
356320f803dc
Option "-w" enables CGI wrapper
HIROSE Yuuji <yuuji@gentei.org>
parents:
519
diff
changeset
|
36 w) wrap=1;; |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
37 t) TYPE=$OPTARG;; |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
38 \?|h) usage; exit 1;; |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
39 esac |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
40 done |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
41 shift $(expr $OPTIND - 1) |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
42 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
43 if [ ! -d $ex/$TYPE ]; then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
44 cat<<EOF 1>&2 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
45 Invalid type($TYPE). |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
46 Types are one of as follows. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
47 `ls $ex|grep -v common | sed 's/^/ /'` |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
48 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
49 exit 1 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
50 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
51 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
52 if [ -z "$ADMIN" ]; then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
53 cat<<EOF 1>&2 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
54 Administrator's email not specified. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
55 Please feed administrator email with \`-a' option. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
56 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
57 exit 1 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
58 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
59 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
60 if ! cd $mydir; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
61 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
|
62 exit 1 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
63 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
64 |
88 | 65 . ./s4-funcs.sh |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
66 if ! checkdomain $ADMIN; then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
67 cat<<EOF 1>&2 |
86
518e3afcb230
add examples/form-text+img/form/memo.def
HIROSE Yuuji <yuuji@gentei.org>
parents:
85
diff
changeset
|
68 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
|
69 Please specify existing email address. |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
70 EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
71 exit 3 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
72 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
73 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
74 if [ -d templ/form ]; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
75 if [ -z "$force" ]; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
76 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
|
77 exit 4 |
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 rm -rf templ/* |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
80 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
81 mkdir templ |
970 | 82 test -d tmp || mkdir -m 1750 tmp |
104 | 83 if (cd templ && cp -r ../examples/$TYPE/* .); then |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
84 if ./s4-init.sh; then |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
85 cat<<EOF |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
86 -------- The s4 System Successfully Installed -------- |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
87 EOF |
110 | 88 if [ -s scripts/s4-$TYPE.case ]; then |
89 casefile=scripts/s4-$TYPE.case | |
107 | 90 else |
110 | 91 casefile=scripts/s4-default.case |
107 | 92 fi |
96 | 93 m4 -P -I scripts -D_SHELL_=`which sh` \ |
524 | 94 -D__NOEDIT__="DO NOT EDIT THIS FILE MANUALLY -> scripts/s4-*.case" \ |
107 | 95 -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
|
96 if [ "$wrap" ]; then |
9060df7f079b
Move index.cgi before comparison
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
97 mv -f index.cgi s4.cgi |
9060df7f079b
Move index.cgi before comparison
HIROSE Yuuji <yuuji@gentei.org>
parents:
521
diff
changeset
|
98 fi |
87 | 99 (echo "ADMIN=$ADMIN" |
526 | 100 echo "S4TYPE=$TYPE" |
95 | 101 [ "$guest" ] && echo "guestonlymode=1") >> s4-config.sh |
530 | 102 sqlite3 -cmd "pragma FOREIGH_KEYS=ON" $db \ |
528 | 103 "REPLACE INTO user VALUES('$ADMIN');" |
541
4f66dc71ad2a
Default password rule fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
538
diff
changeset
|
104 dbsetbyid user "$ADMIN" pswd "`echo $dp of $ADMIN|mypwhash`" |
519
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
105 cat > .htaccess <<-EOF |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
106 DirectoryIndex index.cgi |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
107 AddHandler cgi-script .cgi |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
108 EOF |
526 | 109 if [ -n "$wrap" ]; then |
529 | 110 type cc >/dev/null 2>&1 && CC=cc |
519
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
111 ${CC:-gcc} -o index.cgi pwrap.c \ |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
112 && chmod u+s index.cgi \ |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
113 && rc=0 |
8d2a121cbc59
Add wrapper creation process
HIROSE Yuuji <yuuji@gentei.org>
parents:
110
diff
changeset
|
114 fi |
82
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
115 else |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
116 echo Calling s4-init.sh 'FAILED!!' |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
117 fi |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
118 else |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
119 echo Failed |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
120 fi 1>&2 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
121 |
db489961e461
Installer script - sr-start.sh - added
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff
changeset
|
122 exit ${rc:-5} |