mirror of
https://github.com/Anon-Planet/thgtoa.git
synced 2025-04-19 07:25:54 -04:00
Move scripts to their own dir (aptly named script)
Move scripts to their own directory. Add `serve` script for serving locally (from internal build repo). Rename: - clean.sh -> script/clean - make.sh -> script/make Now you can type `make serve` to serve the guide locally. $ make <TAB> all clean guide serve Requirements are still included in the `serve` file. Signed-off-by: Sharp-tailed Grouse <sharptail@riseup.net>
This commit is contained in:
parent
04f7307910
commit
7c1762289a
30
Makefile
30
Makefile
@ -1,15 +1,15 @@
|
||||
all: guide
|
||||
|
||||
guide: clean
|
||||
./script/make.sh
|
||||
|
||||
.phony: serve
|
||||
serve: # This gets all gems and installs bundler.
|
||||
# Serves the guide locally using Jekyll. 🍽️
|
||||
@echo "Serving site..."
|
||||
./script/serve.sh
|
||||
|
||||
clean: # Clean artifacts. 🧹
|
||||
@echo "Cleaning..."
|
||||
./script/clean.sh
|
||||
|
||||
all: guide
|
||||
|
||||
guide: clean
|
||||
./script/make
|
||||
|
||||
.phony: serve
|
||||
serve: # This gets all gems and installs bundler.
|
||||
# Serves the guide locally using Jekyll. 🍽️
|
||||
@echo "Serving site..."
|
||||
./script/serve
|
||||
|
||||
clean: # Clean artifacts. 🧹
|
||||
@echo "Cleaning..."
|
||||
./script/clean
|
||||
|
||||
|
54
script/README.md
Normal file
54
script/README.md
Normal file
@ -0,0 +1,54 @@
|
||||
### Serving locally (system-wide):
|
||||
|
||||
- Ruby >=2.7.3 needs to be installed
|
||||
- Git needs to be installed
|
||||
- Move this file to the root dir (the clone dir)
|
||||
- Don't run directly as `root`
|
||||
- Needs to be executed with sudo permissions
|
||||
* Essentially, `sudo ./serve`
|
||||
- Ignore the errors of "gem update"
|
||||
|
||||
### Serving locally (as user only):
|
||||
|
||||
- Ruby >=2.7.3 needs to be installed (with sudo)
|
||||
- Git needs to be installed (with sudo)
|
||||
- Move this file to the root dir (the clone dir)
|
||||
- Add the following to your user's `.profile`:
|
||||
|
||||
```
|
||||
GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
|
||||
PATH="$PATH:$GEM_HOME/bin"
|
||||
```
|
||||
|
||||
### Run the build script:
|
||||
|
||||
> cp ./serve ../../
|
||||
> cd thgtoa/
|
||||
> sudo ./serve
|
||||
[sudo] password for <user>:
|
||||
|
||||
...snip...
|
||||
|
||||
Wait a while for this to finish (first run takes a few minutes).
|
||||
Now you have updated the gem dependencies.
|
||||
|
||||
### Congrats, it's a...bundle:
|
||||
|
||||
Bundle complete! 2 Gemfile dependencies, 92 gems now installed.
|
||||
Use `bundle info [gemname]` to see where a bundled gem is installed.
|
||||
|
||||
### Serve the site locally:
|
||||
> sudo bundle exec jekyll serve
|
||||
...snip ...
|
||||
|
||||
Server address: http://127.0.0.1:4000
|
||||
Server running... press ctrl-c to stop.
|
||||
|
||||
You are now free to make your desired changes for the guide.
|
||||
You can clone remotes and test them here, you can do whatever.
|
||||
|
||||
### Non-root user install:
|
||||
|
||||
- <https://wiki.archlinux.org/title/ruby#Setup>
|
||||
- <https://gist.github.com/MichaelCurrin/ddbcfb1714c4dbfb3460a3ecf119620f>
|
||||
- <https://github.com/MichaelCurrin/learn-to-code/blob/master/en/topics/scripting_languages/Ruby/README.md#install-and-upgrade>
|
12
script/clean
Normal file
12
script/clean
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm *.pdf &> /dev/null
|
||||
rm *.html &> /dev/null
|
||||
rm *.odt &> /dev/null
|
||||
rm *.minisig &> /dev/null
|
||||
rm *.asc &> /dev/null
|
||||
rm sha256sum.txt &> /dev/null
|
||||
rm b2sum.txt &> /dev/null
|
||||
rm -r export/{.,}* &> /dev/null
|
||||
|
||||
true
|
45
script/make
Normal file
45
script/make
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$1" == "" ]]; then
|
||||
# Build all `md` files
|
||||
for f in *.md; do
|
||||
echo "Building: $f"
|
||||
bn="$(basename "$f" .md)"
|
||||
"$0" "$bn"
|
||||
done
|
||||
echo "Built all documents. Calculating hashes..."
|
||||
cd export/
|
||||
sha256sum ./* > sha256sum.txt
|
||||
b2sum ./* > b2sum.txt
|
||||
echo "Calculated hashes. Signing generated files..."
|
||||
for f in ./*; do
|
||||
echo "Signing: $f"
|
||||
# verify with GPG
|
||||
gpg --armor --detach-sign --sign "$f"
|
||||
# verify with `minisign -Vm <file> -P RWQ0WYJ07DUokK8V/6LNJ9bf/O/QM9k4FSlDmzgEeXm7lEpw3ecYjXDM`
|
||||
yes '' | minisign -S -s /home/user/.minisign/minisign.key -m "$f"
|
||||
done
|
||||
cd ../
|
||||
cp /home/user/KEY_ROTATION.md.7DFFD7471FB76E2A8ABBBCDDD769B3749E933B8A.asc ./KEY_ROTATION.md.asc
|
||||
cp /home/user/KEY_ROTATION.md.902835EC74825934.minisig ./KEY_ROTATION.md.minisig
|
||||
gpg --armor --export 42FF35DB9DE7C088AB0FD4A70C216A52F6DF4920 > 42FF35DB9DE7C088AB0FD4A70C216A52F6DF4920.asc
|
||||
sha256sum *.md > sha256sum.txt
|
||||
gpg --armor --detach-sign sha256sum.txt
|
||||
yes '' | minisign -S -s /home/user/.minisign/minisign.key -m sha256sum.txt
|
||||
b2sum *.md > b2sum.txt
|
||||
gpg --armor --detach-sign b2sum.txt
|
||||
yes '' | minisign -S -s /home/user/.minisign/minisign.key -m b2sum.txt
|
||||
echo "Signed all files."
|
||||
echo "Done."
|
||||
exit
|
||||
fi
|
||||
|
||||
bn="$1"
|
||||
|
||||
#echo "Generating HTML..."
|
||||
#pandoc --self-contained "$bn".md -o export/"$bn".html --metadata title="The Hitchhiker's Guide to Online Anonymity"
|
||||
#echo "Generating PDF..."
|
||||
#pandoc --self-contained "$bn".md -o export/"$bn".pdf --metadata title="The Hitchhiker's Guide to Online Anonymity" -t context
|
||||
#echo "Generating ODT..."
|
||||
#pandoc --self-contained "$bn".md -o export/"$bn".odt --metadata title="The Hitchhiker's Guide to Online Anonymity"
|
||||
|
37
script/serve
Normal file
37
script/serve
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Prerequisites:
|
||||
# 1. git
|
||||
# 2. ruby
|
||||
# 3. ruby-dev
|
||||
#
|
||||
# Script MUST be in the root of the git clone directory of your choice.
|
||||
# You MUST execute it with elevated privileges.
|
||||
#
|
||||
# When done you can execute these commands:
|
||||
# $ bundle exec jekyll serve --livereload (will build and serve the project locally)
|
||||
# $ bundle exec jekyll build (will build the site in _site folder)
|
||||
|
||||
gem update # Errors are safely ignored.
|
||||
gem install bundler jekyll # Speaks for itself.
|
||||
rm -f Gemfile* # Out with the old..
|
||||
bundle init # ..and in with the new.
|
||||
rm -rf ./vendor/ # In case `bundle init` above does anything weird.
|
||||
|
||||
# Creating the Gemfile we want
|
||||
cat <<EOF >Gemfile
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
# gem "rails"
|
||||
|
||||
# gem "jekyll", "~> 4.2"
|
||||
gem "github-pages", group: :jekyll_plugins
|
||||
gem "jekyll-optional-front-matter", group: :jekyll_plugins
|
||||
gem "webrick", "~> 1.7"
|
||||
EOF
|
||||
bundle install # this will install gems and create a new Gemfile.lock
|
||||
|
||||
echo "Now you can test locally: "
|
||||
echo "$ bundle exec jekyll serve --livereload"
|
49
script/serve-as-user
Normal file
49
script/serve-as-user
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Prerequisites:
|
||||
# 1. git
|
||||
# 2. ruby
|
||||
# 3. ruby-dev
|
||||
#
|
||||
# Script MUST be in the root of the git clone directory of your choice.
|
||||
# You MUST execute it with elevated privileges.
|
||||
#
|
||||
# When done you can execute these commands:
|
||||
# $ bundle exec jekyll serve --livereload (will build and serve the project locally)
|
||||
# $ bundle exec jekyll build (will build the site in _site folder)
|
||||
|
||||
function pause()
|
||||
{
|
||||
read -p "$*"
|
||||
}
|
||||
|
||||
echo add the following to your non-root .profile:
|
||||
echo '''export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"'''
|
||||
echo '''export PATH="$PATH:$GEM_HOME/bin"'''
|
||||
|
||||
pause 'Press [Enter] key to continue...'
|
||||
|
||||
sudo gem update # Errors are safely ignored.
|
||||
gem install bundler --user-install # Speaks for itself.
|
||||
gem install jekyll --user-install # Speaks for itself.
|
||||
rm -f Gemfile* # Out with the old..
|
||||
bundle init # ..and in with the new.
|
||||
rm -rf ./vendor/ # In case `bundle init` above does anything weird.
|
||||
|
||||
# Creating the Gemfile we want
|
||||
cat <<EOF >Gemfile
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
# gem "rails"
|
||||
|
||||
# gem "jekyll", "~> 4.2"
|
||||
gem "github-pages", group: :jekyll_plugins
|
||||
gem "jekyll-optional-front-matter", group: :jekyll_plugins
|
||||
gem "webrick", "~> 1.7"
|
||||
EOF
|
||||
bundle install --user-install # this will install gems and create a new Gemfile.lock
|
||||
|
||||
echo "Now you can test locally: "
|
||||
echo "$ bundle exec jekyll serve --livereload"
|
Loading…
x
Reference in New Issue
Block a user