s4

view s4-start.sh @ 490:e4b929e40fa8

Add feature of limiting date range of POST count
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 08 Jun 2018 09:36:21 +0900
parents 8a88212a1ee3
children 8d2a121cbc59
line source
1 #!/bin/sh
2 # 愛
3 # Start s4 - Generate s4.cgi
4 mydir=`dirname $0`
5 myname=`basename $0`
7 script_dir=${SCRIPT_DIR:-scripts}
9 ADMIN=""
10 TYPE="form1"
11 ex=examples
13 usage() {
14 cat<<EOF
15 $myname `sed -n 3p $0`
16 Usage: $myname [Options]
17 Options are as follows:
18 -h Show this help
19 -a ADM Set ADMIN email address to ADM
20 -f Force overwriting
21 -g Guestonly mode(No login required)
22 -t TYPE Construction type (defaults to $TYPE)
24 TYPEs are one of directory names in examples except \`common'.
25 EOF
26 exit 0
27 }
28 while getopts a:fght: f; do
29 case $f in
30 a) ADMIN=$OPTARG;;
31 g) guest=1;;
32 f) force=1;;
33 t) TYPE=$OPTARG;;
34 \?|h) usage; exit 1;;
35 esac
36 done
37 shift $(expr $OPTIND - 1)
39 if [ ! -d $ex/$TYPE ]; then
40 cat<<EOF 1>&2
41 Invalid type($TYPE).
42 Types are one of as follows.
43 `ls $ex|grep -v common | sed 's/^/ /'`
44 EOF
45 exit 1
46 fi
48 if [ -z "$ADMIN" ]; then
49 cat<<EOF 1>&2
50 Administrator's email not specified.
51 Please feed administrator email with \`-a' option.
52 EOF
53 exit 1
54 fi
56 if ! cd $mydir; then
57 echo "Script(s4-funcs.sh) not found in \`$mydir'." 1>&2
58 exit 1
59 fi
61 . ./s4-funcs.sh
62 if ! checkdomain $ADMIN; then
63 cat<<EOF 1>&2
64 Administrator's email - $ADMIN - is invalid(host not found).
65 Please specify existing email address.
66 EOF
67 exit 3
68 fi
70 if [ -d templ/form ]; then
71 if [ -z "$force" ]; then
72 echo "templ/ directory already exists. Remove it, then try again." 1>&2
73 exit 4
74 fi
75 rm -rf templ/*
76 fi
77 mkdir templ
78 if (cd templ && cp -r ../examples/$TYPE/* .); then
79 if ./s4-init.sh; then
80 cat<<EOF
81 -------- The s4 System Successfully Installed --------
82 EOF
83 if [ -s scripts/s4-$TYPE.case ]; then
84 casefile=scripts/s4-$TYPE.case
85 else
86 casefile=scripts/s4-default.case
87 fi
88 m4 -P -I scripts -D_SHELL_=`which sh` \
89 -D_CASE_=$casefile s4.cgi.m4 > index.cgi && chmod +x index.cgi
90 (echo "ADMIN=$ADMIN"
91 [ "$guest" ] && echo "guestonlymode=1") >> s4-config.sh
92 rc=0
93 else
94 echo Calling s4-init.sh 'FAILED!!'
95 fi
96 else
97 echo Failed
98 fi 1>&2
100 exit ${rc:-5}