This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
889 additions
and
515 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
SHELL=/bin/bash | ||
DOMAIN="benchmark.js.ipfs.io" | ||
|
||
IPFSLOCAL="http://localhost:8080/ipfs/" | ||
IPFSGATEWAY="https://ipfs.io/ipfs/" | ||
NPM=npm | ||
NPMBIN=./node_modules/.bin | ||
OUTPUTDIR=dist | ||
PREPEND=@ | ||
|
||
build: | ||
@echo "Installing npm modules..." | ||
$(PREPEND)npm install && \ | ||
echo "" && \ | ||
echo "Installed npm modules" | ||
$(PREPEND)npm run build | ||
@echo "All files built to ./$(OUTPUTDIR)"; | ||
@echo ""; | ||
@echo "Next steps (make sure you have ipfs deamon running):"; | ||
@echo "- make deploy"; | ||
@echo ""; | ||
|
||
help: | ||
@echo 'Makefile for ipfs benchmarks' | ||
@echo ' ' | ||
@echo 'Usage: ' | ||
@echo ' make Build the optimised site to ./$(OUTPUTDIR) ' | ||
@echo ' make deploy Add the website to your local IPFS node ' | ||
@echo ' make publish-to-domain Update $(DOMAIN) DNS record to the ipfs hash from the last deploy ' | ||
@echo ' ' | ||
|
||
deploy: | ||
$(PREPEND)ipfs add -r -q $(OUTPUTDIR) | tail -n1 >versions/current ; \ | ||
cat versions/current >>versions/history ; \ | ||
export hash=`cat versions/current`; \ | ||
echo ""; \ | ||
echo "published website:"; \ | ||
echo "- $(IPFSLOCAL)$$hash"; \ | ||
echo "- $(IPFSGATEWAY)$$hash"; \ | ||
echo ""; \ | ||
echo "next steps:"; \ | ||
echo "- ipfs pin add -r /ipfs/$$hash"; \ | ||
echo "- make publish-to-domain"; \ | ||
|
||
publish-to-domain: versions/current | ||
DNSIMPLE_TOKEN="$(shell if [ -f auth.token ]; then cat auth.token; else cat $HOME/.protocol/dnsimple.ipfs.io.token; fi)" \ | ||
./dnslink.sh $(DOMAIN) $(shell cat versions/current) | ||
|
||
.PHONY: build help install deploy publish-to-domain clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Usage: | ||
# DNSIMPLE_TOKEN=<token> ./dnslink.sh <domain> <hash> | ||
# | ||
# Example: | ||
# DNSIMPLE_TOKEN=trustno1 ./dnslink.sh website.protocol.ai Qmfoobar | ||
# | ||
# Dependencies: | ||
# - bash | ||
# - curl | ||
# - jq | ||
# | ||
# From: | ||
# https://raw.githubusercontent.com/ipfs/infrastructure/master/scripts/dnslink.sh | ||
# | ||
|
||
set -e | ||
|
||
ZONE="$1" | ||
HASH="$2" | ||
|
||
([ ! -z "$DNSIMPLE_TOKEN" ] && [ ! -z "$ZONE" ] && [ ! -z "$HASH" ]) \ | ||
|| (echo "Usage: DNSIMPLE_TOKEN=<token> ./dnslink.sh <domain> <hash>" && exit 1) | ||
|
||
RECORD_NAME="_dnslink" | ||
RECORD_TTL=120 | ||
|
||
record_id=$( | ||
curl -v -s "https://api.dnsimple.com/v1/domains/$ZONE/records?name=$RECORD_NAME&type=TXT" \ | ||
-H "X-DNSimple-Domain-Token: $DNSIMPLE_TOKEN" \ | ||
-H "Accept: application/json" \ | ||
| jq -r '.[].record.id' | ||
) | ||
|
||
if [ -z "$record_id" ]; then | ||
curl -v -s -X POST "https://api.dnsimple.com/v1/domains/$ZONE/records" \ | ||
-H "X-DNSimple-Domain-Token: $DNSIMPLE_TOKEN" \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type: application/json" \ | ||
-d "{\"record\":{ \"name\":\"$RECORD_NAME\", \"record_type\":\"TXT\", \"content\":\"dnslink=/ipfs/$HASH\", \"ttl\":\"$RECORD_TTL\" }}" \ | ||
| jq -r '.record' \ | ||
&& printf "\\nIt looks like we're good: https://ipfs.io/ipns/$ZONE\\n" | ||
else | ||
curl -v -s -X PUT "https://api.dnsimple.com/v1/domains/$ZONE/records/$record_id" \ | ||
-H "X-DNSimple-Domain-Token: $DNSIMPLE_TOKEN" \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type: application/json" \ | ||
-d "{\"record\":{ \"content\":\"dnslink=/ipfs/$HASH\", \"name\":\"$RECORD_NAME\", \"ttl\":\"$RECORD_TTL\" }}" \ | ||
| jq -r '.record' \ | ||
&& printf "\\nIt looks like we're good: https://ipfs.io/ipns/$ZONE\\n" | ||
fi |
Oops, something went wrong.