bootystrap.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. harakiri() {
  3. printf "!!! %s !!!\n" "$*" &
  4. exit 1
  5. }
  6. prepare() {
  7. [ "$(id -u)" = 0 ] && harakiri "Don't go super sayan on this script! >.<"
  8. [ ! -f "booty.conf" ] && harakiri "Config file booty.conf not found, baka!"
  9. # shellcheck source=/dev/null
  10. . ./booty.conf
  11. [ -z "$UPDATECMD" ] && harakiri "Undefined repo update command!"
  12. printf "About to update main repo...\n"
  13. $UPDATECMD
  14. [ -z "$PACMAN" ] && harakiri "Pacman install command undefined!"
  15. [ -z "$AUR" ] && harakiri "Aur helper install command undefined!"
  16. [ -z "$GIT" ] && harakiri "Git command undefined!"
  17. [ -z "$PROGFILES" ] && harakiri "No progfiles defined!"
  18. printf "These progfiles were defined: %s\n" "$PROGFILES"
  19. }
  20. read_prog_files() {
  21. printf "%s\n" "$PROGFILES" | tr ' ' '\n' | while read -r file; do
  22. printf "Processing %s...\n" "$file"
  23. if [ -f "$file" ]; then
  24. process_prog_file "$file"
  25. else
  26. printf "Couldn't find %s. Skipping to next file if any.\n" "$file"
  27. fi
  28. done
  29. }
  30. process_prog_file() {
  31. FNAME=$(printf "%s" "$1" | cut -d. -f1)
  32. while IFS= read -r program; do
  33. case "$FNAME" in
  34. "base") $PACMAN "$program" ;;
  35. "pacman") $PACMAN "$program" ;;
  36. "aur") $AUR "$program" ;;
  37. "git") process_git "$program" ;;
  38. *) printf "Undefined install command. Skipping...\n" ;;
  39. esac
  40. done <"$1"
  41. }
  42. process_git() {
  43. folder_name="/tmp/$(printf "%s" "$1" | sed -e 's/[\/.:-]//g')"
  44. $GIT "$1" "$folder_name"
  45. }
  46. prepare
  47. read_prog_files