def install(args = {})
      raise JSS::UnsupportedError, 'You must have root privileges to install packages' unless JSS.superuser?

      args[:target] ||= '/'

      ro_pw = args[:ro_pw]

      # as of Casper 9.72, with http downloads, the jamf binary requires
      # the filename must be at the  end of the -path url, but before 9.72
      # it can't be.
      # e.g.
      #    in  <9.72:  jamf install  -package foo.pkg -path http://mycasper.myorg.edu/CasperShare/Packages
      # but
      #    in >=9.72:  jamf install  -package foo.pkg -path http://mycasper.myorg.edu/CasperShare/Packages/foo.pkg
      #
      append_at_vers = JSS.parse_jss_version('9.72')[:version]
      our_vers = JSS.parse_jss_version(@api.server.raw_version)[:version]
      no_filename_in_url = (our_vers < append_at_vers)

      # use a provided alternative url for an http download
      if args[:alt_download_url]

        # we'll re-add the filename below if needed.
        src_path = args[:alt_download_url].chomp "/#{@filename}"

      # use our appropriate dist. point for download
      else
        mdp = JSS::DistributionPoint.my_distribution_point api: @api

        # how do we access our dist. point? with http?
        if mdp.http_downloads_enabled && !(args[:no_http])
          using_http = true
          src_path = mdp.http_url
          if mdp.username_password_required
            raise JSS::MissingDataError, 'No password provided for http download' unless ro_pw
            raise JSS::InvaldDatatError, 'Incorrect password for http access to distribution point.' unless mdp.check_pw(:http, ro_pw)
            # insert the name and pw into the uri
            # reserved_chars = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}]") # we'll escape all the chars that aren't unreserved
            src_path = src_path.sub(%r{(https?://)(\S)}, "#{Regexp.last_match(1)}#{CGI.escape mdp.http_username}:#{CGI.escape ro_pw}@#{Regexp.last_match(2)}")
          end

        # or with filesharing?
        else
          using_http = false
          src_path = mdp.mount(ro_pw)
        end

        # look at the pkgs folder
        src_path += "#{DIST_POINT_PKGS_FOLDER}/"
      end # if args[:alt_download_url]

      if using_http
        src_path += @filename.to_s unless no_filename_in_url
      end

      # are we doing "fill existing users" or "fill user template"?
      do_feu = args[:feu] ? '-feu' : ''
      do_fut = args[:fut] ? '-fut' : ''

      # the install args for jamf
      command_args = "-package '#{@filename}' -path '#{src_path}'  -target '#{args[:target]}' #{do_feu} #{do_fut} -showProgress -verbose"

      # run it via a client cmd
      install_out = JSS::Client.run_jamf :install, command_args, args[:verbose]

      install_out =~ %r{<exitCode>(\d+)</exitCode>}
      install_exit = Regexp.last_match(1) ? Regexp.last_match(1).to_i : nil
      install_exit ||= $CHILD_STATUS.exitstatus

      if args.include? :unmount
        mdp.unmount unless using_http
      end

      install_exit.zero? ? true : false
    end
def install(args = {})
      raise JSS::UnsupportedError, 'You must have root privileges to install packages' unless JSS.superuser?

      args[:target] ||= '/'

      ro_pw = args[:ro_pw]

      # as of Casper 9.72, with http downloads, the jamf binary requires
      # the filename must be at the  end of the -path url, but before 9.72
      # it can't be.
      # e.g.
      #    in  <9.72:  jamf install  -package foo.pkg -path http://mycasper.myorg.edu/CasperShare/Packages
      # but
      #    in >=9.72:  jamf install  -package foo.pkg -path http://mycasper.myorg.edu/CasperShare/Packages/foo.pkg
      #
      append_at_vers = JSS.parse_jss_version('9.72')[:version]
      our_vers = JSS.parse_jss_version(@api.server.raw_version)[:version]
      no_filename_in_url = (our_vers < append_at_vers)

      # use a provided alternative url for an http download
      if args[:alt_download_url]

        # we'll re-add the filename below if needed.
        src_path = args[:alt_download_url].chomp "/#{@filename}"

      # use our appropriate dist. point for download
      else
        mdp = JSS::DistributionPoint.my_distribution_point api: @api

        # how do we access our dist. point? with http?
        if mdp.http_downloads_enabled && !(args[:no_http])
          using_http = true
          src_path = mdp.http_url
          if mdp.username_password_required
            raise JSS::MissingDataError, 'No password provided for http download' unless ro_pw
            raise JSS::InvaldDatatError, 'Incorrect password for http access to distribution point.' unless mdp.check_pw(:http, ro_pw)
            # insert the name and pw into the uri
            # reserved_chars = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}]") # we'll escape all the chars that aren't unreserved
            src_path = src_path.sub(%r{(https?://)(\S)}, "#{Regexp.last_match(1)}#{CGI.escape mdp.http_username}:#{CGI.escape ro_pw}@#{Regexp.last_match(2)}")
          end

        # or with filesharing?
        else
          using_http = false
          src_path = mdp.mount(ro_pw)
        end

        # look at the pkgs folder
        src_path += "#{DIST_POINT_PKGS_FOLDER}/"
      end # if args[:alt_download_url]

      if using_http
        src_path += @filename.to_s unless no_filename_in_url
      end

      # are we doing "fill existing users" or "fill user template"?
      do_feu = args[:feu] ? '-feu' : ''
      do_fut = args[:fut] ? '-fut' : ''

      # the install args for jamf
      command_args = "-package '#{@filename}' -path '#{src_path}'  -target '#{args[:target]}' #{do_feu} #{do_fut} -showProgress -verbose"

      # run it via a client cmd
      install_out = JSS::Client.run_jamf :install, command_args, args[:verbose]

      install_out =~ %r{<exitCode>(\d+)</exitCode>}
      install_exit = Regexp.last_match(1) ? Regexp.last_match(1).to_i : nil
      install_exit ||= $CHILD_STATUS.exitstatus

      if args.include? :unmount
        mdp.unmount unless using_http
      end

      install_exit.zero? ? true : false
    end
Install this package via the jamf binary 'install' command from the
 distribution point for this machine.
 See {JSS::DistributionPoint.my_distribution_point}

 @note This code must be run as root to install packages

 The read-only or http passwd for the dist. point must be provided,
 except for non-authenticated http downloads)

 @param args[Hash] the arguments for installation

 @option args :ro_pw[String] the read-only or http password for the
   distribution point for the local machine
   (http will be used if available, and may not need a pw)

 @option args :target[String,Pathname] The drive on which to install
  the package, defaults to '/'

 @option args :verbose [Boolean] be verbose to stdout, defaults to false

 @option args :feu[Boolean] fill existing users, defaults to false

 @option args :fut[Boolean] fill user template, defaults to false

 @option args :unmount[Boolean] unmount the distribution point when
   finished?(if we mounted it), defaults to false

 @option args :no_http[Boolean] don't use http downloads even if they
   are enabled for the dist. point.

 @option args :alt_download_url [String] Use this url for an http
   download, regardless of distribution point settings. This can be used
   to access Cloud Distribution Points if the fileshare isn't available.
   The URL should already be ur
   The package filename will be removed or appended as needed.

 @return [Boolean] did the jamf install succeed?

 @todo deal with cert-based https authentication in dist points