wiki:jazz/10-05-30

Version 3 (modified by jazz, 14 years ago) (diff)

--

2010-05-30

  • 如何在 shell script 裡面安裝 java 又不用選 yes
    • [參考] Installing java non-interactively
    • 這裡提到用 debconf-set-selections 來設定一些參數,讓 sun-java*-* 不問授權的 yes,方法包括有寫檔跟沒寫檔的做法,個人覺得留言裡面的那個做法最帥了!!
      cat << EOF | /usr/bin/debconf-set-selections
      sun-java6-bin   shared/accepted-sun-dlj-v1-1    select true
      sun-java6-jdk   shared/accepted-sun-dlj-v1-1    select true
      sun-java6-jre   shared/accepted-sun-dlj-v1-1    select true
      EOF
      
    • 那麼如果以後遇到別的套件也有類似的問題該怎麼找參數呢?? 答案是用 debconf-get-selections 這個指令,首先必須安裝 debconf-utils 套件,然後執行 debconf-get-selections 再用 grep 用套件名稱找出可以改的參數。
      ~$ sudo debconf-get-selections | grep sun-java6
      sun-java6-jre	sun-java6-jre/stopthread	boolean	true
      sun-java6-bin	shared/accepted-sun-dlj-v1-1	boolean	true
      sun-java6-jre	shared/accepted-sun-dlj-v1-1	boolean	true
      sun-java6-jre	sun-java6-jre/jcepolicy	note	
      sun-java6-bin	shared/error-sun-dlj-v1-1	error	
      sun-java6-jre	shared/error-sun-dlj-v1-1	error	
      sun-java6-bin	shared/present-sun-dlj-v1-1	note	
      sun-java6-jre	shared/present-sun-dlj-v1-1	note	
      
      • 須注意的是原本參數是 boolean 格式,若要下給 debconf-set-selections 必須置換成 select 關鍵字喔!!
        ~$ sudo debconf-get-selections | grep sun-java6 | grep boolean | sed 's#boolean#select#g'
        sun-java6-bin   shared/accepted-sun-dlj-v1-1    select  true
        sun-java6-jdk   shared/accepted-sun-dlj-v1-1    select  true
        sun-java6-jre   shared/accepted-sun-dlj-v1-1    select  true
        sun-java6-jre   sun-java6-jre/stopthread        select  true