factor out inject-json.sh

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-27 21:19:32 +01:00
parent 249dbb0471
commit b5e4f53357
4 changed files with 60 additions and 23 deletions

34
dev/inject-json.sh Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
##############################################################
#
# File: inject-json.sh
#
# Description: download and prepare JSON.sh and JSON.awk
#
# Usage: source inject-json.sh
#
#### $$VERSION$$ v1.21-dev-17-g8c9298d
##############################################################
# download JSON.sh
JSONSHFILE="JSON.sh/JSON.sh"
if [ ! -r "${JSONSHFILE}" ]; then
printf "Inject JSON.sh ... "
mkdir "JSON.sh" 2>/dev/null
curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/dominictarr/JSON.sh/JSON.sh"
chmod +x "${JSONSHFILE}"
printf "Done!\n"
fi
# download JSON.awk
JSONSHFILE="JSON.sh/JSON.awk"
if [ ! -r "${JSONSHFILE}" ]; then
printf "Inject JSON.awk ... "
curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/JSON.awk"
curl -sL -o "${JSONSHFILE%/*}/awk-patch.sh" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/tool/patch-for-busybox-awk.sh"
printf "Done!\n"
bash "${JSONSHFILE%/*}/awk-patch.sh" "${JSONSHFILE%/*}/JSON.awk"
fi
# delete backup files
rm -f "${JSONSHFILE%/*}"/*.bak

View File

@ -7,7 +7,7 @@
#
# Options: --notest - skip tests
#
#### $$VERSION$$ v1.21-dev-16-geedd0b3
#### $$VERSION$$ v1.21-dev-17-g8c9298d
##############################################################
# magic to ensure that we're always inside the root of our application,
@ -53,22 +53,9 @@ do
mv "${file}" "${file}.dist"
done
# dwonload JSON.sh
echo "Inject JSON.sh"
JSONSHFILE="JSON.sh/JSON.sh"
if [ ! -r "${JSONSHFILE}" ]; then
mkdir "JSON.sh" 2>/dev/null
curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/dominictarr/JSON.sh/JSON.sh"
chmod +x "${JSONSHFILE}"
fi
echo "Inject JSON.awk"
JSONSHFILE="JSON.sh/JSON.awk"
if [ ! -r "${JSONSHFILE}" ]; then
curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/JSON.awk"
curl -sL -o "${JSONSHFILE%/*}/awk-patch.sh" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/tool/patch-for-busybox-awk.sh"
bash "${JSONSHFILE%/*}/awk-patch.sh" "${JSONSHFILE%/*}/JSON.awk"
fi
rm -f "${JSONSHFILE%/*}"/*.bak
# inject JSON.sh into distribution
# shellcheck disable=SC1090
source "$GIT_DIR/../dev/inject-json.sh"
# make html doc
echo "Create html doc"

View File

@ -1,7 +1,14 @@
data-bot-bash/*
*.jssh
*.jssh*
botacl
*.flock
*.log
*.last
*.ok
*.bad
*.bak
*.jpg
*.jpeg
*.png
*.zip
*.gz

View File

@ -1,11 +1,16 @@
#!/usr/bin/env bash
# file: make-standalone.sh
# even after make-distribution.sh bashbot is not self contained as it was in the past.
###################################################################
#
# If you your bot is finished you can use make-standalone.sh to create the
# the old all-in-one bashbot: bashbot.sh and commands.sh only!
# File: make-standalone.sh
#
#### $$VERSION$$ v1.20-0-g2ab00a2
# Description:
# even after make-distribution.sh bashbot is not self contained as it was in the past.
#
# If you your bot is finished you can use make-standalone.sh to create the
# the old all-in-one bashbot: bashbot.sh and commands.sh only!
#
#### $$VERSION$$ v1.21-dev-17-g8c9298d
###################################################################
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
@ -30,6 +35,10 @@ mkdir -p "${DISTDIR}" 2>/dev/null
cp -r ${DISTFILES} "${DISTDIR}" 2>/dev/null
cd "${DISTDIR}" || exit 1
# inject JSON.sh into distribution
# shellcheck disable=SC1090
source "$GIT_DIR/../dev/inject-json.sh"
#######################
# here the magic starts
# create all in one bashbot.sh file