
Make osbashout abort if a client-side scripts returns an error; use a file named error in the status directory to signal the problem and to store the name of the offending script for use by Windows batch scripts. Have osbash.sh and the Windows batch scripts exit when an error file appears. Change-Id: I6722e75c9c23b99e5ed25b00429026c2e0ff6a12
59 lines
1.4 KiB
Bash
59 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# By default, this file is /etc/init.d/osbashauto on the guest system.
|
|
# On boot-up, it executes in order all files that have been put into
|
|
# the autostart folder.
|
|
|
|
# The name of this file is hard-coded in activate_autostart.sh.
|
|
|
|
SHARE_NAME=%SHARE_NAME%
|
|
|
|
# Make sure we have a mount point for the shared directory
|
|
mkdir -p /$SHARE_NAME
|
|
|
|
if ! mountpoint -q /$SHARE_NAME; then
|
|
mount -t vboxsf -ouid=%VM_SHELL_USER%,gid=%VM_SHELL_USER% $SHARE_NAME /$SHARE_NAME
|
|
fi
|
|
|
|
# LOG_DIR is set in activate_autostart.sh as NLOG_DIR
|
|
LOG_DIR=%NLOG_DIR%
|
|
|
|
STATUS_DIR=%NLOG_DIR%/status
|
|
|
|
mkdir -p $STATUS_DIR
|
|
|
|
TOP_DIR=/$SHARE_NAME
|
|
|
|
source "$TOP_DIR/config/paths"
|
|
source "$LIB_DIR/functions.guest"
|
|
|
|
exec_logpath "$LOG_DIR/%RCAUTOSTART%.log"
|
|
|
|
echo "$(date) starting"
|
|
|
|
shopt -s nullglob
|
|
for AUTODIR in "/$SHARE_NAME/autostart" "/$SHARE_NAME/autostart/$HOSTNAME"; do
|
|
if [ -d "$AUTODIR" ]; then
|
|
echo "$(date) autodir $AUTODIR"
|
|
for SCRIPT in $AUTODIR/*.sh; do
|
|
if ! as_root_exec_script "$SCRIPT"; then
|
|
echo >&2 "Script returned with error, giving up."
|
|
# Tell host about the error
|
|
echo "ERROR in $SCRIPT" >> "$STATUS_DIR/error"
|
|
exit 1
|
|
fi
|
|
# Remove script after execution
|
|
rm "$SCRIPT"
|
|
done
|
|
fi
|
|
done
|
|
|
|
echo "$(date) autostart done"
|
|
|
|
# This file is seen and removed by scripts running on the host
|
|
touch "$STATUS_DIR/done"
|
|
|
|
exit 0
|
|
|
|
# vim: set ai ts=4 sw=4 et:
|