heyslack 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env sh
  2. #==============HEADER===============================================|
  3. #AUTHOR
  4. # Jefferson Rocha <lrcjefferson@gmail.com>
  5. #
  6. #PROGRAM
  7. # heyslack - Utilities install for Slackware
  8. #
  9. #DESCRIPTION
  10. #
  11. #
  12. #SUPPORT:
  13. # UPDATE system (update, upgrade-all)
  14. # LAMP (httpd, mysql, php)
  15. #
  16. #CHANGELOG
  17. #===================================================================|
  18. #==========VARIABLES==================|
  19. version="heyslack 0.1"
  20. ##Colors
  21. bold=$(tput bold)
  22. fg_red=$(tput setaf 1)
  23. end=$(tput sgr0)
  24. #=====================================|
  25. #==========TESTES=====================|
  26. # dialog exist?
  27. [ ! $(type -p "dialog") ] && {
  28. printf '%s\n' "${bold}${fg_red}Need a dialog...${end}"
  29. exit 1
  30. }
  31. [ "$UID" -ne "0" ] && {
  32. dialog --title "ERROR!" --infobox "NEED ROOT!" 0 0
  33. exit 1
  34. }
  35. #=====================================|
  36. #==========FUNCTIONS==================|
  37. _USAGE(){ # How use heyslack?
  38. text=$(cat <<EOF
  39. ashduhuasdhusadhudsauhdsauhhusadhudsahudsahudashudshau
  40. sadudasuhdsahdsauhdsa
  41. dsasdahudsuhahudsa
  42. EOF
  43. )
  44. dialog --backtitle "$version" --title "USAGE" \
  45. --msgbox "$text" 0 0
  46. }
  47. search_install(){ # Search and Install!
  48. set -e # Error? stop;
  49. for need in "${LIST[@]}"; {
  50. if ! type -p "$need" 1>/dev/null 2>&1; then
  51. dialog --sleep 1 \
  52. --title "NOT INSTALLED ON SYSTEM" \
  53. --infobox "'${need}' Installing..." 3 35
  54. slackpkg install "$need"
  55. else
  56. dialog --sleep 1 \
  57. --title "ALREADY IN THE SYSTEM" \
  58. --infobox "${need} OK..." 3 30
  59. fi
  60. }
  61. }
  62. update(){
  63. slackpkg update && slackpkg upgrade-all
  64. }
  65. lamp(){ # Lamp install
  66. LIST=("httpd" "mysql" "php") # LIST FOR SEARCH.
  67. dialog --infobox "Wait..." 0 0
  68. search_install # Call Function
  69. }
  70. #=====================================|
  71. # MAIN
  72. while true; do
  73. menu=$(dialog --stdout \
  74. --backtitle "$version" \
  75. --title "SLACKWARE UTILITIES" \
  76. --cancel-label "Sair" \
  77. --ok-label "Instalar" \
  78. --radiolist "Utilities for Slackware" \
  79. 0 0 0 \
  80. "Update" "update system now" off \
  81. "Lamp" "httpd, mysql, php" off )
  82. mode="$?"
  83. [ "$mode" = "1" ] && exit 0
  84. case "$menu" in
  85. Update) update ;;
  86. Lamp) lamp ;;
  87. *) _USAGE ;;
  88. esac
  89. done