创建一个shell脚本来安装更新

时间:2013-10-27 07:21:38

标签: scripting

根据一些额外的研究和下面的yum答案,这是我希望我的脚本要做的事情:

  1. 提取更新
  2. 按特定顺序安装更新
  3. 等待几秒钟,以便为每个部分完成yum更新
  4. 重设root帐户密码(如何通过脚本进行硬编码或设置?)
  5. 重置ssh帐户密码(如何通过脚本进行硬编码或设置?)
  6. 清除历史
  7. 删除文件
  8. 提示重新启动

    #!/bin/sh
    # Run as root
    
    # This extracts the tar copied to the server
    tar -xf updates
    sleep 5
    tar -xf app
    sleep 2
    
    # This moves to the February updates and install it.
    cd /updates/feb
    yum -y update *.rpm
    sleep 5
    # This moves to the March updates and install it.
    cd /updates/mar
    yum -y update *.rpm
    sleep 5
    # This moves to the April updates and install it.
    cd /updates/apr
    yum -y update *.rpm
    sleep 5
    # This moves to the May updates and install it.
    cd /updates/may
    yum -y update *.rpm
    sleep 5
    # This moves to the June updates and install it.
    cd /updates/june
    yum -y update *.rpm
    sleep 5
    # This moves to the August updates and install it.
    cd /updates/aug
    yum -y update *.rpm
    sleep 5
    # This moves to the September updates and install it.
    cd /updates/sep
    yum -y update *.rpm
    sleep 5
    # This moves to the APP dependencies and install it.
    cd /updates/app
    yum -y install *.rpm
    sleep 5
    # This resets the root password
    passwd root
    # This resets the ssh account password
    passwd ssh_user
    # This removes the files from the home directory
    cd /home/user
    rm -rf /updates
    wait 5
    # This clears the history and screen
    history -c
    clear
    # This reboots the server with a y/n prompt
    reboot
    
  9. 编辑更新并为成为菜鸟道歉!

1 个答案:

答案 0 :(得分:2)

添加-y(告诉yum假设“是”答案),如下所示:

yum -y update *.rpm