本指令碼使用yum批次安裝依賴環境,並檢查每個包的安裝結果,如果安裝失敗,則退出安裝。類似安裝皆可調整後使用
#!/bin/bash # ## packages list packages=( java-1.8.0-openjdk-headless java-1.8.0-openjdk java-1.8.0-openjdk-devel ) for package in "${packages[@]}"; do echo "Installing $package ..." if yum install -y "$package"; then echo "$package Installed" else echo "$package Installation failed, Exited !" exit 1 fi done echo "Java environment installation completed"