Skip to content

Instantly share code, notes, and snippets.

@131
Last active February 1, 2018 23:37
Show Gist options
  • Save 131/f501961c91852281301e1477a717d366 to your computer and use it in GitHub Desktop.
Save 131/f501961c91852281301e1477a717d366 to your computer and use it in GitHub Desktop.

minimal curl/wget, with binary file support

function __curl() {
  read proto server path <<<$(echo ${1//// })
  DOC=/${path// //}
  HOST=${server//:*}
  PORT=${server//*:}
  [[ x"${HOST}" == x"${PORT}" ]] && PORT=80

  exec 3<>/dev/tcp/${HOST}/$PORT
  echo -en "GET ${DOC} HTTP/1.0\r\nHost: ${HOST}\r\n\r\n" >&3
  (while read line; do
   [[ "$line" == $'\r' ]] && break
  done && cat) <&3
  exec 3>&-
}

As we cannot use apt-key add, (nothing but gpgv is installed) this is apt-key add - equivalent

__curl http://my-server.com/myrepo.gpg > /etc/apt/trusted.gpg.d/ivs.gpg

Now, all we can use our mirror

echo "deb http://my-server.com/mirror/debian-9 stretch main" > /etc/apt/sources.list
apt-get update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment