centOS6 インストール直後に行う処理をシェルにまとめました。


どのような使い方するにしろ
いつもcentOS6 インストール直後に
共通で設定するコマンドがありましたので
シェルで行えるようにまとめました。

このシェルで行える事

  • レポジトリの設定
  • sudoの設定
  • selinux・ip6tablesの解除
  • git2.Xのインストール
  • アップデート
  • カーネルのアップデート
  • vagrantユーザーでの自動ログイン設定
  • Mozcのインストール
su -

# setup_update.shの準備
rm -f setup_update.sh; touch setup_update.sh; chmod u+x setup_update.sh; vi setup_update.sh
#!/bin/bash

if [ "$UID" -eq 0 ];then
    echo "root!"

    echo "+------------------------------------------------------------------------------------------------------------+";
    echo "■setup start " ${0};
    echo "+------------------------------------------------------------------------------------------------------------+";

    echo "#####################################################################"
    echo "repository"
    echo "#####################################################################"
    readonly URL_RPMFORGE_RPM_GPG_KEY="http://apt.sw.be/RPM-GPG-KEY.dag.txt"
    readonly URL_RPMFORGE="http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm"

    readonly URL_EPEL_RPM_GPG_KEY="http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6"
    readonly URL_EPEL="http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm"

    readonly URL_REMI_RPM_GPG_KEY="http://rpms.famillecollet.com/RPM-GPG-KEY-remi"
    readonly URL_REMI="http://rpms.famillecollet.com/enterprise/remi-release-6.rpm"

    readonly URL_IUS="https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm"

    rpm --import $URL_RPMFORGE_RPM_GPG_KEY
    rpm -ivh $URL_RPMFORGE
    yum -y update rpmforge-release
    cp -p /etc/yum.repos.d/rpmforge.repo /etc/yum.repos.d/rpmforge.repo.org
    sed -i -e "s/enabled = 1/enabled = 0/g" /etc/yum.repos.d/rpmforge.repo

    rpm --import $URL_EPEL_RPM_GPG_KEY
    rpm -ivh $URL_EPEL
    yum -y update epel-release
    cp -p /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.org
    sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo

    rpm --import $URL_REMI_RPM_GPG_KEY
    rpm -ivh $URL_REMI
    yum -y update remi-release

    yum install -y $URL_IUS
    sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/ius.repo


    echo "#####################################################################"
    echo "sudoers"
    echo "#####################################################################"
    cp -fp /etc/sudoers /etc/sudoers.`date "+%Y%m%d_%H%M%S"`_org
    sed -i 's/Defaults.*requiretty/#Default\trequiretty/g' /etc/sudoers
    sed -i 's/^#\s%wheel\s*ALL=(ALL)\s*ALL$/%wheel\tALL=(ALL)\tALL/g' /etc/sudoers
    sed -i 's/^#\s%wheel\s*ALL=(ALL)\s*NOPASSWD: ALL$/vagrant\tALL=(ALL)\tNOPASSWD: ALL/g' /etc/sudoers


    echo "#####################################################################"
    echo "security"
    echo "#####################################################################"
    sed -i "s/\(^SELINUX=\).*/\1disabled/" /etc/selinux/config

    cat /etc/selinux/config | grep "SELINUX="

    service iptables stop
    service ip6tables stop

    chkconfig iptables off
    chkconfig ip6tables off


    echo "#####################################################################"
    echo "git2u"
    echo "#####################################################################"
    yum install -y --enablerepo=ius git2u

    echo "#####################################################################"
    echo "update"
    echo "#####################################################################"
    yum -y update


    echo "#####################################################################"
    echo "kernel update"
    echo "#####################################################################"
    yum install -y update kernel-devel kernel-headers gcc gcc-c++  dkms perl
    yum install -y kernel-devel-`uname -r`


    echo "#####################################################################"
    echo "Development Tools"
    echo "#####################################################################"
    yum groupinstall -y "Development Tools"

    yum install -y bind-utils curl-devel expect gcc-c++ gd-devel glib2-devel glibc-headers ImageMagick ImageMagick-devel 
    yum install -y libffi-devel libxml2-devel libxslt-devel libyaml-devel nkf openssl-devel pcre-devel perl-devel perl-ExtUtils-Embed    
    yum install -y readline readline-devel sqlite-devel tree vim w3m wget zlib zlib-devel

    echo "#####################################################################"
    echo "Auto Log In"
    echo "#####################################################################"
    cp -p /etc/gdm/custom.conf /etc/mdm.conf.`date "+%Y%m%d_%H%M%S"`_org

    sudo sed -i -e "4i TimedLoginEnable=true" /etc/gdm/custom.conf
    sudo sed -i -e "5i TimedLogin=vagrant" /etc/gdm/custom.conf
    sudo sed -i -e "6i TimedLoginDelay=1" /etc/gdm/custom.conf

    echo "#####################################################################"
    echo "Mozc"
    echo "#####################################################################"
    wget http://dl.fedoraproject.org/pub/epel/6/x86_64/protobuf-2.3.0-9.el6.x86_64.rpm
    wget http://ftp.kddilabs.jp/pub/Linux/packages/Vine/Vine-6.3/x86_64/Vine/RPMS/zinnia-0.06-3vl6.x86_64.rpm
    wget http://ftp.kddilabs.jp/pub/Linux/packages/Vine/Vine-6.3/x86_64/Vine/RPMS/tegaki-zinnia-japanese-0.3-1vl6.noarch.rpm
    wget http://ftp.kddilabs.jp/pub/Linux/packages/Vine/Vine-6.3/x86_64/Vine/RPMS/mozc-server-1.5.1090.102-1vl6.x86_64.rpm
    wget http://ftp.kddilabs.jp/pub/Linux/packages/Vine/Vine-6.3/x86_64/Vine/RPMS/mozc-utils-gui-1.5.1090.102-1vl6.x86_64.rpm
    wget http://ftp.kddilabs.jp/pub/Linux/packages/Vine/Vine-6.3/x86_64/Vine/RPMS/ibus-mozc-1.5.1090.102-1vl6.x86_64.rpm
    wget http://ftp.kddilabs.jp/pub/Linux/packages/Vine/Vine-6.3/x86_64/Vine/RPMS/mozc-1.5.1090.102-1vl6.x86_64.rpm

    rpm -ivh protobuf-2.3.0-9.el6.x86_64.rpm
    rpm -ivh zinnia-0.06-3vl6.x86_64.rpm
    rpm -ivh tegaki-zinnia-japanese-0.3-1vl6.noarch.rpm
    rpm -ivh mozc-server-1.5.1090.102-1vl6.x86_64.rpm
    rpm -ivh mozc-utils-gui-1.5.1090.102-1vl6.x86_64.rpm
    rpm -ivh ibus-mozc-1.5.1090.102-1vl6.x86_64.rpm
    rpm -ivh mozc-1.5.1090.102-1vl6.x86_64.rpm

    rm -f protobuf-*.rpm
    rm -f ibus-mozc-*.x86_64.rpm
    rm -f mozc-*.rpm
    rm -f tegaki-zinnia-japanese-*.rpm
    rm -f zinnia-*.rpm



    echo "+------------------------------------------------------------------------------------------------------------+";
    echo "■setup end";
    echo "+------------------------------------------------------------------------------------------------------------+";

else
    echo "non-root user!"
fi