在脚本中间重新启动

在脚本中间重新启动

我看到sudo reboot在脚本的中间 - 这意味着它后面还有更多命令。假设不在块内reboot,是否有任何情况可以执行之后的命令?rebootif

reboot以下是其中的脚本部分。请注意,不if涉及任何块。

    sudo sysctl -p # applies sysctl.conf changes
    sudo sed -i "s/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/" /etc/ssh/sshd_config
    sudo service ssh restart

    sudo reboot

    echo "postfix postfix/main_mailer_type        select  No configuration" | sudo debconf-set-selections
    echo "gridengine-master       shared/gridenginemaster string  hpc-master" | sudo debconf-set-selections
    echo "gridengine-master       shared/gridenginecell   string  default" | sudo debconf-set-selections
    echo "gridengine-master       shared/gridengineconfig boolean false" | sudo debconf-set-selections
    echo "gridengine-common       shared/gridenginemaster string  hpc-master" | sudo debconf-set-selections
    echo "gridengine-common       shared/gridenginecell   string  default" | sudo debconf-set-selections
    echo "gridengine-common       shared/gridengineconfig boolean false" | sudo debconf-set-selections
    echo "gridengine-client       shared/gridenginemaster string  hpc-master" | sudo debconf-set-selections
    echo "gridengine-client       shared/gridenginecell   string  default" | sudo debconf-set-selections
    echo "gridengine-client       shared/gridengineconfig boolean false" | sudo debconf-set-selections
    sudo DEBIAN_FRONTEND=noninteractive apt-get install gridengine-common gridengine-client gridengine-master -y
    sudo -u sgeadmin /usr/share/gridengine/scripts/init_cluster /var/lib/gridengine default /var/spool/gridengine/spooldb sgeadmin
    sudo service gridengine-master restart
    sudo service postfix stop
    sudo update-rc.d postfix disable

答案1

如果sudo失败,例如,如果用户在/etc/sudoers.

该命令也可以位于if块内。如果条件不成立,则将执行脚本的其他部分。

相关内容