Guest User

freemind.sh ubuntu 14.04

a guest
Aug 2nd, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. #!/bin/sh
  2. # 2004-02-13, modified for Debian by deb@zorglub.s.bawue.de
  3. # 2004-06-19, rewritten for Linux/UN*X by deb@zorglub.s.bawue.de
  4. # (based on Jan Schulz's input)
  5. # 2004-11-28, minor changes for version 0.8.0 by deb@zorglub.s.bawue.de
  6. # 2005-01-08, removed bashims to make script POSIX conform
  7. # 2005-01-16, added usage of FREEMIND_BASE_DIR variable
  8. # 2005-02-18, add -Dfreemind.base.dir to make plugins work, add some ""
  9. # and enhance debug mode.
  10. # 2005-11-08, adding commons-codec to classpath.
  11. # 2005-11-09, add some dpkg/rpm information and check for Sun/Blackdown VM.
  12. # 2006-10-29, follow links to this script using readlink.
  13. # 2008-02-02, improve Java recognition, add lsb_release, fix -x which being empty
  14. # add -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D for non-Sun JREs
  15. # 2008-02-03, add debug values script and exit
  16. # 2008-05-20 (fc): -Xmx256M added
  17. # 2008-08-08 (ewl) accept OpenJDK as valid VM to run FreeMind.
  18.  
  19. # we only want to test the script, not FreeMind itself
  20. if ( echo "${DEBUG}" | grep -qe "script" )
  21. then
  22. set -x
  23. fi
  24.  
  25. # debug also java-wrapper
  26. if [ -n "${DEBUG}" ]
  27. then
  28. DEBUG_WRAPPER=1
  29. export DEBUG_WRAPPER
  30. fi
  31.  
  32. ########## FUNCTIONS DEFINITIONS #######################################
  33.  
  34. _debug() {
  35. if [ -n "${DEBUG}" ]
  36. then
  37. echo "DEBUG: $1" >&2
  38. shift
  39. for text in "$@"
  40. do
  41. echo " ${text}" >&2
  42. done
  43. fi
  44. }
  45.  
  46. _error() {
  47. echo "ERROR: $1" >&2
  48. shift
  49. for text in "$@"
  50. do
  51. echo " ${text}" >&2
  52. done
  53. }
  54.  
  55. findjava() {
  56. # We try hard to find the proper 'java' command
  57. if [ -n "${JAVA_CMD}" ] && [ -x "${JAVA_CMD}" ]
  58. then
  59. _debug "Using \$JAVA_CMD to find java virtual machine."
  60. elif [ -n "${JAVA_BINDIR}" ] && [ -x "${JAVA_BINDIR}/java" ]
  61. then
  62. JAVA_CMD="${JAVA_BINDIR}/java"
  63. _debug "Using \$JAVA_BINDIR to find java virtual machine."
  64. elif [ -n "${JAVA_HOME}" ] && [ -x "${JAVA_HOME}/bin/java" ]
  65. then
  66. JAVA_CMD="${JAVA_HOME}/bin/java"
  67. _debug "Using \$JAVA_HOME to find java virtual machine."
  68. else
  69. JAVA_CMD=$(which java)
  70. if [ -n "${JAVA_CMD}" ] && [ -x "${JAVA_CMD}" ]
  71. then
  72. _debug "Using \$PATH to find java virtual machine."
  73. elif [ -x /usr/bin/java ]
  74. then
  75. _debug "Using /usr/bin/java to find java virtual machine."
  76. JAVA_CMD=/usr/bin/java
  77. fi
  78. fi
  79.  
  80. # if we were successful, we return 0 else we complain and return 1
  81. if [ -n "${JAVA_CMD}" ] && [ -x "${JAVA_CMD}" ]
  82. then
  83. _debug "Using '$JAVA_CMD' as java virtual machine..."
  84. if [ -n "${DEBUG}" ]
  85. then
  86. "$JAVA_CMD" -version >&2
  87. fi
  88. if (! "${JAVA_CMD}" -version 2>&1 | grep -qe 'Java(TM)' \
  89. -e 'OpenJDK')
  90. then
  91. _error "Your Java VM is not a complete implementation," \
  92. "=======================================" \
  93. "FREEMIND WILL MOST PROBABLY *NOT* WORK," \
  94. "=======================================" \
  95. "define JAVA_CMD, JAVA_BINDIR, JAVA_HOME or PATH in order" \
  96. "to point to such a VM. See the manpage of freemind(1) for details."
  97. JAVA_TYPE=other
  98. else
  99. JAVA_TYPE=sun
  100. fi
  101. return 0
  102. else
  103. _error "Couldn't find a java virtual machine," \
  104. "define JAVA_CMD, JAVA_BINDIR, JAVA_HOME or PATH." \
  105. "See the manpage of freemind(1) for details."
  106. return 1
  107. fi
  108. }
  109.  
  110. _source() {
  111. if [ -f "$1" ]
  112. then
  113. _debug "Sourcing '$1'."
  114. . "$1"
  115. fi
  116. }
  117.  
  118. output_debug_info() {
  119. if [ -z "${DEBUG}" ]
  120. then
  121. return 0
  122. fi
  123. _debug "Freemind parameters are '${@}'."
  124. _debug "$(uname -a)"
  125. if [ -x "$(which lsb_release 2>/dev/null)" ]
  126. then
  127. _debug "$(lsb_release -a)"
  128. else
  129. _debug "System is not LSB conform, 'lsb_release' does not exist."
  130. fi
  131. if [ -x "$(which dpkg 2>/dev/null)" ]
  132. then
  133. _debug "The following DEB packages are installed:"
  134. COLUMNS=132 dpkg -l | grep -i -e freemind >&2
  135. elif [ -x "$(which rpm 2>/dev/null)" ]
  136. then
  137. _debug "The following RPM packages are installed:"
  138. rpm -qa | grep -i -e freemind >&2
  139. else
  140. _debug "Neither dpkg nor rpm is installed."
  141. fi
  142. }
  143.  
  144. ########## START MAIN PART #############################################
  145.  
  146. #--------- Put the environment together --------------------------------
  147.  
  148. _source /etc/freemind/freemindrc
  149. _source ~/.freemind/freemindrc
  150.  
  151. if [ -r /usr/lib/java-wrappers/java-wrappers.sh ]
  152. then # the Debian method
  153. . /usr/lib/java-wrappers/java-wrappers.sh
  154. require_java_runtime java6
  155. else
  156. findjava
  157. if [ $? -ne 0 ]
  158. then
  159. exit 1
  160. fi
  161. fi
  162.  
  163. output_debug_info
  164.  
  165. if [ -L "$0" ] && [ -x $(which readlink) ]
  166. then # if the script is a link and we have 'readlink' to follow it
  167. # -m should be faster and link does always resolve, else this script
  168. # wouldn't be called, would it?
  169. freefile=$(readlink -mn "$0")
  170. _debug "Link '$0' resolved to '${freefile}'."
  171. else
  172. freefile="$0"
  173. fi
  174. freepath=$(dirname "${freefile}")
  175. freepath="${freepath%/bin}" # nothing happens if freemind is not installed
  176. # under something/bin
  177.  
  178. # we try different possibilities to find freemind.jar
  179. for jar in "${FREEMIND_BASE_DIR}" \
  180. "${freepath}" "${freepath}/share/freemind" "${freepath}/freemind"
  181. do
  182. if [ -f "${jar}/lib/freemind.jar" ]
  183. then
  184. freedir="${jar}"
  185. _debug "Freemind Directory is '${jar}'."
  186. break
  187. fi
  188. done
  189.  
  190. if [ -z "${freedir}" ]
  191. then
  192. _error "Couldn't find freemind under '${freepath}'."
  193. exit 1
  194. fi
  195.  
  196. if [ ! -f ~/.freemind/patterns.xml ] && [ -f /etc/freemind/patterns.xml ]
  197. then
  198. if [ ! -d ~/.freemind ]
  199. then
  200. _debug "Creating directory ~/.freemind."
  201. mkdir -p ~/.freemind
  202. fi
  203. _debug "Copying patterns.xml to ~/.freemind."
  204. cp /etc/freemind/patterns.xml ~/.freemind/patterns.xml
  205. fi
  206.  
  207. #--------- Call (at last) FreeMind -------------------------------------
  208.  
  209. # The CLASSPATH also lets one specify additional jars, which is good, if
  210. # you want to add a new Look&Feel jar (the motif one is so ugly...).
  211. #
  212. CLASSPATH="${ADD_JARS}:${CLASSPATH}:${freedir}/lib/freemind.jar:\
  213. /usr/share/java/SimplyHTML.jar:\
  214. /usr/share/java/gnu-regexp.jar:\
  215. /usr/share/java/jibx-run-1.1.6a.jar:\
  216. /usr/share/java/xpp3.jar:\
  217. ${freedir}/lib/bindings.jar:\
  218. /usr/share/java/forms.jar:\
  219. ${freedir}"
  220. if [ "${JAVA_TYPE}" = "sun" ]
  221. then
  222. _debug "Calling: '${JAVA_CMD} -Dfreemind.base.dir=${freedir} -cp ${CLASSPATH} freemind.main.FreeMindStarter $@'."
  223. ( echo "${DEBUG}" | grep -qe "exit" ) && exit 0 # do not start FreeMind
  224. "${JAVA_CMD}" -Xmx256M -Dfreemind.base.dir="${freedir}" -cp "${CLASSPATH}" freemind.main.FreeMindStarter "$@"
  225. else # non-Sun environments don't work currently.
  226. _debug "Calling: '${JAVA_CMD} -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D -Dfreemind.base.dir=${freedir} -cp ${CLASSPATH} freemind.main.FreeMindStarter $@'."
  227. ( echo "${DEBUG}" | grep -qe "exit" ) && exit 0 # do not start FreeMind
  228. "${JAVA_CMD}" -Xmx256M -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D -Dfreemind.base.dir="${freedir}" -cp "${CLASSPATH}" freemind.main.FreeMindStarter "$@"
  229. fi
Add Comment
Please, Sign In to add comment