Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ysaotome/12f523be8308371b0222c70647829d00 to your computer and use it in GitHub Desktop.
Save ysaotome/12f523be8308371b0222c70647829d00 to your computer and use it in GitHub Desktop.
演習用:ニフティクラウド(NiftyCloud)向けEC-CUBE3セットアップスクリプト。http://[サーバIP]/ にEC-CUBE3がセットアップされる
#!/bin/bash
# Description:EC-CUBE3 Setup with CentOS 7.1 64bit Plain for NiftyCloud (http://cloud.nifty.com/)
# DBサーバ用ファイル
# 2016/06/01 @ysaotome
(
#===============================================
# Settings
#===============================================
##追加する管理ユーザ名
USER_NAME='eccube'
##管理ユーザのパスワード
USER_PASSWORD='hoge##123'
#===============================================
ARC=$(/bin/uname -m)
SALT=$(/usr/bin/uuidgen| /usr/bin/tr -d '-')
## 管理ユーザ追加と設定
/usr/sbin/useradd -G 100 -p $(/usr/bin/perl -e 'print crypt(${ARGV[0]}, ${ARGV[1]})' ${USER_PASSWORD} ${SALT}) -m ${USER_NAME}
/bin/mkdir -p -m 700 /home/${USER_NAME}/.ssh
/bin/cp /root/.ssh/authorized_keys /home/${USER_NAME}/.ssh/.
/bin/chown -R ${USER_NAME}:${USER_NAME} /home/${USER_NAME}/.ssh
## リポジトリ追加:RPMforge
/bin/rpm --import http://ftp.riken.jp/Linux/dag/RPM-GPG-KEY.dag.txt
/bin/rpm -ivh http://ftp.riken.jp/Linux/dag/redhat/el7/en/${ARC}/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.${ARC}.rpm
/bin/sed -i.org -e "s/enabled.*=.*1/enabled=0/g" /etc/yum.repos.d/rpmforge.repo
## リポジトリ追加:EPEL
/bin/rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL
/bin/rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/7/${ARC}/e/epel-release-7-5.noarch.rpm
/bin/sed -i.org -e "s/enabled.*=.*1/enabled=0/g" /etc/yum.repos.d/epel.repo
## リポジトリ追加:Remi
/bin/rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
/bin/rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
/bin/sed -i.org -e "s/enabled.*=.*1/enabled=0/g" /etc/yum.repos.d/remi.repo
## カーネルアップデートの制約を一時的に許可する
/bin/sed -ie 's/exclude=/#exclude=/' /etc/yum.conf
## ツールセットアップ
/usr/bin/yum --enablerepo=rpmforge,epel,remi -y install zsh.${ARC} screen.${ARC} vim-enhanced.${ARC} chrony.${ARC} git.${ARC} figlet.${ARC}
/usr/bin/yum --enablerepo=rpmforge,epel,remi -y install htop.${ARC} sysstat.${ARC} dstat.noarch
## zshとscreenの設定ファイル取得
/usr/bin/wget --no-check-certificate -P /home/${USER_NAME}/ 'https://gist.github.com/ysaotome/1336176/raw/8ec9767aaaaec88cbe8c2b4a4092f16d7839c77b/.screenrc'
/usr/bin/wget --no-check-certificate -P /home/${USER_NAME}/ 'https://gist.github.com/ysaotome/1336176/raw/0388bb029061783bcb2d8bbd3218b04ac4b29ba4/.zshrc'
/bin/chown -R ${USER_NAME}:${USER_NAME} /home/${USER_NAME}/.screenrc /home/${USER_NAME}/.zshrc
/bin/ln -s /home/${USER_NAME}/.screenrc /root/
/bin/ln -s /home/${USER_NAME}/.zshrc /root/
/usr/sbin/usermod -s /bin/zsh root
/usr/sbin/usermod -s /bin/zsh ${USER_NAME}
## update-motd設置
/usr/bin/wget --no-check-certificate -O /usr/local/bin/screenfetch https://raw.githubusercontent.com/KittyKatt/screenFetch/master/screenfetch-dev
/bin/chmod 755 /usr/local/bin/screenfetch
/usr/bin/wget --no-check-certificate -P /usr/local/bin/ 'https://gist.github.com/ysaotome/5997652/raw/fecdf757b348debfcdd866df00f6d567ff749623/update_motd_by_screenfetch.sh'
/bin/chmod 755 /usr/local/bin/update_motd_by_screenfetch.sh
/usr/local/bin/update_motd_by_screenfetch.sh
/bin/cat << _UPDATEMOTD_ > /etc/cron.d/update-motd
#update-moted
*/5 * * * * root /usr/local/bin/update_motd_by_screenfetch.sh
_UPDATEMOTD_
## 時刻同期設定
/usr/bin/vmware-toolbox-cmd timesync disable
/bin/sed -i.org -e "s/^server /#server /g" /etc/chrony.conf
/bin/cat << _NTPDCONF_ >> /etc/chrony.conf
server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst
_NTPDCONF_
/usr/bin/systemctl enable chronyd
/usr/bin/systemctl restart chronyd
/usr/bin/chronyc sources
## yum update
/usr/bin/yum -y update
## カーネルアップデートの制約を入れる
/bin/sed -ie 's/#exclude=/exclude=/' /etc/yum.conf
## PostgreSQLセットアップ
/usr/bin/yum install postgresql-server
postgresql-setup initdb
vi /var/lib/pgsql/data/pg_hba.conf
local   all             postgres                                peer
local   all             all                                     md5
host    all             all             127.0.0.1/32  
systemctl restart postgresql
systemctl enable postgresql
) 2>&1 | /usr/bin/tee /var/log/niftycloud-init.log
#!/bin/bash
# Description:EC-CUBE3 Setup with CentOS 7.1 64bit Plain for NiftyCloud (http://cloud.nifty.com/)
# WEB/APPサーバ用ファイル
# 2016/06/01 @ysaotome
(
#===============================================
# Settings
#===============================================
##追加する管理ユーザ名
USER_NAME='eccube'
##管理ユーザのパスワード
USER_PASSWORD='hoge##123'
#===============================================
ARC=$(/bin/uname -m)
SALT=$(/usr/bin/uuidgen| /usr/bin/tr -d '-')
## 管理ユーザ追加と設定
/usr/sbin/useradd -G 100 -p $(/usr/bin/perl -e 'print crypt(${ARGV[0]}, ${ARGV[1]})' ${USER_PASSWORD} ${SALT}) -m ${USER_NAME}
/bin/mkdir -p -m 700 /home/${USER_NAME}/.ssh
/bin/cp /root/.ssh/authorized_keys /home/${USER_NAME}/.ssh/.
/bin/chown -R ${USER_NAME}:${USER_NAME} /home/${USER_NAME}/.ssh
## リポジトリ追加:RPMforge
/bin/rpm --import http://ftp.riken.jp/Linux/dag/RPM-GPG-KEY.dag.txt
/bin/rpm -ivh http://ftp.riken.jp/Linux/dag/redhat/el7/en/${ARC}/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.${ARC}.rpm
/bin/sed -i.org -e "s/enabled.*=.*1/enabled=0/g" /etc/yum.repos.d/rpmforge.repo
## リポジトリ追加:EPEL
/bin/rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL
/bin/rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/7/${ARC}/e/epel-release-7-5.noarch.rpm
/bin/sed -i.org -e "s/enabled.*=.*1/enabled=0/g" /etc/yum.repos.d/epel.repo
## リポジトリ追加:Remi
/bin/rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
/bin/rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
/bin/sed -i.org -e "s/enabled.*=.*1/enabled=0/g" /etc/yum.repos.d/remi.repo
## カーネルアップデートの制約を一時的に許可する
/bin/sed -ie 's/exclude=/#exclude=/' /etc/yum.conf
## ツールセットアップ
/usr/bin/yum --enablerepo=rpmforge,epel,remi -y install zsh.${ARC} screen.${ARC} vim-enhanced.${ARC} chrony.${ARC} git.${ARC} figlet.${ARC}
/usr/bin/yum --enablerepo=rpmforge,epel,remi -y install htop.${ARC} sysstat.${ARC} dstat.noarch
## zshとscreenの設定ファイル取得
/usr/bin/wget --no-check-certificate -P /home/${USER_NAME}/ 'https://gist.github.com/ysaotome/1336176/raw/8ec9767aaaaec88cbe8c2b4a4092f16d7839c77b/.screenrc'
/usr/bin/wget --no-check-certificate -P /home/${USER_NAME}/ 'https://gist.github.com/ysaotome/1336176/raw/0388bb029061783bcb2d8bbd3218b04ac4b29ba4/.zshrc'
/bin/chown -R ${USER_NAME}:${USER_NAME} /home/${USER_NAME}/.screenrc /home/${USER_NAME}/.zshrc
/bin/ln -s /home/${USER_NAME}/.screenrc /root/
/bin/ln -s /home/${USER_NAME}/.zshrc /root/
/usr/sbin/usermod -s /bin/zsh root
/usr/sbin/usermod -s /bin/zsh ${USER_NAME}
## update-motd設置
/usr/bin/wget --no-check-certificate -O /usr/local/bin/screenfetch https://raw.githubusercontent.com/KittyKatt/screenFetch/master/screenfetch-dev
/bin/chmod 755 /usr/local/bin/screenfetch
/usr/bin/wget --no-check-certificate -P /usr/local/bin/ 'https://gist.github.com/ysaotome/5997652/raw/fecdf757b348debfcdd866df00f6d567ff749623/update_motd_by_screenfetch.sh'
/bin/chmod 755 /usr/local/bin/update_motd_by_screenfetch.sh
/usr/local/bin/update_motd_by_screenfetch.sh
/bin/cat << _UPDATEMOTD_ > /etc/cron.d/update-motd
#update-moted
*/5 * * * * root /usr/local/bin/update_motd_by_screenfetch.sh
_UPDATEMOTD_
## 時刻同期設定
/usr/bin/vmware-toolbox-cmd timesync disable
/bin/sed -i.org -e "s/^server /#server /g" /etc/chrony.conf
/bin/cat << _NTPDCONF_ >> /etc/chrony.conf
server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst
_NTPDCONF_
/usr/bin/systemctl enable chronyd
/usr/bin/systemctl restart chronyd
/usr/bin/chronyc sources
## yum update
/usr/bin/yum -y update
## カーネルアップデートの制約を入れる
/bin/sed -ie 's/#exclude=/exclude=/' /etc/yum.conf
## Apache,PHPセットアップ
yum install -y php-pear php-devel httpd-devel pcre-devel gcc make
yum install -y php php-pdo php-mysql php-pgsql php-gd php-mbstring php-xml 
http://anandarajpandey.com/2014/07/15/how-to-install-apc-in-centos-for-php-better-performance-opcode/
pecl install apc 
vi /etc/php.d/apc.ini
 extension=apc.so
 apc.enabled=1
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum install --enablerepo="epel" php-mcrypt
vi /etc/php.ini
date.timezone = "Asia/Tokyo"
) 2>&1 | /usr/bin/tee /var/log/niftycloud-init.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment