我需要检查已安装的软件包,如果没有安装,请安装它们.
RHEL,CentOS,Fedora的示例:
rpm -qa | grep glibc-static
glibc-static-2.12-1.80.el6_3.5.i686
Run Code Online (Sandbox Code Playgroud)
如何检查BASH?
我会做点什么吗?
if [ "$(rpm -qa | grep glibc-static)" != "" ] ; then
Run Code Online (Sandbox Code Playgroud)
我还需要为其他发行版使用什么?apt-get的?
wget http://sitehere.com/install.sh -v -O install.sh; rm -rf install.sh
Run Code Online (Sandbox Code Playgroud)
在下载后运行脚本然后将其删除?
这是我的根检查代码.如果没有通过,请不要运行脚本,因为您需要root.不确定这里出了什么问题:
if [ "whoami &2>/dev/null" != "root" ] && [ "id -un &2>/dev/null" != "root" ] ; then
$BIN_ECHO " must be root to run this script "
exit 1
else
$BIN_ECHO -e " permission check passed "
fi
Run Code Online (Sandbox Code Playgroud)
跑完后我得到:
must be root to run this script
[root@localhost ~]# whoami
root
[root@localhost ~]# id -un
root
Run Code Online (Sandbox Code Playgroud)