github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/stage1/reaper/reaper.sh (about) 1 #!/usr/bin/bash 2 shopt -s nullglob 3 4 SYSCTL=/usr/bin/systemctl 5 DIAG=/diagnostic 6 7 if [ $# -eq 3 ]; then 8 app=$1 9 root_dir=$2 10 target=$3 11 status=$(${SYSCTL} show --property ExecMainStatus "${app}.service") 12 status="${status#*=}" 13 echo "${status}" > "/rkt/status/$app" 14 if [ "${status}" != 0 ] ; then 15 # The command "systemctl exit $status" sets the return value that will 16 # be used when the pod exits (via shutdown.service). 17 # This command is available since systemd v227. On older versions, the 18 # command will fail and rkt will just exit with return code 0. 19 if [ -n "$EXIT_POD" ] ; then 20 ${SYSCTL} exit ${status#*=} 2>/dev/null 21 fi 22 # systemd EXIT_EXEC is 203 (https://github.com/systemd/systemd/blob/v230/src/basic/exit-status.h#L47) 23 if [ "${status}" == 203 ]; then 24 "${DIAG}" "${root_dir}" "${target}" 2>&1 25 fi 26 fi 27 exit 0 28 fi