diff --git a/setup/start.sh b/setup/start.sh index 92f881a30..5dee421f1 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -107,8 +107,6 @@ unbound-anchor -a /var/lib/unbound/root.key log "Adding systemd services" cp -r "${script_dir}/start/systemd/." /etc/systemd/system/ -[[ "${ubuntu_version}" == "16.04" ]] && sed -e 's/MemoryMax/MemoryLimit/g' -i /etc/systemd/system/box.service -[[ "${ubuntu_version}" == "16.04" ]] && sed -e 's/Type=notify/Type=simple/g' -i /etc/systemd/system/unbound.service systemctl daemon-reload systemctl enable --now cloudron-syslog systemctl enable unbound diff --git a/src/scripts/starttask.sh b/src/scripts/starttask.sh index 5a19d9694..b5c01a8b1 100755 --- a/src/scripts/starttask.sh +++ b/src/scripts/starttask.sh @@ -31,16 +31,11 @@ systemctl reset-failed "${service_name}" 2>/dev/null || true readonly id=$(id -u $SUDO_USER) readonly ubuntu_version=$(lsb_release -rs) -if [[ "${ubuntu_version}" == "16.04" ]]; then - options="-p TimeoutStopSec=10s -p MemoryLimit=${memory_limit_mb}M --remain-after-exit" -else - options="-p TimeoutStopSec=10s -p MemoryMax=${memory_limit_mb}M --pipe --wait" +options="-p TimeoutStopSec=10s -p MemoryMax=${memory_limit_mb}M --pipe --wait" - # Note: BindsTo will kill this task when the box is stopped. but will not kill this task when restarted! - # For this reason, we have code to kill the tasks both on shutdown and startup. - # BindsTo does not work on ubuntu 16, this means that even if box is stopped, the tasks keep running - [[ "$BOX_ENV" == "cloudron" ]] && options="${options} -p BindsTo=box.service" -fi +# Note: BindsTo will kill this task when the box is stopped. but will not kill this task when restarted! +# For this reason, we have code to kill the tasks both on shutdown and startup. +[[ "$BOX_ENV" == "cloudron" ]] && options="${options} -p BindsTo=box.service" # systemd 237 on ubuntu 18.04 does not apply --nice if [[ "${ubuntu_version}" == "18.04" ]]; then @@ -54,18 +49,5 @@ systemd-run --unit "${service_name}" --nice "${nice}" --uid=${id} --gid=${id} ${ "${task_worker}" "${task_id}" "${logfile}" exit_code=$? -if [[ "${ubuntu_version}" == "16.04" ]]; then - sleep 3 - # we cannot use systemctl is-active because unit is always active until stopped with RemainAfterExit - while [[ "$(systemctl show -p SubState ${service_name})" == *"running"* ]]; do - echo "Waiting for service ${service_name} to finish" - sleep 3 - done - exit_code=$(systemctl show "${service_name}" -p ExecMainStatus | sed 's/ExecMainStatus=//g') - systemctl stop "${service_name}" || true # because of remain-after-exit we have to deactivate the service -fi - -[[ "${ubuntu_version}" == "18.04" ]] && wait # for the renice subshell we started - echo "Service ${service_name} finished with exit code ${exit_code}" exit "${exit_code}" diff --git a/src/scripts/update.sh b/src/scripts/update.sh index 5befa3d32..d5be3941e 100755 --- a/src/scripts/update.sh +++ b/src/scripts/update.sh @@ -30,18 +30,12 @@ systemctl reset-failed "${UPDATER_SERVICE}" 2>/dev/null || true # StandardError will follow StandardOutput in default inherit mode. https://www.freedesktop.org/software/systemd/man/systemd.exec.html echo "=> Run installer.sh as ${UPDATER_SERVICE}." -if [[ "$(systemd --version | head -n1)" != "systemd 22"* ]]; then - readonly DATETIME=`date '+%Y-%m-%d_%H-%M-%S'` - readonly LOG_FILE="/home/yellowtent/platformdata/logs/updater/cloudron-updater-${DATETIME}.log" +readonly DATETIME=`date '+%Y-%m-%d_%H-%M-%S'` +readonly LOG_FILE="/home/yellowtent/platformdata/logs/updater/cloudron-updater-${DATETIME}.log" - update_service_options="-p StandardOutput=file:${LOG_FILE}" - echo "=> starting service (ubuntu 18.04) ${UPDATER_SERVICE}. see logs at ${LOG_FILE}" -else - update_service_options="" - echo "=> starting service (ubuntu 16.04) ${UPDATER_SERVICE}. see logs using journalctl -u ${UPDATER_SERVICE}" -fi +echo "=> starting service ${UPDATER_SERVICE}. see logs at ${LOG_FILE}" -if ! systemd-run --property=OOMScoreAdjust=-1000 --unit "${UPDATER_SERVICE}" $update_service_options ${installer_path}; then +if ! systemd-run --property=OOMScoreAdjust=-1000 --unit "${UPDATER_SERVICE}" -p StandardOutput=file:${LOG_FILE} ${installer_path}; then echo "Failed to install cloudron. See log for details" exit 1 fi