source: branches/version-2_13-dev/eccube_install.sh @ 22847

Revision 22847, 6.5 KB checked in by nanasess, 8 years ago (diff)

#150 (ユニットテスト環境の整備)

  • カラム修正
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
Line 
1#!/bin/sh
2
3######################################################################
4#
5# EC-CUBE のインストールを行う shell スクリプト
6#
7#
8# #処理内容
9# 1. パーミッション変更
10# 2. html/install/sql 配下の SQL を実行
11# 3. 管理者権限をアップデート
12# 4. data/config/config.php を生成
13#
14# 使い方
15# Configurationの内容を自分の環境に併せて修正
16# PostgreSQLの場合は、DBユーザーを予め作成しておいて
17# # ./ec_cube_install.sh pgsql
18# MySQLはMYSQLのRoot以外のユーザーで実行する場合は、128行目をコメントアウトして
19# # ./ec_cube_install.sh mysql
20#
21#
22# 開発コミュニティの関連スレッド
23# http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=4918&forum=14&post_id=23090#forumpost23090
24#
25#######################################################################
26
27#######################################################################
28# Configuration
29#-- Shop Configuration
30CONFIG_PHP="data/config/config.php"
31ADMIN_MAIL=${ADMIN_MAIL:-"admin@example.com"}
32SHOP_NAME=${SHOP_NAME:-"EC-CUBE SHOP"}
33HTTP_URL=${HTTP_URL:-"http://test.local"}
34HTTPS_URL=${HTTPS_URL:-"http://test.local/"}
35DOMAIN_NAME=${DOMAIN_NAME:-""}
36
37DBSERVER=${DBSERVER-"127.0.0.1"}
38DBNAME=${DBNAME:-"cube213_dev"}
39DBUSER=${DBUSER:-"cube213_dev_user"}
40DBPASS=${DBPASS:-"password"}
41
42ADMINPASS="f6b126507a5d00dbdbb0f326fe855ddf84facd57c5603ffdf7e08fbb46bd633c"
43AUTH_MAGIC="droucliuijeanamiundpnoufrouphudrastiokec"
44
45DBTYPE=$1;
46
47case "${DBTYPE}" in
48"pgsql" )
49    #-- DB Seting Postgres
50    PSQL=psql
51    PGUSER=postgres
52    DROPDB=dropdb
53    CREATEDB=createdb
54    DBPORT=5432
55;;
56"mysql" )
57    #-- DB Seting MySQL
58    MYSQL=mysql
59    ROOTUSER=root
60    ROOTPASS=$DBPASS
61    DBSERVER="127.0.0.1"
62    DBPORT=3306
63;;
64* ) echo "ERROR:: argument is invaid"
65exit
66;;
67esac
68
69
70#######################################################################
71# Install
72
73#-- Update Permissions
74echo "update permissions..."
75chmod -R go+w "./html"
76chmod go+w "./data"
77chmod -R go+w "./data/Smarty"
78chmod -R go+w "./data/cache"
79chmod -R go+w "./data/class"
80chmod -R go+w "./data/class_extends"
81chmod go+w "./data/config"
82chmod -R go+w "./data/download"
83chmod -R go+w "./data/downloads"
84chmod go+w "./data/fonts"
85chmod go+w "./data/include"
86chmod go+w "./data/logs"
87chmod -R go+w "./data/module"
88chmod go+w "./data/smarty_extends"
89chmod go+w "./data/upload"
90chmod go+w "./data/upload/csv"
91
92#-- Setup Database
93SQL_DIR="./html/install/sql"
94OPTIONAL_SQL_FILE=optional.sql
95if [ -f ${OPTIONAL_SQL_FILE} ]
96then
97    echo "remove optional SQL"
98    rm ${OPTIONAL_SQL_FILE}
99fi
100
101SEQUENCES="
102dtb_best_products_best_id_seq
103dtb_bloc_bloc_id_seq
104dtb_category_category_id_seq
105dtb_class_class_id_seq
106dtb_classcategory_classcategory_id_seq
107dtb_csv_no_seq
108dtb_csv_sql_sql_id_seq
109dtb_customer_customer_id_seq
110dtb_deliv_deliv_id_seq
111dtb_holiday_holiday_id_seq
112dtb_kiyaku_kiyaku_id_seq
113dtb_mail_history_send_id_seq
114dtb_maker_maker_id_seq
115dtb_member_member_id_seq
116dtb_module_update_logs_log_id_seq
117dtb_news_news_id_seq
118dtb_order_order_id_seq
119dtb_order_detail_order_detail_id_seq
120dtb_other_deliv_other_deliv_id_seq
121dtb_pagelayout_page_id_seq
122dtb_payment_payment_id_seq
123dtb_products_class_product_class_id_seq
124dtb_products_product_id_seq
125dtb_review_review_id_seq
126dtb_send_history_send_id_seq
127dtb_mailmaga_template_template_id_seq
128dtb_plugin_plugin_id_seq
129dtb_plugin_hookpoint_plugin_hookpoint_id_seq
130dtb_api_config_api_config_id_seq
131dtb_api_account_api_account_id_seq
132"
133
134echo "create optional SQL..."
135echo "INSERT INTO dtb_member (member_id, login_id, password, salt, work, del_flg, authority, creator_id, rank, update_date) VALUES (2, 'admin', '${ADMINPASS}', '${AUTH_MAGIC}', '1', '0', '0', '0', '1', current_timestamp);" >> ${OPTIONAL_SQL_FILE}
136echo "INSERT INTO dtb_baseinfo (id, shop_name, email01, email02, email03, email04, top_tpl, product_tpl, detail_tpl, mypage_tpl, update_date) VALUES (1, '${SHOP_NAME}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', 'default1', 'default1', 'default1', 'default1', current_timestamp);" >> ${OPTIONAL_SQL_FILE}
137
138case "${DBTYPE}" in
139"pgsql" )
140    # PostgreSQL
141    echo "dropdb..."
142    sudo -u ${PGUSER} ${DROPDB} ${DBNAME}
143    echo "createdb..."
144    sudo -u ${PGUSER} ${CREATEDB} -U ${DBUSER} ${DBNAME}
145    echo "create table..."
146    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_table_pgsql.sql ${DBNAME}
147    echo "insert data..."
148    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${SQL_DIR}/insert_data.sql ${DBNAME}
149    for S in $SEQUENCES
150    do
151    echo "CREATE SEQUENCE $S START 10000;" >> ${OPTIONAL_SQL_FILE}
152    done
153    echo "execute optional SQL..."
154    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${OPTIONAL_SQL_FILE} ${DBNAME}
155;;
156"mysql" )
157    DBPASS=`echo $DBPASS | tr -d " "`
158    if [ -n ${DBPASS} ]; then
159    PASSOPT="--password=$DBPASS"
160    CONFIGPASS=$DBPASS
161    fi
162    # MySQL
163    echo "dropdb..."
164    ${MYSQL} -u ${ROOTUSER} ${PASSOPT} -e "drop database ${DBNAME}"
165    echo "createdb..."
166    ${MYSQL} -u ${ROOTUSER} ${PASSOPT} -e "create database ${DBNAME}"
167    #echo "grant user..."
168    #${MYSQL} -u ${ROOTUSER} ${PASSOPT} -e "GRANT ALL ON ${DBNAME}.* TO '${DBUSER}'@'%' IDENTIFIED BY '${DBPASS}'"
169    echo "create table..."
170    ${MYSQL} -u ${DBUSER} ${PASSOPT} ${DBNAME} < ${SQL_DIR}/create_table_mysql.sql
171    echo "insert data..."
172    ${MYSQL} -u ${DBUSER} ${PASSOPT} ${DBNAME} < ${SQL_DIR}/insert_data.sql
173    for S in $SEQUENCES
174    do
175    echo "CREATE TABLE $S ( sequence int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (sequence)) ENGINE=MyISAM DEFAULT CHARSET=utf8; LOCK TABLES $S WRITE; INSERT INTO $S VALUES (10000); UNLOCK TABLES;" >> ${OPTIONAL_SQL_FILE}
176    done
177    echo "execute optional SQL..."
178    ${MYSQL} -u ${DBUSER} ${PASSOPT} ${DBNAME} < ${OPTIONAL_SQL_FILE}
179;;
180esac
181
182#-- Setup Initial Data
183
184echo "copy images..."
185cp -rv "./html/install/save_image" "./html/upload/"
186
187echo "creating ${CONFIG_PHP}..."
188cat > "./${CONFIG_PHP}" <<EOF
189<?php
190define('ECCUBE_INSTALL', 'ON');
191define('HTTP_URL', '${HTTP_URL}');
192define('HTTPS_URL', '${HTTPS_URL}');
193define('ROOT_URLPATH', '/');
194define('DOMAIN_NAME', '${DOMAIN_NAME}');
195define('DB_TYPE', '${DBTYPE}');
196define('DB_USER', '${DBUSER}');
197define('DB_PASSWORD', '${CONFIGPASS}');
198define('DB_SERVER', '${DBSERVER}');
199define('DB_NAME', '${DBNAME}');
200define('DB_PORT', '${DBPORT}');
201define('ADMIN_DIR', 'admin/');
202define('ADMIN_FORCE_SSL', FALSE);
203define('ADMIN_ALLOW_HOSTS', 'a:0:{}');
204define('AUTH_MAGIC', '${AUTH_MAGIC}');
205define('PASSWORD_HASH_ALGOS', 'sha256');
206define('MAIL_BACKEND', 'mail');
207define('SMTP_HOST', '');
208define('SMTP_PORT', '');
209define('SMTP_USER', '');
210define('SMTP_PASSWORD', '');
211
212EOF
213
214echo "Finished Successful!"
Note: See TracBrowser for help on using the repository browser.