source: branches/version-2_12-dev/eccube_install.sh @ 22129

Revision 22129, 5.1 KB checked in by kim, 9 years ago (diff)

#1980 インストールシェルの改造(mysql, postgresに対応、mysqlは不完全)

  • 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#
16# # ./ec_cube_install.sh mysql
17#
18#
19# 開発コミュニティの関連スレッド
20# http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=4918&forum=14&post_id=23090#forumpost23090
21#
22#######################################################################
23
24#######################################################################
25# Configuration
26#-- Shop Configuration
27CONFIG_PHP="data/config/config.php"
28ADMIN_MAIL=${ADMIN_MAIL:-"admin@example.com"}
29SHOP_NAME=${SHOP_NAME:-"EC-CUBE SHOP"}
30HTTP_URL=${HTTP_URL:-"http://test.local"}
31HTTPS_URL=${HTTPS_URL:-"http://test.local/"}
32DOMAIN_NAME=${DOMAIN_NAME:-""}
33ADMINPASS="f6b126507a5d00dbdbb0f326fe855ddf84facd57c5603ffdf7e08fbb46bd633c"
34AUTH_MAGIC="droucliuijeanamiundpnoufrouphudrastiokec"
35
36DBTYPE=$1;
37
38case "${DBTYPE}" in
39"pgsql" )
40    #-- DB Seting Postgres
41    PSQL=psql
42    PGUSER=postgres
43    DROPDB=dropdb
44    CREATEDB=createdb
45    DBSERVER="127.0.0.1"
46    DBNAME=cube212_dev
47    DBUSER=cube212_dev_user
48    DBPASS=password
49    DBPORT=5432
50;;
51"mysql" )
52    #-- DB Seting MySQL
53    MYSQL=mysql
54    ROOTUSER=root
55    ROOTPASS=arigato36
56    DBSERVER="127.0.0.1"
57    DBNAME=cube212_dev
58    DBUSER=cube212_dev_user
59    DBPASS=password
60    DBPORT=3306
61;;
62* ) echo "ERROR:: argument is invaid"
63exit
64;;
65esac
66
67
68#######################################################################
69# Install
70
71echo "PREFIX=${PREFIX}"
72echo "EC_CUBE_VERSION=${EC_CUBE_VERSION}"
73
74#-- Update Permissions
75echo "update permissions..."
76chmod -R 777 "./html"
77chmod 755 "./data"
78chmod -R 777 "./data/Smarty"
79chmod -R 777 "./data/cache"
80chmod -R 777 "./data/class"
81chmod -R 755 "./data/class_extends"
82chmod 777 "./data/config"
83chmod -R 777 "./data/download"
84chmod -R 777 "./data/downloads"
85chmod 755 "./data/fonts"
86chmod 755 "./data/include"
87chmod 777 "./data/logs"
88chmod -R 777 "./data/module"
89chmod 755 "./data/smarty_extends"
90chmod 777 "./data/upload"
91chmod 777 "./data/upload/csv"
92
93#-- Setup Database
94SQL_DIR="./html/install/sql"
95OPTIONAL_SQL_FILE=optional.sql
96if [ -f ${OPTIONAL_SQL_FILE} ]
97then
98    echo "remove optional SQL"
99    rm ${OPTIONAL_SQL_FILE}
100fi
101
102echo "create optional SQL..."
103echo "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}
104echo "INSERT INTO dtb_baseinfo (id, shop_name, email01, email02, email03, email04, email05, top_tpl, product_tpl, detail_tpl, mypage_tpl, update_date) VALUES (1, '${SHOP_NAME}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', 'default1', 'default1', 'default1', 'default1', current_timestamp);" >> ${OPTIONAL_SQL_FILE}
105
106
107case "${DBTYPE}" in
108"pgsql" )
109    # PostgreSQL
110    echo "dropdb..."
111    su ${PGUSER} -c "${DROPDB} ${DBNAME}"
112    echo "createdb..."
113    su ${PGUSER} -c "${CREATEDB} -U ${DBUSER} ${DBNAME}"
114    echo "create table..."
115    su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_table_pgsql.sql ${DBNAME}"
116    echo "insert data..."
117    su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/insert_data.sql ${DBNAME}"
118    echo "execute optional SQL..."
119    su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${OPTIONAL_SQL_FILE} ${DBNAME}"
120;;
121"mysql" )
122    # MySQL
123    echo "dropdb..."
124    ${MYSQL} -u ${ROOTUSER} -p${ROOTPASS} -e "drop database ${DBNAME}"
125    echo "createdb..."
126    ${MYSQL} -u ${ROOTUSER} -p${ROOTPASS} -e "create database ${DBNAME}"
127    #echo "grant user..."
128    #${MYSQL} -u ${ROOTUSER} -p${ROOTPASS} -e "GRANT ALL ON ${DBNAME}.* TO '${DBUSER}'@'%' IDENTIFIED BY '${DBPASS}'"
129    echo "create table..."
130    ${MYSQL} -u ${DBUSER} -p${DBPASS} ${DBNAME} < ${SQL_DIR}/create_table_mysql.sql
131    echo "insert data..."
132    ${MYSQL} -u ${DBUSER} -p${DBPASS} ${DBNAME} < ${SQL_DIR}/insert_data.sql
133    echo "execute optional SQL..."
134    ${MYSQL} -u ${DBUSER} -p${DBPASS} ${DBNAME} < ${OPTIONAL_SQL_FILE}
135;;
136esac
137
138#-- Setup Initial Data
139
140echo "copy images..."
141cp -rv "./html/install/save_image" "./html/upload/"
142
143echo "creating ${CONFIG_PHP}..."
144cat > "./${CONFIG_PHP}" <<EOF
145<?php
146define('ECCUBE_INSTALL', 'ON');
147define('HTTP_URL', '${HTTP_URL}');
148define('HTTPS_URL', '${HTTPS_URL}');
149define('ROOT_URLPATH', '/');
150define('DOMAIN_NAME', '${DOMAIN_NAME}');
151define('DB_TYPE', '${DBTYPE}');
152define('DB_USER', '${DBUSER}');
153define('DB_PASSWORD', '${DBPASS}');
154define('DB_SERVER', '${DBSERVER}');
155define('DB_NAME', '${DBNAME}');
156define('DB_PORT', '${DBPORT}');
157define('ADMIN_DIR', 'admin/');
158define('ADMIN_FORCE_SSL', FALSE);
159define('ADMIN_ALLOW_HOSTS', 'a:0:{}');
160define('AUTH_MAGIC', '${AUTH_MAGIC}');
161define('PASSWORD_HASH_ALGOS', 'sha256');
162define('MAIL_BACKEND', 'mail');
163define('SMTP_HOST', '');
164define('SMTP_PORT', '');
165define('SMTP_USER', '');
166define('SMTP_PASSWORD', '');
167
168EOF
169
170echo "Finished Successful!"
Note: See TracBrowser for help on using the repository browser.