source: branches/comu-ver2/eccube_install.sh @ 18364

Revision 18364, 5.5 KB checked in by nanasess, 12 years ago (diff)

PostgreSQL のユーザー名を postgres に修正

  • Property svn:keywords set to Id Revision Date
Line 
1#!/bin/sh
2
3######################################################################
4#
5# EC-CUBE の再インストールを行う shell スクリプト
6#
7# ※ PostgreSQL 専用
8#
9# 1. 既存の EC-CUBE サイトを移動(PREFIX.YYYYMMDD)
10# 2. SVNリポジトリより checkout(tags/EC_CUBE_VERSION)
11# 3. パーミッション変更
12# 4. dropdb を実行
13# 5. createdb を実行
14# 6. html/install/sql 配下の SQL を実行
15# 8. 管理者権限をアップデート
16# 9. data/install.php を生成
17#
18# 使い方
19#
20# sudo PREFIX=/install/path/to/eccube \
21#      EC_CUBE_VERSION=eccube-2.4.1 ./ec_cube_reinstall.sh
22#
23#
24#######################################################################
25
26PREFIX=${PREFIX:-"$1"}
27EC_CUBE_VERSION=${EC_CUBE_VERSION:-"$2"}
28
29ADMIN_MAIL=${ADMIN_MAIL:-"shop@ec-cube.net"}
30SHOP_NAME=${SHOP_NAME:-"ロックオンのふとんやさん"}
31INSTALL_PHP="data/install.php"
32SITE_URL=${SITE_URL:-"http://demo2.ec-cube.net/"}
33SSL_URL=${SSL_URL:-"http://demo2.ec-cube.net/"}
34DOMAIN_NAME=${DOMAIN_NAME:-""}
35
36TODAY=`date "+%Y%m%d"`
37
38SVN=svn
39SVN_USER=guest
40SVN_PASSWD=lh1jNhUn
41
42REPOSITORY="https://svn.ec-cube.net/open/tags/"
43
44PGUSER=postgres
45DROPDB=dropdb
46CREATEDB=createdb
47PSQL=psql
48
49DBSERVER="127.0.0.1"
50DBNAME=demo2_db
51DBUSER=demo2_db_user
52DBPASS=password
53DBPORT=5432
54
55OPTIONAL_SQL_FILE=optional.sql
56
57
58echo "PREFIX=${PREFIX}"
59echo "EC_CUBE_VERSION=${EC_CUBE_VERSION}"
60
61if [ -d ${PREFIX} ]
62then
63    echo "backup old version..."
64    mv ${PREFIX} "${PREFIX}.${TODAY}"
65fi
66
67if [ -f ${OPTIONAL_SQL_FILE} ]
68then
69    echo "remove optional SQL"
70    rm ${OPTIONAL_SQL_FILE}
71fi
72
73echo "checkout sources from svn.ec-cube.net..."
74${SVN} checkout --username ${SVN_USER} --password ${SVN_PASSWD} \
75    "${REPOSITORY}/${EC_CUBE_VERSION}" ${PREFIX}
76
77echo "update permissions..."
78chmod -R 777 "${PREFIX}/data/cache"
79chmod -R 777 "${PREFIX}/data/class"
80chmod -R 777 "${PREFIX}/data/Smarty"
81chmod -R 777 "${PREFIX}/data/logs"
82chmod -R 777 "${PREFIX}/data/downloads"
83chmod -R 777 "${PREFIX}/html/install/temp"
84chmod -R 777 "${PREFIX}/html/user_data"
85chmod -R 777 "${PREFIX}/html/cp"
86chmod -R 777 "${PREFIX}/html/upload"
87
88#echo "dropdb..."
89#su ${PGUSER} -c "${DROPDB} ${DBNAME}"
90
91#echo "createdb..."
92#su ${PGUSER} -c "${CREATEDB} -U ${DBUSER} ${DBNAME}"
93
94SQL_DIR="${PREFIX}/html/install/sql"
95
96echo "drop view..."
97su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/drop_view.sql ${DBNAME}"
98
99echo "drop tables..."
100su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/drop_table.sql ${DBNAME}"
101su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_session;' ${DBNAME}"
102su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_module;' ${DBNAME}"
103su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_campaign_order;' ${DBNAME}"
104su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_mobile_kara_mail;' ${DBNAME}"
105su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_mobile_ext_session_id;' ${DBNAME}"
106su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_site_control;' ${DBNAME}"
107su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_trackback;' ${DBNAME}"
108
109echo "create table..."
110su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_table_pgsql.sql ${DBNAME}"
111
112echo "create_view..."
113su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_view.sql ${DBNAME}"
114
115echo "adding table comment..."
116su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/table_comment.sql ${DBNAME}"
117
118echo "adding tables..."
119su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_campaign_order_pgsql.sql ${DBNAME}"
120su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_mobile_ext_session_id_pgsql.sql ${DBNAME}"
121su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_mobile_kara_mail_pgsql.sql ${DBNAME}"
122su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_module_pgsql.sql ${DBNAME}"
123su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_session_pgsql.sql ${DBNAME}"
124su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_site_control_pgsql.sql ${DBNAME}"
125su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_trackback_pgsql.sql ${DBNAME}"
126
127echo "insert data..."
128su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/insert_data.sql ${DBNAME}"
129
130echo "create optional SQL..."
131echo "INSERT INTO dtb_member (member_id, login_id, password, authority, creator_id) VALUES ('1', 'admin', '2c19f4a742398150cecc80b3e76b673a35b8c19c', '0', '0');" >> ${OPTIONAL_SQL_FILE}
132echo "INSERT INTO dtb_baseinfo (shop_name, email01, email02, email03, email04, email05, top_tpl, product_tpl, detail_tpl, mypage_tpl) VALUES ('${SHOP_NAME}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', '${ADMIN_MAIL}', 'default1', 'default1', 'default1', 'default1');" >> ${OPTIONAL_SQL_FILE}
133echo "execute optional SQL..."
134su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${OPTIONAL_SQL_FILE} ${DBNAME}"
135
136echo "copy images..."
137cp -rv "${PREFIX}/html/install/save_image" "${PREFIX}/html/upload/"
138
139echo "creating ${INSTALL_PHP}..."
140cat > "${PREFIX}/${INSTALL_PHP}" <<EOF
141<?php
142define ('ECCUBE_INSTALL', 'ON');
143define ('HTML_PATH', '${PREFIX}/html/');
144define ('SITE_URL', '${SITE_URL}');
145define ('SSL_URL', '${SSL_URL}');
146define ('URL_DIR', '/');
147define ('DOMAIN_NAME', '${DOMAIN_NAME}');
148define ('DB_TYPE', 'pgsql');
149define ('DB_USER', '${DBUSER}');
150define ('DB_PASSWORD', '${DBPASS}');
151define ('DB_SERVER', '${DBSERVER}');
152define ('DB_NAME', '${DBNAME}');
153define ('DB_PORT', '${DBPORT}');
154define ('DATA_PATH', '${PREFIX}/data/');
155define ('MOBILE_HTML_PATH', HTML_PATH . 'mobile/');
156define ('MOBILE_SITE_URL', SITE_URL . 'mobile/');
157define ('MOBILE_SSL_URL', SSL_URL . 'mobile/');
158define ('MOBILE_URL_DIR', URL_DIR . 'mobile/');
159?>
160EOF
161
162echo "Finished Successful!"
Note: See TracBrowser for help on using the repository browser.