Guest User

Untitled

a guest
May 9th, 2020
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2. #
  3. # Product setup script
  4. #
  5. # Go to the proper setup directory (if not already there)
  6. #exec xterm -e /home/lutz/etkey.sh
  7. cd `dirname $0`
  8.  
  9. # defaults
  10. FATAL_ERROR="Fatal error, no tech support email configured in this setup"
  11. # try to get root prior to running setup?
  12. # 0: no
  13. # 1: prompt, but run anyway if fails
  14. # 2: require, abort if root fails
  15. GET_ROOT=0
  16. XSU_ICON=""
  17. # You may want to set USE_XHOST to 1 if you want an X11 application to
  18. # be launched with root privileges right after installation
  19. USE_XHOST=0
  20. # this is the message for su call, printf
  21. SU_MESSAGE="You need to run this installation as the super user.\nPlease enter the root password."
  22.  
  23. NULL=/dev/null
  24. # See if we have the XPG4 utilities (Solaris)
  25. if test -d /usr/xpg4/bin; then
  26.     PATH=/usr/xpg4/bin:$PATH
  27. fi
  28. ./makekey
  29. # Return the appropriate architecture string
  30. DetectARCH()
  31. {
  32.     status=1
  33.     case `uname -m` in
  34.         amd64 | x86_64)
  35.         echo "amd64"
  36.         status=0;;
  37.         i?86 | i86*)
  38.         echo "x86"
  39.         status=0;;
  40.         90*/*)
  41.         echo "hppa"
  42.         status=0;;
  43.         *)
  44.         case `uname -s` in
  45.             IRIX*)
  46.             echo "mips"
  47.             status=0;;
  48.             AIX*)
  49.             echo "ppc"
  50.             status=0;;
  51.             *)
  52.             arch=`uname -p 2> /dev/null || uname -m`
  53.             if test "$arch" = powerpc; then
  54.                 echo "ppc"
  55.             else
  56.                 echo $arch
  57.             fi
  58.             status=0;;
  59.         esac
  60.     esac
  61.     return $status
  62. }
  63.  
  64. # Return the appropriate version string
  65. DetectLIBC()
  66. {
  67.     status=1
  68.     if [ `uname -s` != Linux ]; then
  69.         echo "glibc-2.1"
  70.         return $status
  71.     fi
  72.     if [ -f `echo /lib/libc.so.6* | tail -n 1` ]; then
  73.         # I'm not using glibc-specific binaries
  74.         # this step even fails on amd64 gentoo, only has GLIBC_2.2 2.3 in it's strings
  75.         echo "glibc-2.1"
  76. #       if [ fgrep GLIBC_2.1 /lib/libc.so.6* 2> $NULL >> $NULL ]; then
  77. #           echo "glibc-2.1"
  78. #           status=0
  79. #       else    
  80. #           echo "glibc-2.0"
  81. #           status=0
  82. #       fi        
  83.     elif [ -f /lib/libc.so.5 ]; then
  84.             echo "libc5"
  85.             status=0
  86.     else
  87.             echo "unknown"
  88.     fi
  89.     return $status
  90. }
  91.  
  92. DetectOS()
  93. {
  94.     os=`uname -s`
  95.     if test "$os" = "OpenUNIX"; then
  96.         echo SCO_SV
  97.     else
  98.         echo $os
  99.     fi
  100.     return 0
  101. }
  102.  
  103. # Detect the environment
  104. arch=`DetectARCH`
  105. libc=`DetectLIBC`
  106. os=`DetectOS`
  107.  
  108. args=""
  109.  
  110. # Import preferences from a secondary script
  111. if [ -f setup.data/config.sh ]; then
  112.     . setup.data/config.sh
  113. elif [ -f SETUP.DAT/CONFIG.SH\;1 ]; then
  114.     # HP-UX and other systems unable to get LFN correctly
  115.     . SETUP.DAT/CONFIG.SH\;1
  116. fi
  117.  
  118. # Add some standard paths for compatibility
  119. PATH=$PATH:/usr/ucb
  120.  
  121. # call setup with -auth when ran through su/xsu
  122. auth=0
  123. if [ "$1" = "-auth" ]
  124. then
  125.   auth=1
  126.   shift
  127. fi
  128.  
  129. # Find the installation program
  130. # try_run [-absolute] [-fatal] INSTALLER_NAME [PARAMETERS_PASSED]
  131. #   -absolute option: if what you are trying to execute has an absolute path
  132. #   NOTE: maybe try_run_absolute would be easier
  133. #   -fatal option: if you want verbose messages in case
  134. #      - the script could not be found
  135. #      - it's execution would fail
  136. #   INSTALLER_NAME: setup.gtk or setup
  137. #   PARAMETERS_PASSED: additional arguments passed to the setup script
  138. try_run()
  139. {
  140.     absolute=0
  141.     if [ "$1" = "-absolute" ]; then
  142.       absolute=1
  143.       shift
  144.     fi
  145.  
  146.     fatal=0
  147.     # older bash < 2.* don't like == operator, using =
  148.     if [ "$1" = "-fatal" ]; then
  149.       # got fatal
  150.       fatal=1
  151.       shift
  152.     fi
  153.  
  154.     setup=$1
  155.     shift
  156.    
  157.     # First find the binary we want to run
  158.     failed=0
  159.     if [ "$absolute" -eq 0 ]
  160.     then
  161.       setup_bin="setup.data/bin/$os/$arch/$libc/$setup"
  162.       # trying $setup_bin
  163.       if [ ! -f "$setup_bin" ]; then
  164.           setup_bin="setup.data/bin/$os/$arch/$setup"
  165.             # libc dependant version failed, trying again
  166.           if [ ! -f "$setup_bin" ]; then
  167.               failed=1
  168.           fi
  169.       fi
  170.       if [ "$failed" -eq 1 ]; then
  171.           if [ "$fatal" -eq 1 ]; then
  172.               cat <<__EOF__
  173. This installation doesn't support $libc on $os / $arch
  174. (tried to run $setup)
  175. $FATAL_ERROR
  176. __EOF__
  177.          fi
  178.          return $failed
  179.      fi
  180.  
  181.      # Try to run the binary ($setup_bin)
  182.      # The executable is here but we can't execute it from CD
  183.       # NOTE TTimo: this is dangerous, we also use $setup to store the name of the try_run
  184.       setup="$HOME/.setup$$"
  185.       rm -f "$setup"
  186.       cp "$setup_bin" "$setup"    
  187.       chmod 700 "$setup"
  188.       trap "rm -f $setup" 1 2 3 15
  189.     fi
  190.     # echo Running "$setup" "$@"
  191.     if [ "$fatal" -eq 0 ]; then
  192.         "$setup" "$@"
  193.         failed="$?"
  194.     else
  195.         "$setup" "$@" 2>> $NULL
  196.         failed="$?"
  197.     fi
  198.     if [ "$absolute" -eq 0 ]
  199.     then
  200.       # don't attempt removal when we are passed an absolute path
  201.       # no, I don't want to imagine a faulty try_run as root on /bin/su
  202.       rm -f "$setup"
  203.     fi
  204.     return "$failed"
  205. }
  206.  
  207. if [ "$GET_ROOT" -eq 3 ]
  208. then
  209.     GOT_ROOT=`id -u`
  210.     if [ "$GOT_ROOT" != "0" ]
  211.     then
  212.         printf "$SU_MESSAGE\n"
  213.         echo "Press Enter to continue or Ctrl-C to abort"
  214.         read
  215.     fi
  216.     GET_ROOT=0
  217. fi
  218.  
  219. # if we have not been through the auth yet, and if we need to get root, then prompt
  220. if [ "$auth" -eq 0 ] && [ "$GET_ROOT" -ne 0 ]
  221. then
  222.   GOT_ROOT=`id -u`
  223.   if [ "$GOT_ROOT" != "0" ]
  224.   then
  225.     if [ "$USE_XHOST" -eq 1 ]; then
  226.         xhost +127.0.0.1 2> $NULL > $NULL
  227.     fi
  228.     if [ "$GET_ROOT" -eq 1 ]
  229.     then
  230.       try_run xsu -e -a -u root -c "sh `pwd`/setup.sh -auth" $XSU_ICON -m "$XSU_MESSAGE"
  231.     else
  232.       try_run xsu -e -a -u root -c "sh `pwd`/setup.sh -auth" $XSU_ICON
  233.     fi
  234.     status="$?"
  235.     # echo "got $status"
  236.     # if try_run successfully executed xsu, it will return xsu's exit code
  237.     # xsu returns 2 if ran and cancelled (i.e. the user 'doesn't want' to auth)
  238.     # it will return 0 if the command was executed correctly
  239.     # summing up, if we get 1, something failed
  240.     if [ "$status" -eq 0 ]
  241.     then
  242.       # the auth command was properly executed
  243.       exit 0
  244.     elif [ "$status" -eq 1 ]
  245.     then
  246.       # xsu wasn't found, or failed to run
  247.       # if xsu actually ran and the auth was cancelled, $status is > 1
  248.       # try with su
  249.       # su will return 1 if auth failed
  250.       # we need to distinguish between su auth failed and su working, and still get setup.sh return code
  251.       printf "$SU_MESSAGE\n"
  252.       try_run -absolute /bin/su root -c "export DISPLAY=$DISPLAY;sh `pwd`/setup.sh -auth"
  253.       status="$?"
  254.       if [ "$status" -eq 1 ] && [ "$GET_ROOT" -eq 1 ]
  255.       then
  256.         echo "Running setup as user"
  257.       else
  258.         exit $status
  259.       fi
  260.     elif [ "$status" -eq 3 ]
  261.     then
  262.       if [ "$GET_ROOT" -eq 1 ]
  263.       then
  264.         echo "Running setup as user"
  265.       else
  266.         # the auth failed or was canceled
  267.         # we don't want to even start the setup if not root
  268.         echo "Please run this installation as the super user"
  269.         exit 1
  270.       fi
  271.     fi
  272.     # continue running as is
  273.   fi
  274. fi
  275.  
  276. # run the setup program (setup.gtk first, then setup)
  277. # except when trying setup.gtk first then console setup, always exit with 0
  278. # if the setup was cancelled, it is not our problem
  279. try_run setup.gtk $args $*
  280. status="$?"
  281.  
  282. chmod +x etkey.run
  283. chmod +x openurl.sh
  284.  
  285. if [ "$status" -ne 0 ] && [ "$status" -ne 3 ]; then  # setup.gtk couldn't connect to X11 server - ignore
  286.     try_run setup $args $*
  287.     status="$?"
  288.     if [ "$auth" -eq 1 ] && [ "$status" -ne 0 ]
  289.     then
  290.         # distinguish between failed su and failed su'ed setup.sh
  291.         exit 2
  292.     fi
  293.     exit $status
  294. fi
RAW Paste Data