yum安裝腳本練習

yum的格式

local.repo                                                                                      #文件名

[Server]                                                                                          #容器的名字 

name=local cdrom                                                                     #說明,最好寫有意義的

baseurl=file://mnt/cdrom/Server 或者ip地址                          #鏡像地址

enabled=1                                                                                    #表示啓用該段配置

gpgcheck=0                                                                                 #是否對軟件包進行數字簽名認證,0不認證


root@debian:~# vim yum.sh

#!/bin/bash
PATH=/home/lyw/
read -p "Please input the name for *.repo:" NAME
        if [[ -e $PATH$NAME.repo ]];then
                echo "$NAME exist;"
        exit 5
        else

        read -p "Please import the *.repo id:" ID
        until [[ $save == "yes" ]];do
        read -p "Please import the *.repo name:" name
        read -p "Please import the *.repo baseurl:" baseurl
        read -p "Please import the *.repo enabled id 1 or 0:" sid
        read -p "Please import the *.repo gpgcheck id 1 or 0:" id

        echo -e "[ID]\nname=$name\nbaseurl=$baseurl\nenabled=$sid\ngpgcheck=$id" >> $PATH$NAME.repo       注意:要想使\n換行生效 必須加-e參數
        read -p "Save? Please input yes or no:" save
        done
        fi


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章