#!/bin/bash for i in`cat /root/package.txt` do rpm -q $i if [ $? -eq 0 ];then echo "Package $i is already intsalled" >> /root/package.log 2>&1 else yum install -y $i echo "Package $i is now installed" >>/root/package.log 2>&1 fi done
二、自動添加用戶,用戶組 自動添加用戶組,創建目錄,定義oracle密碼,後面還可以加入環境變量,kernel參數等,oracle密碼設置為oracle
#!/bin/bash for i in dbaoinstall do cat /etc/group | grep $i > /dev/null2>&1 if [ $? -eq 0 ];then echo "Group $i is already exist" else groupadd -r $i fi done id oracle >/dev/null 2>&1 && echo "User Oracle is already exist" || useradd -g oinstall -G dba oracle #set password for oracle echo"oracle" | passwd --stdin oracle #create dictionary for install mkdir -p /u01/app chown -R oracle:oinstall /u01/app chmod 775 -R /u01/app