2016-02-22 21:06:34 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-05-04 10:06:48 +00:00
|
|
|
# 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
|
|
|
|
|
2021-05-04 10:06:48 +00:00
|
|
|
MAN_LOCATION='man/man1'
|
|
|
|
MAN7_LOCATION='man/man7'
|
|
|
|
POSTS_LOCATION='docs/_posts'
|
2016-02-22 21:06:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
function checkout_manuals {
|
2021-05-04 10:06:48 +00:00
|
|
|
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:
|
2016-08-21 13:37:20 +00:00
|
|
|
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:
|
2021-05-04 10:06:48 +00:00
|
|
|
for com in $MAN_LOCATION/git-secret-*.1.md; do
|
2016-08-21 13:37:20 +00:00
|
|
|
local short_name
|
2021-05-04 10:06:48 +00:00
|
|
|
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}
|
2016-08-21 13:37:20 +00:00
|
|
|
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}
|
2016-08-21 13:37:20 +00:00
|
|
|
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"
|
2021-05-04 10:06:48 +00:00
|
|
|
cat "$MAN7_LOCATION/git-secret.7.md" >> "$usage_filename"
|
2016-02-22 21:06:34 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 12:59:55 +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
|
2021-05-06 10:17:18 +00:00
|
|
|
cp utils/apk/install.sh docs/_includes/install-akp.sh
|
2021-05-05 12:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-22 21:06:34 +00:00
|
|
|
checkout_manuals
|
|
|
|
copy_to_posts
|
2021-05-05 12:59:55 +00:00
|
|
|
copy_install_scripts
|