better structure

This commit is contained in:
dockeradm
2023-07-11 11:08:49 +02:00
parent f43314c405
commit e542fa3427
+17 -18
View File
@@ -70,16 +70,15 @@ startSWSifNotRunning () {
}
# pull new data an build site
pullAndBuild () {
echo "getting new data"
git pull origin "${GITBRANCHNAME}" --allow-unrelated-histories --ff-only || errorAndExit "can't pull content repository" 1
echo "build website with newer data to ${OUTPUT_DIR}"
zola build --force --base-url "${BASE_URL}" --output-dir "${OUTPUT_DIR}" || errorAndExit "can't build website" 2
buildSite () {
goProjectPath
echo "build website with newer data to ${OUTPUT_DIR}"
zola build --force --base-url "${BASE_URL}" --output-dir "${OUTPUT_DIR}" || errorAndExit "can't build website" 2
}
goProjectPath () {
echo "change into project directory ${HOME}/${GITPROJECTNAME}"
cd "${HOME}/${GITPROJECTNAME}" || exit 5
cd "${HOME}/${GITPROJECTNAME}" || errorAndExit "error on changing into project path" 5
}
# write error text into err console and exit
@@ -118,12 +117,14 @@ getTheme () {
then
echo "clone theme with ${GITTHEMECLONEURL} ${THEME_NAME}"
git clone -b "${GITBRANCHNAME}" "${GITTHEMECLONEURL}" "${THEME_NAME}" || errorAndExit "can't clone theme" 3
buildSite
echo "change into themes directory"
cd ./themes || errorAndExit "can't change into themes directory" 2
fi
if [ -d ./"${THEME_NAME}" ]
then
echo "change into theme directory ${THEME_NAME}"
cd ./"${THEME_NAME}" || errorAndExit "can't change into theme directory" 2
# check if there are changes in the theme repository
echo "check if there are changes in the theme repository"
git fetch || errorAndExit "can't fetch theme repository" 4
if git diff --quiet FETCH_HEAD;
@@ -135,8 +136,7 @@ getTheme () {
echo "integrate external libraries"
make || errorAndExit "error interate external libraries" 6
fi
goProjectPath
pullAndBuild
buildSite
else
goProjectPath
fi
@@ -153,7 +153,8 @@ getContent () {
if git diff --quiet FETCH_HEAD;
then
echo "getting updated content"
pullAndBuild
git pull origin "${GITBRANCHNAME}" --allow-unrelated-histories --ff-only || errorAndExit "can't pull content repository" 1
buildSite
fi
}
@@ -174,19 +175,17 @@ zola --version
echo "checking local repository directory"
if [ ! -d "${GITPROJECTNAME}" ]; then
echo "no local repository directory found, cloning ${GITPROJECTNAME} from ${GITCLONEURL}"
git clone -b "${GITBRANCHNAME}" "${GITCLONEURL}" || exit 9
echo "change into project path ${GITPROJECTNAME}"
cd "${GITPROJECTNAME}" || exit 6
getTheme
getContent
git clone -b "${GITBRANCHNAME}" "${GITCLONEURL}" || errorAndExit "error cloning project" 9
goProjectPath
getTheme
fi
while true
do
getTheme
getContent
getContent
getTheme
startSWSifNotRunning
echo "Sleeping for ${IDLE_TIME} seconds"
echo "Sleeping for ${IDLE_TIME} seconds"
sleep "${IDLE_TIME}"
done