Add scripts for installing uniswap on remote urbit instance

This commit is contained in:
Prathamesh Musale 2023-12-01 14:57:28 +05:30
parent 28bd4bb509
commit 8020f1c6b5
2 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,109 @@
#!/bin/bash
# $1: Glob file URL (eg. https://xyz.com/glob-abcd.glob)
# $2: Uniswap desk dir (default: ./zod/uniswap)
if [ -z "$1" ]; then
echo "Glob file URL arg not provided"
exit 0
fi
glob_url=$1
glob_file=$(basename "$glob_url")
glob_hash=$(echo "$glob_file" | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
echo "Using glob file ${glob_file}"
# Default desk dir: ./zod/uniswap
uniswap_desk_dir="${2:-./zod/uniswap}"
echo "Using ${uniswap_desk_dir} as the Uniswap desk dir path"
# Fire curl requests to perform operations on the ship
dojo () {
curl -s --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' http://localhost:12321
}
hood () {
curl -s --data '{"source":{"dojo":"+hood/'"$1"'"},"sink":{"app":"hood"}}' http://localhost:12321
}
# Create/mount a uniswap desk
hood "merge %uniswap our %landscape"
hood "mount %uniswap"
# Create a mark file for .map file type
cat << EOF > "${uniswap_desk_dir}/mar/map.hoon"
::
:::: /hoon/map/mar
:: Mark for js source maps
/? 310
::
=, eyre
|_ mud=@
++ grow
|%
++ mime [/application/octet-stream (as-octs:mimes:html (@t mud))]
--
++ grab
|% :: convert from
++ mime |=([p=mite q=octs] (@t q.q))
++ noun cord :: clam from %noun
--
++ grad %mime
--
EOF
# Create a mark file for .woff file type
cat << EOF > "${uniswap_desk_dir}/mar/woff.hoon"
|_ dat=octs
++ grow
|%
++ mime [/font/woff dat]
--
++ grab
|%
++ mime |=([=mite =octs] octs)
++ noun octs
--
++ grad %mime
--
EOF
# Create a mark file for .ttf file type
cat << EOF > "${uniswap_desk_dir}/mar/ttf.hoon"
|_ dat=octs
++ grow
|%
++ mime [/font/ttf dat]
--
++ grab
|%
++ mime |=([=mite =octs] octs)
++ noun octs
--
++ grad %mime
--
EOF
rm "${uniswap_desk_dir}/desk.bill"
rm "${uniswap_desk_dir}/desk.ship"
# Update the docket file
cat << EOF > "${uniswap_desk_dir}/desk.docket-0"
:~ title+'Uniswap'
info+'Self-hosted uniswap frontend.'
color+0xcd.75df
image+'https://logowik.com/content/uploads/images/uniswap-uni7403.jpg'
base+'uniswap'
glob-http+['${glob_url}' ${glob_hash}]
version+[0 0 1]
website+'https://uniswap.org/'
license+'MIT'
==
EOF
# Commit changes and install the app
hood "commit %uniswap"
hood "install our %uniswap"
echo "Uniswap app installed"

View File

@ -0,0 +1,18 @@
#!/bin/bash
# $1: Remote user host
# $2: Path to run the app installation in (where urbit ship dir is located)
# $3: Glob file URL (eg. https://xyz.com/glob-abcd.glob)
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <username@remote_host> </path/to/remote/folder> <glob_url>"
exit 1
fi
remote_user_host="$1"
remote_folder="$2"
glob_url="$3"
installation_script="./install-uniswap-app.sh"
ssh "$remote_user_host" "cd $remote_folder && bash -s $glob_url" < "$installation_script"