s4

view s4-start.sh @ 84:e16cb89bb0f2

Write ADMIN to s4-config.sh
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 03 Aug 2015 12:51:06 +0900
parents db489961e461
children 465447d8b3ab
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 -t TYPE Force overwriting (defaults to $type)
23 TYPEs are one of directory names in examples except \`common'.
24 EOF
25 exit 0
26 }
27 while getopts afht: f; do
28 case $f in
29 a) admin=$OPTARG;;
30 f) force=1;;
31 t) type=$OPTARG;;
32 \?|h) usage; exit 1;;
33 esac
34 done
35 shift $(expr $OPTIND - 1)
37 if [ ! -d $ex/$type ]; then
38 cat<<EOF 1>&2
39 Invalid type($type).
40 Types are one of as follows.
41 `ls $ex|grep -v common | sed 's/^/ /'`
42 EOF
43 exit 1
44 fi
46 if [ -z "$admin" ]; then
47 cat<<EOF 1>&2
48 Administrator's email not specified.
49 Please feed administrator email with \`-a' option.
50 EOF
51 exit 1
52 fi
54 if ! cd $mydir; then
55 echo "Script(s4-funcs.sh) not found in \`$mydir'." 1>&2
56 exit 1
57 fi
59 . ./s4-funcs.sh || exit 2
60 if ! checkdomain $admin; then
61 cat<<EOF 1>&2
62 Administrator's email - $admin - is invalid(host not found).
63 Please specify existing email address.
64 EOF
65 exit 3
66 fi
68 if [ -d templ/form ]; then
69 if [ -z "$force" ]; then
70 echo "templ/ directory already exists. Remove it, then try again." 1>&2
71 exit 4
72 fi
73 rm -rf templ/*
74 fi
75 mkdir templ
76 if (cd templ && ln -s ../examples/$type/* .); then
77 if ./s4-init.sh; then
78 cat<<EOF
79 -------- The s4 System Successfully Installed --------
80 EOF
81 echo "ADMIN=$admin" >> s4-config.sh && rc=0
82 else
83 echo Calling s4-init.sh 'FAILED!!'
84 fi
85 else
86 echo Failed
87 fi 1>&2
89 exit ${rc:-5}