Swarmlab docs

Application development in a distributed system

Development of Distributed Systems from Design to Application


You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

221 lines
4.6 KiB

#!/bin/bash
#SERVICE_URL=https://git.swarmlab.io:3000/docs/Documentation.git
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
#echo $cwdir
#echo $wdir
txturl='\033[1;36m'
txturl1='\033[0;36m'
txtg='\033[0;32m'
NOCOLOR='\033[0m'
usage ()
{
echo ""
echo " No argument supplied"
echo ""
echo "--------------"
echo " create Swarmlab.io Doc "
echo "--------------"
echo ""
echo " USAGE: ./init-docs.sh [OPTIONS]"
echo ""
echo " Examples of [OPTIONS] can be:"
echo ""
echo -e " ${txtg}[docname]:${NOCOLOR} You can use upper and lowercase letters, numbers, “.” (dot), and “_” (underscore) symbols. "
echo ""
echo ""
echo " "
}
if [[ $# -eq 0 ]] ; then
usage
exit 1
fi
if [[ -z "$1" ]] ; then
usage
exit 1
else
pdir="$(dirname "$wdir")"
dname="$pdir/$1"
#echo $pdir
#echo $dname
if [[ -d "$dname" ]] ; then
echo ""
echo "--------------"
echo -e "Directory ${txtg} ${dname} ${NOCOLOR} ${txturl} exists ${NOCOLOR}"
echo "--------------"
echo ""
exit 1
fi
. $wdir/config.ini
SERVICE_NAME=$1
SERVICE_NAME_MENOU=$1
echo ""
echo "Default parameters are:"
echo -e "SERVICE_URL=${txtg}${SERVICE_URL}${NOCOLOR}"
echo -e "SERVICE_NAME=${txtg}${SERVICE_NAME}${NOCOLOR}"
echo -e "SERVICE_NAME_MENOU=${txtg}${SERVICE_NAME_MENOU}${NOCOLOR}"
echo -e "You can change this setting in: ${txturl} config.ini ${NOCOLOR}"
echo ""
echo "Do you wish to create this in $dname?"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit;;
esac
done
if [[ $yn == 'Yes' ]];then
mkdir -p $dname
if [[ ! -d "$dname" ]] ; then
echo ""
echo "--------------"
echo -e "mkdir: cannot create directory ${txtg} ${dname} ${NOCOLOR}"
echo "--------------"
echo ""
exit 1
fi
cd $wdir
cp -rf modules ${dname}
cp -rf supplemental-ui ${dname}
cp -rf run ${dname}
cp -f build.sh ${dname}
cp -f build-local.sh ${dname}
cp -f antora.yml ${dname}
cp -f site.yml ${dname}
cp -f push.sh ${dname}
if [[ ! -d "${dname}/modules" || ! -d "${dname}/supplemental-ui" || ! -d "${dname}/run" || ! -f "${dname}/antora.yml" || ! -f "${dname}/site.yml" || ! -f "${dname}/build.sh" || ! -f "${dname}/push.sh" ]] ; then
echo ""
echo "--------------"
echo -e "cannot create template in directory ${txtg} ${dname} ${NOCOLOR}"
echo "--------------"
echo ""
exit 1
fi
cat << EOF > ${dname}/antora.yml
name: ${SERVICE_NAME}
title: ${SERVICE_NAME}
version: docs
nav:
- modules/ROOT/nav.adoc
EOF
cat << EOF > ${dname}/site.yml
site:
title: Swarmlab ${SERVICE_NAME}
url: http://docs.swarmlab.io/SwarmLab-HowTos/swarmlab/docs
start_page: ${SERVICE_NAME}::index.adoc
content:
sources:
- url: ${SERVICE_URL}
branches: master
start_path: ${SERVICE_NAME_MENOU}
ui:
bundle:
url: https://git.swarmlab.io:3000/docs/docs/raw/branch/master/ui-bundle.zip
snapshot: true
supplemental_files: ./supplemental-ui
asciidoc:
attributes:
:plantuml-server-url: http://www.plantuml.com/plantuml
extensions:
- '@djencks/asciidoctor-mathjax'
- asciidoctor-plantuml
EOF
cat << EOF > ${dname}/site-local.yml
site:
title: Swarmlab ${SERVICE_NAME}
url: http://docs.swarmlab.io/SwarmLab-HowTos/swarmlab/docs
start_page: ${SERVICE_NAME}::index.adoc
content:
sources:
- url: /antora
branches: master
start_path: ${SERVICE_NAME_MENOU}
ui:
bundle:
url: https://git.swarmlab.io:3000/docs/docs/raw/branch/master/ui-bundle.zip
snapshot: true
supplemental_files: ./supplemental-ui
asciidoc:
attributes:
:plantuml-server-url: http://www.plantuml.com/plantuml
extensions:
- '@djencks/asciidoctor-mathjax'
- asciidoctor-plantuml
EOF
cat << EOF > ${dname}/modules/ROOT/nav.adoc
* xref:index.adoc[${SERVICE_NAV_MENOU}]
EOF
cat << EOF > ${dname}/modules/ROOT/nav.adoc
* xref:index.adoc[${SERVICE_NAV_MENOU}]
EOF
cat << EOF > ${dname}/modules/ROOT/pages/index.adoc
= ${SERVICE_NAME_MENOU}
image::ROOT:swarmlab.png[swarmlab,150,float=right]
This tutorial demonstrates: *a.* howto create a Swarmlab.io doc wit asciidoc
== Intro
*intro* here
EOF
fi
cd $cwdir
fi