스크립트 동작 테스트 해본 리눅스 OS
CentOS 6.9 , 7.0, 7.1
Ubuntu 180402
주석이 처리된 부분은 제외하고 사용하셔도 됩니다.
*추가적으로 업데이트 및 수정 사항이 생길때마다 수정할 예정
*추가 여러분들의 댓글 의견도 바로 반영하겠습니다.
#!/bin/bash
pkg_check=`which rpm >& /dev/null; echo $?`
rpm_need_list=( "lshw" "dmidecode" "lsb" "util-linux" )
rpm_need_install="yum install"
#dpkg_need_install=`apt-get install`
if [ ${pkg_check} -eq 0 ]; #PRM PKG Check Point!!!
then
echo ""
echo ""
echo ""
echo ""
echo "Can Use RPM Package."
echo ""
echo ""
echo ""
echo ""
echo "========================================"
echo "Server Information to Command List Check"
echo "========================================"
echo ""
for list_num in ${rpm_need_list[@]};
do
rpm_need_check_command1=`rpm -qa | grep "${list_num}"`
echo "${rpm_need_check_command1}"
rpm_need_check_command2=`rpm -qa | grep "${list_num}" >& /dev/null; echo $?`
if [ ${rpm_need_check_command2} -eq 1 ];
then
echo "yum install ${list_num}"
echo -n "Install continue ? (y/n) "
read ans_continue
if [ "${ans_continue}" = "y" ] ; then
install_option="-y"
else
install_option=""
fi
rpm_need_install="yum install ${install_option} ${list_num}"
echo ""
echo "========================================"
echo "The Server is not installed ${list_num}."
echo "========================================"
echo ""
${rpm_need_install} 2>&1 > /dev/null
fi
sleep 1
done
echo ""
echo "===================="
echo "Command List ReCheck"
echo "===================="
for list_num in ${rpm_need_list[@]};
do
rpm_need_check_command1=`rpm -qa | grep "${list_num}"`
echo "${rpm_need_check_command1}"
rpm_need_check_command2=`rpm -qa | grep "${list_num}" >& /dev/null; echo $?`
if [ ${rpm_need_check_command2} -eq 1 ];
then
rpm_need_install="yum install ${list_num}"
echo ""
echo "==========================================="
echo "The Server is not installed!!! ${list_num}."
echo "==========================================="
echo ""
${rpm_need_install}
fi
done
echo ""
echo "========================================="
echo "Server need command list full complete!!!"
echo "========================================="
echo ""
echo ""
echo ""
echo "==================================="
echo "Server Information Report Start!!!!"
echo "==================================="
sleep 1
sh ./svr_info.sh
elif [ ${pkg_check} -eq 2 ]; #Ubuntu PKG Check Point!!!
# then
# echo ""
# echo ""
# echo ""
# echo ""
# echo "Can Use DPKG Package."
# echo ""
# echo ""
# echo ""
# echo ""
# echo "========================================"
# echo "Server Information to Command List Check"
# echo "========================================"
# echo ""
#
# for list_num in ${rpm_need_list[@]};
# do
# dpkg_need_check_command1=`dpkg --list | grep "${list_num}" | awk '{print $2 "" $3}'`
#
# echo "${rpm_need_check_command1}"
#
# rpm_need_check_command2=`dpkg --list | grep "${list_num}" >& /dev/null; echo $?`
#
# if [ ${rpm_need_check_command2} -eq 1 ];
# then
# rpm_need_install="yum install ${list_num}"
#
# echo ""
# echo "========================================"
# echo "The Server is not installed ${list_num}."
# echo "========================================"
# echo ""
# ${rpm_need_install}
# fi
#
# sleep 1
# done
#
# echo ""
# echo "===================="
# echo "Command List ReCheck"
# echo "===================="
#
# for list_num in ${rpm_need_list[@]};
# do
# rpm_need_check_command1=`rpm -qa | grep "${list_num}"`
#
# echo "${rpm_need_check_command1}"
#
# rpm_need_check_command2=`rpm -qa | grep "${list_num}" >& /dev/null; echo $?`
#
# if [ ${rpm_need_check_command2} -eq 1 ];
# then
# rpm_need_install="yum install ${list_num}"
#
# echo ""
# echo "==========================================="
# echo "The Server is not installed!!! ${list_num}."
# echo "==========================================="
# echo ""
# ${rpm_need_install}
# fi
# done
#
# echo ""
# echo "========================================="
# echo "Server need command list full complete!!!"
# echo "========================================="
# echo ""
#
# echo ""
# echo ""
# echo "==================================="
# echo "Server Information Report Start!!!!"
# echo "==================================="
#
# sleep 1
# sh ./svr_info.sh
then
echo "DPKG형식의 패키지 파일 사용이 가능합니다."
fi
'Script > Search Info 관련' 카테고리의 다른 글
Cisco Switch MAC(ver2) 정보 자동화 (0) | 2019.08.29 |
---|---|
Info - Ping Type Check (0) | 2019.07.29 |
Info - 서버 정보 읽어오는 스크립트 ver.2 (0) | 2019.07.29 |
Cisco Switch MAC 정보 자동화 (0) | 2019.07.17 |
Info - 서버 정보 읽어오는 스크립트 (수정19.06.18) (0) | 2019.06.05 |