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

Revision 23337, 6.6 KB checked in by kimoto, 8 years ago (diff)

#2503 postgresでNEXTVALエラーが出てしまうのでshで作成する

  • 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
132dtb_tax_rule_tax_rule_id_seq
133"
134
135echo "create optional SQL..."
136echo "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}
137echo "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}
138
139case "${DBTYPE}" in
140"pgsql" )
141    # PostgreSQL
142    echo "dropdb..."
143    sudo -u ${PGUSER} ${DROPDB} ${DBNAME}
144    echo "createdb..."
145    sudo -u ${PGUSER} ${CREATEDB} -U ${DBUSER} ${DBNAME}
146    echo "create table..."
147    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_table_pgsql.sql ${DBNAME}
148    echo "insert data..."
149    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${SQL_DIR}/insert_data.sql ${DBNAME}
150    for S in $SEQUENCES
151    do
152    echo "CREATE SEQUENCE $S START 10000;" >> ${OPTIONAL_SQL_FILE}
153    done
154    echo "execute optional SQL..."
155    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${OPTIONAL_SQL_FILE} ${DBNAME}
156;;
157"mysql" )
158    DBPASS=`echo $DBPASS | tr -d " "`
159    if [ -n ${DBPASS} ]; then
160    PASSOPT="--password=$DBPASS"
161    CONFIGPASS=$DBPASS
162    fi
163    # MySQL
164    echo "dropdb..."
165    ${MYSQL} -u ${ROOTUSER} ${PASSOPT} -e "drop database ${DBNAME}"
166    echo "createdb..."
167    ${MYSQL} -u ${ROOTUSER} ${PASSOPT} -e "create database ${DBNAME}"
168    #echo "grant user..."
169    #${MYSQL} -u ${ROOTUSER} ${PASSOPT} -e "GRANT ALL ON ${DBNAME}.* TO '${DBUSER}'@'%' IDENTIFIED BY '${DBPASS}'"
170    echo "create table..."
171    ${MYSQL} -u ${DBUSER} ${PASSOPT} ${DBNAME} < ${SQL_DIR}/create_table_mysql.sql
172    echo "insert data..."
173    ${MYSQL} -u ${DBUSER} ${PASSOPT} ${DBNAME} < ${SQL_DIR}/insert_data.sql
174    for S in $SEQUENCES
175    do
176    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}
177    done
178    echo "execute optional SQL..."
179    ${MYSQL} -u ${DBUSER} ${PASSOPT} ${DBNAME} < ${OPTIONAL_SQL_FILE}
180;;
181esac
182
183#-- Setup Initial Data
184
185echo "copy images..."
186cp -rv "./html/install/save_image" "./html/upload/"
187
188echo "creating ${CONFIG_PHP}..."
189cat > "./${CONFIG_PHP}" <<EOF
190<?php
191define('ECCUBE_INSTALL', 'ON');
192define('HTTP_URL', '${HTTP_URL}');
193define('HTTPS_URL', '${HTTPS_URL}');
194define('ROOT_URLPATH', '/');
195define('DOMAIN_NAME', '${DOMAIN_NAME}');
196define('DB_TYPE', '${DBTYPE}');
197define('DB_USER', '${DBUSER}');
198define('DB_PASSWORD', '${CONFIGPASS}');
199define('DB_SERVER', '${DBSERVER}');
200define('DB_NAME', '${DBNAME}');
201define('DB_PORT', '${DBPORT}');
202define('ADMIN_DIR', 'admin/');
203define('ADMIN_FORCE_SSL', FALSE);
204define('ADMIN_ALLOW_HOSTS', 'a:0:{}');
205define('AUTH_MAGIC', '${AUTH_MAGIC}');
206define('PASSWORD_HASH_ALGOS', 'sha256');
207define('MAIL_BACKEND', 'mail');
208define('SMTP_HOST', '');
209define('SMTP_PORT', '');
210define('SMTP_USER', '');
211define('SMTP_PASSWORD', '');
212
213EOF
214
215echo "Finished Successful!"
Note: See TracBrowser for help on using the repository browser.