Run the updater through systemd-run

This ensures it can start and stop the box process.
Due to control-group setting to killall children
the updater itself would get killed if the box service
restarts
This commit is contained in:
Johannes
2016-11-01 18:13:45 +01:00
parent 4f6f5bf3b7
commit 18b58ced8d

View File

@@ -8,7 +8,8 @@ if [[ ${EUID} -ne 0 ]]; then
fi fi
readonly INSTALLER_SOURCE_DIR="/home/yellowtent/installer" readonly INSTALLER_SOURCE_DIR="/home/yellowtent/installer"
readonly LOG_FILE="/var/log/cloudron-update.log" readonly UPDATER_SERVICE="cloudron-updater"
readonly DATA_FILE="/tmp/cloudron-update-data.json"
if [[ $# == 1 && "$1" == "--check" ]]; then if [[ $# == 1 && "$1" == "--check" ]]; then
echo "OK" echo "OK"
@@ -23,14 +24,17 @@ fi
readonly sourceTarballUrl="${1}" readonly sourceTarballUrl="${1}"
readonly data="${2}" readonly data="${2}"
echo " " &>> "${LOG_FILE}" echo "Updating Cloudron with ${sourceTarballUrl}"
echo "============ update marker ============" &>> "${LOG_FILE}" echo "${data}"
echo " " &>> "${LOG_FILE}"
echo "Updating Cloudron with ${sourceTarballUrl}" &>> "${LOG_FILE}"
echo "${data}" &>> "${LOG_FILE}"
echo "=> Run installer.sh" # Save user data in file, to avoid argument length limit with systemd-run
if ! ${INSTALLER_SOURCE_DIR}/scripts/installer.sh --sourcetarballurl "${sourceTarballUrl}" --data "${data}" &>> "${LOG_FILE}"; then echo "${data}" > "${DATA_FILE}"
echo "=> Run installer.sh as cloudron-updater.service"
if ! systemd-run --unit "${UPDATER_SERVICE}" ${INSTALLER_SOURCE_DIR}/scripts/installer.sh --sourcetarballurl "${sourceTarballUrl}" --data-file "${DATA_FILE}"; then
echo "Failed to install cloudron. See ${LOG_FILE} for details" echo "Failed to install cloudron. See ${LOG_FILE} for details"
exit 1 exit 1
fi fi
echo "=> service ${UPDATER_SERVICE} started."
echo "=> See logs with journalctl -u ${UPDATER_SERVICE} -f"