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.

fll-installer 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2007 Joaquim Boura <x-un-i@berlios.de>
  4. # heavily based on the knoppix installer from
  5. # Fabian Franz <knoppix-installer@fabian-franz.de>
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; either version 2
  10. # of the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this package; if not, see <http://www.gnu.org/licenses>
  19. #
  20. # On Debian GNU/Linux systems, the text of the GPL license can be
  21. # found in /usr/share/common-licenses/GPL.
  22. #
  23. #--------------------------------------------------------------------------
  24. ERRLOG=/tmp/.installer.error
  25. DEBUGLOG=/tmp/.installer.debug
  26. STARTTIME=$(date +%s)
  27. [ -e "$ERRLOG" ] && rm -f "$ERRLOG"
  28. [ -e "$DEBUGLOG" ] && rm -f "$DEBUGLOG"
  29. # redirect STDERR to debug log
  30. exec 2> "${DEBUGLOG}"
  31. # In case UID is not set, set and use it
  32. if [ -z "${UID}" ]; then
  33. UID=$(id -ur)
  34. fi
  35. if [ -n "$INSTDBG" ]; then
  36. set -x
  37. fi
  38. #--------------------------------------------------------------
  39. # one place to save the error code and message
  40. #--------------------------------------------------------------
  41. error () {
  42. local exitval="${1}"
  43. shift
  44. # the gui should use this to proclaim success/error
  45. printf "${exitval}-${@}\n" > "${ERRLOG}"
  46. printf "E: ${@}\n"
  47. clean_exit ${exitval}
  48. }
  49. #--------------------------------------------------------------
  50. # say
  51. #--------------------------------------------------------------
  52. say () {
  53. printf "O: ${1}\n"
  54. }
  55. #--------------------------------------------------------------
  56. # usage
  57. #--------------------------------------------------------------
  58. usage () {
  59. echo "$0 [-d|--debug] [-i|--inotify inotify_fifo] [-h] [installer inotify_fifo]"
  60. exit 1
  61. }
  62. #--------------------------------------------------------------
  63. # preparation, process cli arguments with getopt
  64. #--------------------------------------------------------------
  65. TEMP=$(getopt -o di:h \
  66. --long debug,inotify:,help \
  67. -n "$(basename ${0})" -- "${@}")
  68. if [ "${?}" -ne 0 ]; then
  69. error 255 "getopt terminated abnormally"
  70. # exit 255
  71. fi
  72. # Note the quotes around `$TEMP': they are essential!
  73. eval set -- "${TEMP}"
  74. while true ; do
  75. case "${1}" in
  76. -d|--debug)
  77. set -x
  78. shift
  79. ;;
  80. -i|--inotify)
  81. INSTALLER_INOTIFY="${2}"
  82. shift 2
  83. ;;
  84. -h|--help)
  85. usage
  86. exit 0
  87. ;;
  88. *)
  89. break
  90. ;;
  91. esac
  92. done
  93. # also handle old installer call
  94. shift $((OPTIND))
  95. if [ "$#" -eq "2" ]; then
  96. [ "$1" = "installer" ] && INSTALLER_INOTIFY="$2"
  97. fi
  98. #--------------------------------------------------------------
  99. #
  100. # Include needed Modules
  101. #--------------------------------------------------------------
  102. SEARCHPATH="/usr/share/fll-installer"
  103. say "loading modules"
  104. for i in $(find "${SEARCHPATH}/modules" -name '*.bm'); do
  105. . "$i"
  106. done
  107. #------------------
  108. # trap clean_exit EXIT
  109. TMPDIR="$(mktemp -p /tmp -d fll-installer.XXXXXX)"
  110. #------------------
  111. main
  112. # we should never arrive here otherwise
  113. # something did go wrong
  114. error 254 "internal error"
  115. #------------------