KShutdown – graphical shutdown utility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
6.8KB

  1. #!/bin/bash
  2. # TODO: 2.0: use kdialog
  3. META_FULL_NAME="KShutDown"
  4. META_VERSION="`cat VERSION`"
  5. #if [[ (("$TERM" == "dumb") || ("$TERM" == "xterm")) && ("${1}" != "--launch-in-konsole") ]]; then
  6. # echo
  7. # echo "Press Ctrl+C to exit $META_FULL_NAME installer"
  8. # konsole --notabbar --notoolbar --workdir `dirname "${0}"` -T "$META_FULL_NAME Installer" -e ${0} --launch-in-konsole
  9. # exit
  10. #fi
  11. # installation dirs
  12. DEFAULT_DIR=`tde-config --prefix`
  13. if [ -z "$DEFAULT_DIR" ]; then
  14. DEFAULT_DIR="/usr"
  15. fi
  16. INSTALL_DIR="$DEFAULT_DIR"
  17. # colors
  18. DEF_C="\E[37;40m"
  19. KEY_C="\E[31;40m"
  20. # configure options
  21. CONFIGURE_OPTIONS=""
  22. FAST_COMPILATION="true"
  23. # i18n
  24. # english
  25. I18N_TITLE_DOCS="Documentation and License"
  26. I18N_TITLE_SETUP="Compilation and Installation"
  27. I18N_CHANGE_DIR="Change installation directory (prefix)"
  28. I18N_DISABLE_FAST="Disable fast compilation"
  29. I18N_ENABLE_FAST="Enable fast compilation"
  30. I18N_INSTALL="Install"
  31. I18N_LICENSE="License"
  32. I18N_NEWS="What's new? (q - quit)"
  33. I18N_PRESS_ENTER="Press <Enter> to exit"
  34. I18N_QUIT="Quit"
  35. I18N_THANKS="Thank you for using"
  36. I18N_MENU="K Menu: Accessories -> KShutDown"
  37. I18N_CONF_WITH="Configuring with"
  38. I18N_INST_FAILED="Installation failed!"
  39. I18N_COMP_FAILED="Compilation failed!"
  40. I18N_CONF_FAILED="Configuration failed!"
  41. I18N_COMP_START="Compiling..."
  42. I18N_MINU=" This may take a few minutes."
  43. I18N_MISSING_DEPEN1="Make sure you have installed the 'tdelibs-devel' package"
  44. I18N_MISSING_DEPEN2=" which is required to compile any KDE application."
  45. I18N_ENTER_DIR="Enter a new prefix"
  46. I18N_SETUP="Setup"
  47. I18N_README="Readme"
  48. # polish
  49. if [[ ("$LANG" == "pl_PL.UTF-8") || ("$LANG" == "pl_PL") || ("$LANG" == "pl") ]]; then
  50. I18N_TITLE_DOCS="Dokumentacja i licencja"
  51. I18N_TITLE_SETUP="Kompilacja i instalacja"
  52. I18N_CHANGE_DIR="Zmien katalog instalacji (prefix)"
  53. I18N_DISABLE_FAST="Wylacz szybka kompilacje"
  54. I18N_ENABLE_FAST="Wlacz szybka kompilacje"
  55. I18N_INSTALL="Instaluj"
  56. I18N_LICENSE="Licencja"
  57. I18N_NEWS="Co nowego? (q - wyjscie)"
  58. I18N_PRESS_ENTER="Nacisnij <Enter>, aby wyjsc"
  59. I18N_QUIT="Zakoncz"
  60. I18N_THANKS="Dziekujemy za uzycie"
  61. I18N_MENU="Menu K: Akcesoria -> KShutDown"
  62. I18N_CONF_WITH="Konfigurowanie z"
  63. I18N_INST_FAILED="Instalacja nie powiodla sie!"
  64. I18N_COMP_FAILED="Kompilacja nie powiodla sie!"
  65. I18N_CONF_FAILED="Konfiguracja nie powiodla sie!"
  66. I18N_COMP_START="Kompilowanie..."
  67. I18N_MINU=" To moze potrwac kilka minut."
  68. I18N_MISSING_DEPEN1="Upewnij sie, ze masz zainstalowana paczke 'tdelibs-devel',"
  69. I18N_MISSING_DEPEN2=" ktora jest wymagana do kompilacji jakiejkolwiek aplikacji KDE."
  70. I18N_ENTER_DIR="Wprowadz nowy prefix"
  71. I18N_SETUP="Instalator"
  72. I18N_README="Przeczytaj (readme)"
  73. fi
  74. #italian
  75. if [[ ("$LANG" == "it_IT.UTF-8") || ("$LANG" == "it_IT") || ("$LANG" == "it") ]]; then
  76. I18N_TITLE_DOCS="Documentazione e Licenza"
  77. I18N_TITLE_SETUP="Compilazione ed Installazione"
  78. I18N_CHANGE_DIR="Cambia la cartella di destinazione (prefix)"
  79. I18N_DISABLE_FAST="Disabilita compilazione veloce"
  80. I18N_ENABLE_FAST="Abilita compilazione veloce"
  81. I18N_INSTALL="Installa"
  82. I18N_LICENSE="Licenza"
  83. I18N_NEWS="Cosa c'è di nuovo? (q - esci)"
  84. I18N_PRESS_ENTER="Premi <Enter> per uscire"
  85. I18N_QUIT="Esci"
  86. I18N_THANKS="Grazie di usare"
  87. I18N_MENU="Menu K: Accessori -> KShutDown"
  88. I18N_CONF_WITH="Configurazione con"
  89. I18N_INST_FAILED="Installazione fallita!"
  90. I18N_COMP_FAILED="Compilazione fallita!"
  91. I18N_CONF_FAILED="Configurazione fallita!"
  92. I18N_COMP_START="Compilazione..."
  93. I18N_MINU=" Per questo potrebbero volerci alcuni minuti."
  94. I18N_MISSING_DEPEN1="Assicurati di aver installato il pacchetto 'tdelibs-devel'"
  95. I18N_MISSING_DEPEN2=" che è necessario per compilare ogni applicazione KDE."
  96. I18N_ENTER_DIR="Inserisci una nuova destinazione"
  97. I18N_SETUP="Installazione"
  98. I18N_README="Leggimi"
  99. fi
  100. # internal functions
  101. ks_kill()
  102. {
  103. echo
  104. echo
  105. echo "$I18N_SETUP: ${1}"
  106. echo
  107. echo "$I18N_PRESS_ENTER"
  108. read
  109. ks_quit 1
  110. }
  111. ks_quit()
  112. {
  113. ks_reset
  114. exit ${1}
  115. }
  116. ks_reset()
  117. {
  118. tput sgr0
  119. }
  120. ks_show_finish_info()
  121. {
  122. echo
  123. echo "$I18N_THANKS $META_FULL_NAME!"
  124. echo " The $META_FULL_NAME Team"
  125. echo
  126. echo "HOW TO RUN?"
  127. echo
  128. echo "$I18N_MENU"
  129. echo "Command: kshutdown"
  130. echo "Command line options: kshutdown --help"
  131. echo
  132. echo -e "$I18N_PRESS_ENTER"
  133. read
  134. }
  135. ks_show_menu()
  136. {
  137. echo -e "$DEF_C"
  138. clear
  139. echo
  140. echo
  141. echo " $I18N_SETUP"
  142. echo " $META_FULL_NAME $META_VERSION"
  143. echo
  144. echo
  145. echo -e " ${KEY_C}${I18N_TITLE_SETUP}${DEF_C}"
  146. echo -e " [${KEY_C}i${DEF_C}] $I18N_INSTALL (./configure --prefix=${INSTALL_DIR}, make, tdesu -c \"make install\")"
  147. echo -e " [${KEY_C}p${DEF_C}] $I18N_CHANGE_DIR"
  148. if [ -n "$FAST_COMPILATION" ]; then
  149. echo -e " [${KEY_C}f${DEF_C}] $I18N_DISABLE_FAST";
  150. else
  151. echo -e " [${KEY_C}f${DEF_C}] $I18N_ENABLE_FAST (--enable-final)";
  152. fi
  153. echo
  154. echo -e " ${KEY_C}${I18N_TITLE_DOCS}${DEF_C}"
  155. echo -e " [${KEY_C}n${DEF_C}] $I18N_NEWS"
  156. echo -e " [${KEY_C}l${DEF_C}] $I18N_LICENSE (GNU GPL)"
  157. echo -e " [${KEY_C}r${DEF_C}] $I18N_README"
  158. echo
  159. echo -e " [${KEY_C}q${DEF_C}] $I18N_QUIT"
  160. echo
  161. echo
  162. echo " http://kshutdown.sourceforge.net"
  163. }
  164. while [ 1 ]; do
  165. ks_show_menu
  166. # wait for a single key
  167. read -n 1 -s
  168. # install
  169. if [[ ("$REPLY" == "i") || ( "$REPLY" == "I" ) ]]; then
  170. if [ -n "$FAST_COMPILATION" ]; then
  171. CONFIGURE_OPTIONS="--prefix=${INSTALL_DIR} --enable-final";
  172. else
  173. CONFIGURE_OPTIONS="--prefix=${INSTALL_DIR}";
  174. fi
  175. echo
  176. echo "$I18N_SETUP: $I18N_CONF_WITH '$CONFIGURE_OPTIONS'..."
  177. echo
  178. # configure
  179. if ! [ -f ./configure ]; then
  180. make -f admin/Makefile.common cvs
  181. fi
  182. if ./configure $CONFIGURE_OPTIONS; then
  183. echo "$I18N_SETUP: $I18N_COMP_START"
  184. echo "$I18N_MINU"
  185. if make; then
  186. if [ -w "${INSTALL_DIR}" ]; then
  187. if make install; then
  188. ks_show_finish_info
  189. ks_quit
  190. else
  191. ks_kill "$I18N_INST_FAILED"
  192. fi
  193. else
  194. if tdesu -c "make install"; then
  195. ks_show_finish_info
  196. ks_quit
  197. else
  198. ks_kill "$I18N_INST_FAILED"
  199. fi
  200. fi
  201. else
  202. ks_kill "$I18N_COMP_FAILED"
  203. fi
  204. else
  205. echo
  206. echo
  207. echo "$I18N_SETUP: $I18N_MISSING_DEPEN1"
  208. echo "$I18N_MISSING_DEPEN2"
  209. ks_kill "$I18N_CONF_FAILED"
  210. fi
  211. ks_quit
  212. # prefix
  213. elif [[ ("$REPLY" == "p") || ( "$REPLY" == "P" ) ]]; then
  214. echo
  215. echo "$I18N_ENTER_DIR [${DEFAULT_DIR}]: "
  216. read -e
  217. if [ -z "$REPLY" ]; then
  218. REPLY="$DEFAULT_DIR"
  219. fi
  220. INSTALL_DIR="$REPLY"
  221. # toggle fast compilation
  222. elif [[ ("$REPLY" == "f") || ( "$REPLY" == "F" ) ]]; then
  223. if [ -z "$FAST_COMPILATION" ]; then
  224. FAST_COMPILATION="true";
  225. else
  226. FAST_COMPILATION="";
  227. fi
  228. # news
  229. elif [[ ("$REPLY" == "n") || ( "$REPLY" == "N" ) ]]; then
  230. less "NEWS"
  231. # license
  232. elif [[ ("$REPLY" == "l") || ( "$REPLY" == "L" ) ]]; then
  233. less "COPYING"
  234. # readme
  235. elif [[ ("$REPLY" == "r") || ( "$REPLY" == "R" ) ]]; then
  236. less "README"
  237. # quit
  238. elif [[ ("$REPLY" == "q") || ( "$REPLY" == "Q" ) ]]; then
  239. ks_reset
  240. clear
  241. exit
  242. fi
  243. done