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

Revision 22143, 5.3 KB checked in by kim, 8 years ago (diff)

#1980 インストールシェルのpostgresをsu からsudo 実行に修正

  • 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:-""}
36ADMINPASS="f6b126507a5d00dbdbb0f326fe855ddf84facd57c5603ffdf7e08fbb46bd633c"
37AUTH_MAGIC="droucliuijeanamiundpnoufrouphudrastiokec"
38
39DBTYPE=$1;
40
41case "${DBTYPE}" in
42"pgsql" )
43    #-- DB Seting Postgres
44    PSQL=psql
45    PGUSER=postgres
46    DROPDB=dropdb
47    CREATEDB=createdb
48    DBSERVER="127.0.0.1"
49    DBNAME=cube212_dev
50    DBUSER=cube212_dev_user
51    DBPASS=password
52    DBPORT=5432
53;;
54"mysql" )
55    #-- DB Seting MySQL
56    MYSQL=mysql
57    ROOTUSER=root
58    ROOTPASS=password
59    DBSERVER="127.0.0.1"
60    DBNAME=cube212_dev
61    DBUSER=cube212_dev_user
62    DBPASS=password
63    DBPORT=3306
64;;
65* ) echo "ERROR:: argument is invaid"
66exit
67;;
68esac
69
70
71#######################################################################
72# Install
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    sudo -u ${PGUSER} ${DROPDB} ${DBNAME}
112    echo "createdb..."
113    sudo -u ${PGUSER} ${CREATEDB} -U ${DBUSER} ${DBNAME}
114    echo "create table..."
115    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_table_pgsql.sql ${DBNAME}
116    echo "insert data..."
117    sudo -u ${PGUSER} ${PSQL} -U ${DBUSER} -f ${SQL_DIR}/insert_data.sql ${DBNAME}
118    echo "execute optional SQL..."
119    sudo -u ${PGUSER} ${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.