-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathasciidoc-build-upload-open.sh
executable file
·33 lines (26 loc) · 1.57 KB
/
asciidoc-build-upload-open.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Avital Pinnick, 2022
# This script builds a downstream preview with Asciidoctor and uploads it to your remote drive.
# You must have Asciidoctor installed ($ sudo dnf install asciidoctor).
# You must be in the same directory as the master.adoc file.
# You must set up a remote drive and copy your SSH key.
# You must also clean up your drive manually from time to time so that you do not run out of space.
# I decided not to use the date as part of the path. We can add it if we want to keep versions separated by dates as well as GitHub branches.
# DATE=$(date +"%m-%d-%y")
# You must set these variables.
KERB="apinnick"
GEO="tlv"
# This is the directory or guide name so that different books can be uploaded for the same branch, for example, 'branch_name/administration_guide/'.
DIR=$(pwd | xargs basename)
BRANCH=$(git branch --show-current)
asciidoctor -o index.html master.adoc
if ssh $KERB@file.$GEO.redhat.com "test -e ~/public_html/$BRANCH/$DIR/"; then
echo -e "\nDirectory exists. Updating preview."
rsync -az --info=progress2 --human-readable index.html images ../common $KERB@file.$GEO.redhat.com:~/public_html/$BRANCH/$DIR/
else
echo -e "\nCreating directory and uploading preview."
rsync -az --rsync-path="mkdir -p ~/public_html/$BRANCH/$DIR/ && rsync" --info=progress2 --human-readable index.html images ../common $KERB@file.$GEO.redhat.com:~/public_html/$BRANCH/$DIR/
fi
echo -e "\nYou can view your preview at http://file.$GEO.redhat.com/$KERB/$BRANCH/$DIR/index.html"
echo -e "***Important***\nYou must be connected to the VPN to view this file.\n"
rm index.html