Changeset 22129


Ignore:
Timestamp:
2012/12/11 19:43:31 (11 years ago)
Author:
kim
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/eccube_install.sh

    r20319 r22129  
    33###################################################################### 
    44# 
    5 # EC-CUBE のインストールを行う shell スクリプト 
     5# EC-CUBE のインストールを行う shell スクリプト 
    66# 
    7 # ※ PostgreSQL 専用 
    87# 
    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 を生成 
     8# #処理内容 
     9# 1. パーミッション変更 
     10# 2. html/install/sql 配下の SQL を実行 
     11# 3. 管理者権限をアップデート 
     12# 4. data/config/config.php を生成 
    1513# 
    1614# 使い方 
    1715# 
    18 # # ./ec_cube_install.sh /install/path/to/eccube eccube-2.4.1 
     16# # ./ec_cube_install.sh mysql 
    1917# 
    20 # この場合の DocumentRoot は, /install/path/to/eccube/html になります. 
    2118# 
    2219# 開発コミュニティの関連スレッド 
     
    2522####################################################################### 
    2623 
    27 PREFIX=${PREFIX:-"$1"} 
    28 EC_CUBE_VERSION=${EC_CUBE_VERSION:-"$2"} 
     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" 
    2935 
    30 ADMIN_MAIL=${ADMIN_MAIL:-"shop@ec-cube.net"} 
    31 SHOP_NAME=${SHOP_NAME:-"ロックオンのふとんやさん"} 
    32 INSTALL_PHP="data/install.php" 
    33 SITE_URL=${SITE_URL:-"http://demo2.ec-cube.net/"} 
    34 SSL_URL=${SSL_URL:-"http://demo2.ec-cube.net/"} 
    35 DOMAIN_NAME=${DOMAIN_NAME:-""} 
     36DBTYPE=$1; 
    3637 
    37 TODAY=`date "+%Y%m%d"` 
     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 
    3866 
    39 SVN=svn 
    40 SVN_USER=guest 
    41 SVN_PASSWD=lh1jNhUn 
    4267 
    43 REPOSITORY="https://svn.ec-cube.net/open/tags/" 
    44  
    45 PGUSER=postgres 
    46 DROPDB=dropdb 
    47 CREATEDB=createdb 
    48 PSQL=psql 
    49  
    50 DBSERVER="127.0.0.1" 
    51 DBNAME=demo2_db 
    52 DBUSER=demo2_db_user 
    53 DBPASS=password 
    54 DBPORT=5432 
    55  
    56 OPTIONAL_SQL_FILE=optional.sql 
    57  
     68####################################################################### 
     69# Install  
    5870 
    5971echo "PREFIX=${PREFIX}" 
    6072echo "EC_CUBE_VERSION=${EC_CUBE_VERSION}" 
    6173 
    62 if [ -d ${PREFIX} ] 
    63 then 
    64     echo "backup old version..." 
    65     mv ${PREFIX} "${PREFIX}.${TODAY}" 
    66 fi 
     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" 
    6792 
     93#-- Setup Database 
     94SQL_DIR="./html/install/sql" 
     95OPTIONAL_SQL_FILE=optional.sql 
    6896if [ -f ${OPTIONAL_SQL_FILE} ] 
    6997then 
     
    72100fi 
    73101 
    74 echo "checkout sources from svn.ec-cube.net..." 
    75 ${SVN} checkout --username ${SVN_USER} --password ${SVN_PASSWD} \ 
    76     "${REPOSITORY}/${EC_CUBE_VERSION}" ${PREFIX} 
     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} 
    77105 
    78 echo "update permissions..." 
    79 chmod -R 777 "${PREFIX}/data/cache" 
    80 chmod -R 777 "${PREFIX}/data/class" 
    81 chmod -R 777 "${PREFIX}/data/Smarty" 
    82 chmod -R 777 "${PREFIX}/data/logs" 
    83 chmod -R 777 "${PREFIX}/data/downloads" 
    84 chmod -R 777 "${PREFIX}/html/install/temp" 
    85 chmod -R 777 "${PREFIX}/html/user_data" 
    86 chmod -R 777 "${PREFIX}/html/cp" 
    87 chmod -R 777 "${PREFIX}/html/upload" 
    88106 
    89 #echo "dropdb..." 
    90 #su ${PGUSER} -c "${DROPDB} ${DBNAME}" 
     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 
    91137 
    92 #echo "createdb..." 
    93 #su ${PGUSER} -c "${CREATEDB} -U ${DBUSER} ${DBNAME}" 
    94  
    95 SQL_DIR="${PREFIX}/html/install/sql" 
    96  
    97 echo "drop view..." 
    98 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/drop_view.sql ${DBNAME}" 
    99  
    100 echo "drop tables..." 
    101 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/drop_table.sql ${DBNAME}" 
    102 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_session;' ${DBNAME}" 
    103 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_module;' ${DBNAME}" 
    104 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_campaign_order;' ${DBNAME}" 
    105 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_mobile_kara_mail;' ${DBNAME}" 
    106 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_mobile_ext_session_id;' ${DBNAME}" 
    107 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_site_control;' ${DBNAME}" 
    108 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -c 'DROP TABLE dtb_trackback;' ${DBNAME}" 
    109  
    110 echo "create table..." 
    111 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_table_pgsql.sql ${DBNAME}" 
    112  
    113 echo "create_view..." 
    114 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/create_view.sql ${DBNAME}" 
    115  
    116 echo "adding tables..." 
    117 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_campaign_order_pgsql.sql ${DBNAME}" 
    118 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_mobile_ext_session_id_pgsql.sql ${DBNAME}" 
    119 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_mobile_kara_mail_pgsql.sql ${DBNAME}" 
    120 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_module_pgsql.sql ${DBNAME}" 
    121 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_session_pgsql.sql ${DBNAME}" 
    122 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_site_control_pgsql.sql ${DBNAME}" 
    123 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/add/dtb_trackback_pgsql.sql ${DBNAME}" 
    124  
    125 echo "insert data..." 
    126 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${SQL_DIR}/insert_data.sql ${DBNAME}" 
    127  
    128 echo "create optional SQL..." 
    129 echo "INSERT INTO dtb_member (member_id, login_id, password, authority, creator_id) VALUES ('1', 'admin', '2c19f4a742398150cecc80b3e76b673a35b8c19c', '0', '0');" >> ${OPTIONAL_SQL_FILE} 
    130 echo "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} 
    131 echo "execute optional SQL..." 
    132 su ${PGUSER} -c "${PSQL} -U ${DBUSER} -f ${OPTIONAL_SQL_FILE} ${DBNAME}" 
     138#-- Setup Initial Data 
    133139 
    134140echo "copy images..." 
    135 cp -rv "${PREFIX}/html/install/save_image" "${PREFIX}/html/upload/" 
     141cp -rv "./html/install/save_image" "./html/upload/" 
    136142 
    137 echo "creating ${INSTALL_PHP}..." 
    138 cat > "${PREFIX}/${INSTALL_PHP}" <<EOF 
     143echo "creating ${CONFIG_PHP}..." 
     144cat > "./${CONFIG_PHP}" <<EOF 
    139145<?php 
    140 define ('ECCUBE_INSTALL', 'ON'); 
    141 define ('HTML_PATH', '${PREFIX}/html/'); 
    142 define ('SITE_URL', '${SITE_URL}'); 
    143 define ('SSL_URL', '${SSL_URL}'); 
    144 define ('URL_DIR', '/'); 
    145 define ('DOMAIN_NAME', '${DOMAIN_NAME}'); 
    146 define ('DB_TYPE', 'pgsql'); 
    147 define ('DB_USER', '${DBUSER}'); 
    148 define ('DB_PASSWORD', '${DBPASS}'); 
    149 define ('DB_SERVER', '${DBSERVER}'); 
    150 define ('DB_NAME', '${DBNAME}'); 
    151 define ('DB_PORT', '${DBPORT}'); 
    152 define ('DATA_PATH', '${PREFIX}/data/'); 
    153 define ('MOBILE_HTML_PATH', HTML_PATH . 'mobile/'); 
    154 define ('MOBILE_SITE_URL', SITE_URL . 'mobile/'); 
    155 define ('MOBILE_SSL_URL', SSL_URL . 'mobile/'); 
    156 define ('MOBILE_URL_DIR', URL_DIR . 'mobile/'); 
    157 ?> 
     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 
    158168EOF 
    159169 
Note: See TracChangeset for help on using the changeset viewer.