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

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

処理フローを修正

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