git-secret/create_posts.sh

74 lines
1.7 KiB
Bash
Raw Normal View History

2016-02-22 21:06:34 +00:00
#!/usr/bin/env bash
# Should be called from the root folder, not inside `docs/` folder
# See `make build-docs`
2016-02-22 21:06:34 +00:00
set -e
MAN_LOCATION='man/man1'
MAN7_LOCATION='man/man7'
POSTS_LOCATION='docs/_posts'
2016-02-22 21:06:34 +00:00
function checkout_manuals {
cp -r man/ docs/man
2016-02-22 21:06:34 +00:00
}
function copy_to_posts {
# Cleaning old files:
2016-03-13 09:26:28 +00:00
rm -f "$POSTS_LOCATION/*.md"
2016-05-12 13:20:39 +00:00
rm -rf "$POSTS_LOCATION"
mkdir -p "$POSTS_LOCATION"
2016-02-22 21:06:34 +00:00
# Moving new command files:
local timestamp
local current_date
timestamp=$(date "+%Y-%m-%d %H:%M:%S %z")
current_date=$(date "+%Y-%m-%d")
2016-02-22 21:06:34 +00:00
2016-02-22 21:23:03 +00:00
# Creating command refernce:
for com in $MAN_LOCATION/git-secret-*.1.md; do
local short_name
short_name=$(echo "$com" | sed -n "s|$MAN_LOCATION/\(.*\)\.1\.md|\1|p")
2016-02-22 21:06:34 +00:00
local command_header="---
layout: post
title: '${short_name}'
date: ${timestamp}
permalink: ${short_name}
2016-02-22 21:06:34 +00:00
categories: command
---"
local post_filename="$POSTS_LOCATION/${current_date}-${short_name}.md"
echo "$command_header" > "$post_filename"
cat "$com" >> "$post_filename"
done
2016-02-22 21:23:03 +00:00
# Creating main usage file:
local usage_header="---
layout: post
title: 'git-secret'
date: ${timestamp}
permalink: git-secret
2016-02-22 21:23:03 +00:00
categories: usage
---"
local usage_filename="$POSTS_LOCATION/${current_date}-git-secret.md"
echo "$usage_header" > "$usage_filename"
cat "$MAN7_LOCATION/git-secret.7.md" >> "$usage_filename"
2016-02-22 21:06:34 +00:00
}
function copy_install_scripts {
# We test these scripts using `release-ci`,
# so, installation instructions will always be up-to-date:
cp utils/deb/install.sh docs/_includes/install-deb.sh
cp utils/rpm/install.sh docs/_includes/install-rpm.sh
cp utils/apk/install.sh docs/_includes/install-akp.sh
}
2016-02-22 21:06:34 +00:00
checkout_manuals
copy_to_posts
copy_install_scripts