Skip to content

Instantly share code, notes, and snippets.

@lunatilia
Created March 27, 2015 09:22
Show Gist options
  • Save lunatilia/8cb5535f5548d0becba1 to your computer and use it in GitHub Desktop.
Save lunatilia/8cb5535f5548d0becba1 to your computer and use it in GitHub Desktop.
CentOS6とかでMinimalインストールしたときに環境を整えるスクリプト(自分用)
#!/bin/sh
#----------------------------------------------------------------------------#
# setup-el6minimal.sh
#----------------------------------------------------------------------------#
# Defined Install Packages
VMWARE_BUILD="gcc kernel-headers kernel-devel perl-core "
NETWORK="bind-utils telnet openssh-clients ntp traceroute lsof wget curl "
OTHERS="man man-pages-ja parted tmpwatch screen sysstat "
function cronie_replace(){
rpm -q cronie-anacron > /dev/null
local RET=$?
if [ ${RET} -ne 0 ]; then
echo "cronie-noanacron: already installed."
return 0
else
yum remove cronie-anacron
yum install cronie-noanacron
return $?
fi
}
function rpm_inst_check(){
rpm -q $1 > /dev/null
local RET=$?
if [ ${RET} -ne 0 ]; then
INST="$INST $1"
fi
}
function inst_packages(){
local LISTS=${VMWARE_BUILD}${NETWORK}${OTHERS}
for PACKAGE in ${LISTS}
do
rpm_inst_check ${PACKAGE}
done
echo "Detect packages: ${INST}"
if [ -z "${INST}" ]; then
echo "all packages: already installed."
return 0
else
yum install ${INST}
return $?
fi
}
#----- run -----#
cronie_replace
RET=$?
if [ ${RET} -ne 0 ]; then
echo "Error: Function \"cronie_replace\" is failed."
fi
inst_packages
RET=$?
if [ ${RET} -ne 0 ]; then
echo "Error: Function \"inst_packages\" is failed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment