on b286e73 help sign in
73 lines 2.0 kB history raw
1#!/usr/bin/env bash
3# Use this script to automate building the website. You'll need a fresh copy of
4# the repository and a fresh fakezod booted with the static-site-dev branch of
5# Arvo. The site is built in two steps because Urbit typically runs out of
6# memory before finishing a full build. One fakezod is usually good for only a
7# single build.
9# Strip trailing slashes on input parameters
11site=${1%/}
12ship=${2%/}
14# Copy static_site to ship
16copy_static_site ()
18 echo -e "- Copying source files from $site to $ship"
19 rm -rf $ship/home/web
20 cp -r $site/static-site $ship/home/web
21 cp $site/static-site/index.hoon $ship/home/web.hoon
22 rm -rf $ship/home/ren/partials
23 cp -r $site/partials $ship/home/ren/partials
24 cp $site/urb.hoon $ship/home/ren
27# Print instructions if both parameters aren't provided
29if [[ $# -lt 2 ]] ; then
30 printf '- This command needs two arguments:\n(1) the path to your urbit.org repository\n(2) the path to your pier\n'
31 exit 0
32fi
34# Print instructions
36read -n1 -s -r -p $'- Boot your fakezod and run |mount %, then press any key to continue\n'
38# Create dist folder
40dist="dist-$(date -u '+%Y.%-m.%-d...%H.%M.%S')"
41mkdir $dist
43# Second render with |static in urbit (posts)
45copy_static_site $site $ship
46rm -rf $ship/home/web/docs
47read -n1 -s -r -p $'- Wait for sync, then run |static in your urbit, wait for it to finish, then press any key to continue\n'
49# Copy results of first render (posts) to dist folder
51echo -e "- Copying posts from $site to $ship"
52cp -r $ship/.urb/put/web/* $dist
54# First render with |static in urbit (docs)
56copy_static_site $site $ship
57rm -rf $ship/home/web/posts
58read -n1 -s -r -p $'- Wait for sync, then run |static in your urbit again, wait for it to finish, then press any key to continue\n'
60# Copy results of second render (docs) to dist folder
62rsync -av --ignore-existing $ship/.urb/put/web/* $dist
64# Remove unecessary files
66rm -rf $dist/index
68# Copy js directory
70rm -rf $dist/js/*
71cp -r $site/static-site/js $dist
73echo -e "- Find your website in $dist"