戻る

データベース作成スクリプト

0001: #! /bin/bash
0002: #-----------------------------------------------------------#
0003: # CreateDB.sh
0004: # ===========
0005: #
0006: # データベース作成
0007: #
0008: # CreateDB.sh { <option> }
0009: # <option> : -d               DataBase  を削除する
0010: #            -r               DataBase  を再作成する
0011: #                             既定値は新規作成
0012: #            encode=UTF8      CHARACTER SET を UTF8 にする
0013: #                             既定値は EUCJ_0208
0014: #            dbpath=<path>    <path> の DBFILE を使う
0015: #                             既定値は /DB/birds/birds.fdb
0016: #            pagesize=<size>  ページサイズ
0017: #                     Fb1.5/Linux x86 で有効な値は
0018: #                     1024, 2048, 4096(default), 8192, 16384
0019: #
0020: # $Id: CreateDB.sh,v 1.12  ##########  $
0021: # ------------------------------------------------------------ #
0022: encode="DEFAULT CHARACTER SET EUCJ_0208"
0023: dbpath="/DB/birds/birds.fdb"
0024: pagesize=""
0025: while [ "${1}" != "" ]; do
0026:     [ "${1:0:1}" == "-" ] && param=${1}
0027:     [ "${1:0:7}" == "encode=" ]   && encode="DEFAULT CHARACTER SET ${1:7}"
0028:     [ "${1:0:7}" == "dbpath=" ]   && dbpath=${1:7}
0029:     [ "${1:0:9}" == "pagesize=" ] && pagesize="PAGE_SIZE ${1:9}"
0030:     [ "${1}" == "shadow" ]        && shadow=1
0031:     shift
0032: done
0033: 
0034: dbhost=${dbpath%:*}
0035: if [ "${dbhost}" == "${dbpath}" ]; then
0036:     dbhost="localhost"
0037:     dbfile=${dbpath}
0038: else
0039:     dbfile=${dbpath#*:}
0040: fi
0041: 
0042: if [ ${shadow} -eq 1 ]; then
0043:     shadowname=${dbfile%.*}.shadow
0044: fi
0045: 
0046: if [ "${param}" == "-d" ] || [ "${param}" == "-r" ]; then
0047:     echo '**** DELETE DATABASE FILE ****'
0048:     if [ "$dbhost" == "localhost" ]; then
0049:         yes | rm ${dbfile}
0050:         if [ ${shadow} ] ; then
0051:             yes | rm ${shadowname}
0052:         fi
0053:     else
0054:         ssh ${dbhost} "yes|rm ${dbfile}"
0055:     fi
0056:     [ "${param}" == "-d" ] && exit
0057: fi
0058: 
0059: echo '**** CREATE DATABASE FILE ****'
0060: isql << EOF
0061: CREATE DATABASE
0062:   '${dbpath}'
0063:   USER 'SYSDBA'
0064:   PASSWORD '********'
0065:   ${pagesize}
0066:   ${encode};
0067: COMMIT;
0068: QUIT;
0069: EOF
0070: if [ ${shadowname} ]; then
0071:     isql << EOF
0072: CONNECT ${dbpath} USER 'SYSDBA' PASSWORD '********';
0073: CREATE SHADOW 1 AUTO '${shadowname}';
0074: COMMIT;
0075: QUIT;
0076: EOF
0077: fi
0078: 
0079: exit

この HTML を検査する。( XHTML 1.0 Strict で書かれています )
Another HTML Lint Gateway ( Mirrored by htmllint.oosato.org )