Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update install script to work with Windows #4149

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

casey
Copy link
Collaborator

@casey casey commented Dec 23, 2024

Fixes #4124.

Tested on:

  • ARM Mac
  • x86 Mac
  • x86 Windows
  • x86 Linux

Testing on untested platforms is appreciated!

@cryptoni9n
Copy link
Collaborator

I'm unable to access the explorer on my local ord server on Windows when I run it with --https. I've only ever used http with it up till now. I don't have a cert setup so the TLS/SSL handshake is failing when I attempt the curl command. I've attempted to install a self-signed cert but haven't got it working yet. I'm wondering if maybe this is what the --acme-server flag is for? I'm not certain since I'm unable to locate any documentation on it.

Anyone have experience testing ord server --https locally on a windows machine? Will ask on Discord, also.

@casey
Copy link
Collaborator Author

casey commented Dec 29, 2024

@cryptoni9n Is this related to the install script, or just related to running ord with --https? It sounds like maybe the latter? To get ord working with --https, you'll need a domain for the computer that's running ord, have port 443 open, and pass the domain to --acme-domain.

@cryptoni9n
Copy link
Collaborator

@casey thanks for the quick response. It is an issue with accessing ord over https, but I'm only attempting this configuration because I thought testing the curl install script requires it. If I can run the curl install over http, then I could bypass this issue.

when running on http (F:\0.22.1\release>ord --datadir F:\Bitcoin --cookie-file f:\Bitcoin\.cookie --index "F:\Bitcoin\ord_index\0.22.0\index-0.22-without-874739.redb" --commit-interval 10 server):

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --proto '=https' --tlsv1.2 -fsLS http://localhost/install.sh | bash -s
curl: (1) Protocol "http" not supported or disabled in libcurl

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --proto '=http' --tlsv1.2 -fsLS http://localhost/install.sh | bash -s
curl: (1) Protocol "https" not supported or disabled in libcurl

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --tlsv1.2 -fsLS http://localhost/install.sh | bash -s
install.sh: Could not determine target from output of `uname -m`-`uname -s`, please use `--target`: x86_64-MINGW64_NT-10.0-26100
install.sh: Target architecture is not supported by this install script.
install.sh: Consider opening an issue or building from source: https://github.com/ordinals/ord

when running on https (F:\0.22.1\release>ord --datadir F:\Bitcoin --cookie-file f:\Bitcoin\.cookie --index "F:\Bitcoin\ord_index\0.22.0\index-0.22-without-874739.redb" --commit-interval 10 server --https --acme-domain localhost)

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --proto '=https' --tlsv1.2 -fsLS https://localhost/install.sh | bash -s
curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --proto '=https' --tlsv1.2 -fsLS https://127.0.0.1:443/install.sh | bash -s
curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --proto '=https' --tlsv1.2 -fsLS https://0.0.0.0:443/install.sh | bash -s
curl: (7) Failed to connect to 0.0.0.0 port 443 after 0 ms: Couldn't connect to server

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --tlsv1.2 -fsLS https://0.0.0.0:443/install.sh | bash -s
curl: (7) Failed to connect to 0.0.0.0 port 443 after 1 ms: Couldn't connect to server

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl --tlsv1.2 -fsLS https://localhost/install.sh | bash -s
curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed

@cryptoni9n
Copy link
Collaborator

I removed the https and tls flags and added the --target flag, as directed by the error message. now, when running this command while the server is accessible over http port 80:

MINGW64 /f/Bitcoin/ord_repo/ord (pr-4149)
$ curl -fsLS http://localhost/install.sh | bash -s -- --target x86_64-MINGW64_NT-10.0-26100
install.sh: Repository:  https://github.com/ordinals/ord
install.sh: Crate:       ord
install.sh: Tag:         0.22.1
install.sh: Target:      x86_64-MINGW64_NT-10.0-26100
install.sh: Destination: /c/Users/nine/bin
install.sh: Archive:     https://github.com/ordinals/ord/releases/download/0.22.1/ord-0.22.1-x86_64-MINGW64_NT-10.0-26100.tar.gz
curl: (22) The requested URL returned error: 404

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now

also, when visiting https://github.com/ordinals/ord/releases/download/0.22.1/ord-0.22.1-x86_64-MINGW64_NT-10.0-26100.tar.gz, I see the response "Not Found"

@casey
Copy link
Collaborator Author

casey commented Dec 30, 2024

To test the script locally, you should only need to do ./install.sh, no need to curl it.

@cryptoni9n
Copy link
Collaborator

thanks, just gave that a try and have similar result:

$ ./install.sh
curl: (22) The requested URL returned error: 404

I'm noticing through testing with the curl command that the script seems to want to add .tar.gz to the filename, even for Windows which I think is .zip. Perhaps this is part of the issue?

@casey
Copy link
Collaborator Author

casey commented Jan 3, 2025

Weird, just looking at the script it should handle that:

if [ "$extension" = "zip" ]; then
  download "$archive" "$td/ord.zip"
  unzip -d "$td" "$td/ord.zip"
else
  download "$archive" - | tar --directory "$td" --strip-components 1 -xz
fi

for name in `ls $tempdir`; do
file="$tempdir/$name"
test -x $file || continue
if [ "$extension" = "zip" ]; then
Copy link
Collaborator

@cryptoni9n cryptoni9n Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code suggestion eliminates the 404/file not found error I was running into on Windows when running ./install.sh --force with the fix from this branch.

Suggested change
if [ "$extension" = "zip" ]; then
if [ "$extension" = "zip" ]; then
download "$archive" "$td/ord.zip"
unzip -d "$td" "$td/ord.zip"
binary_path=$(find "$td" -type f \( -name "ord.exe" -o -name "ord" \) | head -n 1)
else
download "$archive" - | tar --directory "$td" --strip-components 1 -xz
binary_path=$(find "$td" -name ord | head -n 1)
fi
if [ -z "$binary_path" ]; then
err "Binary not found in the archive"
fi
binary_name=$(basename "$binary_path")
if [ -e "$dest/$binary_name" ] && [ "$force" = false ]; then
err "\`$dest/$binary_name\` already exists"
else
mkdir -p "$dest"
cp "$binary_path" "$dest/$binary_name"
chmod 755 "$dest/$binary_name"
fi
rm -rf "$td"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error I was hitting was as follows:

Archive:  /tmp/tmp.yF7M2GQnOS/ord.zip
   creating: /tmp/tmp.yF7M2GQnOS/ord-0.22.1/
  inflating: /tmp/tmp.yF7M2GQnOS/ord-0.22.1/Cargo.lock
  inflating: /tmp/tmp.yF7M2GQnOS/ord-0.22.1/Cargo.toml
  inflating: /tmp/tmp.yF7M2GQnOS/ord-0.22.1/LICENSE
  inflating: /tmp/tmp.yF7M2GQnOS/ord-0.22.1/ord.exe
  inflating: /tmp/tmp.yF7M2GQnOS/ord-0.22.1/README.md
cp: cannot stat '/tmp/tmp.yF7M2GQnOS/ord.exe': No such file or directory

@casey
Copy link
Collaborator Author

casey commented Jan 9, 2025

Good news, I bit the bullet and ordered a $200 Windows laptop to test on, so hopefully I can figure this out one it arrives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update install.sh to support Windows x86
2 participants