add comments to scripts

This commit is contained in:
will Farrell 2017-02-15 13:42:35 -07:00
parent 8f787586e7
commit c4a114a31c

View File

@ -131,12 +131,18 @@ function build_crontab() {
continue
fi
COMMENT=$(jq -r .[$i].comment ${CONFIG})
if [ "${COMMENT}" != "null" ]; then
echo "# ${COMMENT}" >> ${CRONTAB_FILE}
fi
SCRIPT_NAME=$(cat /proc/sys/kernel/random/uuid)
COMMAND="/bin/bash ${HOME_DIR}/jobs/${SCRIPT_NAME}.sh"
cat << EOF > ${HOME_DIR}/jobs/${SCRIPT_NAME}.sh
#!/usr/bin/env bash
set -e
echo "cron: ${COMMENT}"
$(make_cmd "$(jq -c .[$i] ${CONFIG})")
EOF
if [ "$(jq -r .[$i].trigger ${CONFIG})" != "null" ]; then
@ -151,14 +157,6 @@ EOF
done < <(jq -r '.['$i'].trigger|keys[]' ${CONFIG})
fi
NAME=$(jq -r .[$i].name ${CONFIG})
COMMENT=$(jq -r .[$i].comment ${CONFIG})
if [ "${NAME}" != "null" ] && [ "${COMMENT}" != "null" ]; then
echo "# ${NAME}: ${COMMENT}" >> ${CRONTAB_FILE}
elif [ "${COMMENT}" != "null" ]; then
echo "# ${COMMENT}" >> ${CRONTAB_FILE}
fi
echo "${SCHEDULE} ${COMMAND}" >> ${CRONTAB_FILE}
if [ "$(jq -r .[$i].onstart ${CONFIG})" == "true" ]; then