Files
cloudron-box/src/test/checkInstall
Girish Ramakrishnan b1b6f70118 Kill all tasks on shutdown and startup
BindsTo will kill all the tasks when systemctl stop box is executed.
But when restarted, it keeps the tasks running. Because of this behavior,
we kill the tasks on startup and stop of the box code.
2020-08-06 23:47:40 -07:00

59 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -eu
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
readonly TEST_IMAGE="cloudron/test:25.2.0"
# reset sudo timestamp to avoid wrong success
sudo -k || sudo --reset-timestamp
# checks if all scripts are sudo access
scripts=("${SOURCE_DIR}/src/scripts/clearvolume.sh" \
"${SOURCE_DIR}/src/scripts/mvvolume.sh" \
"${SOURCE_DIR}/src/scripts/mkdirvolume.sh" \
"${SOURCE_DIR}/src/scripts/rmaddondir.sh" \
"${SOURCE_DIR}/src/scripts/reloadnginx.sh" \
"${SOURCE_DIR}/src/scripts/reboot.sh" \
"${SOURCE_DIR}/src/scripts/restart.sh" \
"${SOURCE_DIR}/src/scripts/restartdocker.sh" \
"${SOURCE_DIR}/src/scripts/restartunbound.sh" \
"${SOURCE_DIR}/src/scripts/update.sh" \
"${SOURCE_DIR}/src/scripts/collectlogs.sh" \
"${SOURCE_DIR}/src/scripts/configurecollectd.sh" \
"${SOURCE_DIR}/src/scripts/remotesupport.sh" \
"${SOURCE_DIR}/src/scripts/starttask.sh" \
"${SOURCE_DIR}/src/scripts/stoptask.sh" \
"${SOURCE_DIR}/src/scripts/rmmailbox.sh" \
"${SOURCE_DIR}/src/scripts/configurelogrotate.sh")
for script in "${scripts[@]}"; do
if [[ $(sudo -n "${script}" --check 2>/dev/null) != "OK" ]]; then
echo ""
echo "${script} does not have sudo access. Try 'sudo -n ${script} --check'"
echo "You have to add the lines below to /etc/sudoers.d/yellowtent"
echo ""
echo "Defaults!${script} env_keep=\"HOME BOX_ENV\""
echo "${USER} ALL=(ALL) NOPASSWD: ${script}"
echo ""
exit 1
fi
done
image_missing=""
images=$(node -e "var i = require('${SOURCE_DIR}/src/infra_version.js'); console.log(Object.keys(i.images).map(function (x) { return i.images[x].tag; }).join('\n'));"; echo $TEST_IMAGE)
for image in ${images}; do
if ! docker inspect "${image}" >/dev/null 2>/dev/null; then
echo "docker pull ${image}"
echo "docker pull ${image%@sha256:*}"
image_missing="true"
fi
done
if [[ "${image_missing}" == "true" ]]; then
echo "Pull above images before running tests"
exit 1
fi