Enhance entrypoint script to support legacy COMMAND_INIT and COMMAND_EXIT variables, allowing for backward compatibility and execution of multiple user-defined exit and initialization commands in order.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -28,7 +28,20 @@ term_handler() {
|
||||
fi
|
||||
|
||||
# Run user-defined exit commands
|
||||
eval "$COMMAND_EXIT"
|
||||
# First run the legacy COMMAND_EXIT for backward compatibility
|
||||
if [[ -n "$COMMAND_EXIT" ]]; then
|
||||
eval "$COMMAND_EXIT"
|
||||
fi
|
||||
|
||||
# Then run numbered COMMAND_EXIT variables in order
|
||||
for i in {01..99}; do
|
||||
var_name="COMMAND_EXIT$i"
|
||||
var_value="${!var_name}"
|
||||
if [[ -n "$var_value" ]]; then
|
||||
echo "Running $var_name..."
|
||||
eval "$var_value"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Cleanup completed, exiting..."
|
||||
exit 0
|
||||
@@ -53,7 +66,20 @@ echo "Starting SSH service..."
|
||||
sudo service ssh start
|
||||
|
||||
# Run initialization commands
|
||||
eval "$COMMAND_INIT"
|
||||
# First run the legacy COMMAND_INIT for backward compatibility
|
||||
if [[ -n "$COMMAND_INIT" ]]; then
|
||||
eval "$COMMAND_INIT"
|
||||
fi
|
||||
|
||||
# Then run numbered COMMAND_INIT variables in order
|
||||
for i in {01..99}; do
|
||||
var_name="COMMAND_INIT$i"
|
||||
var_value="${!var_name}"
|
||||
if [[ -n "$var_value" ]]; then
|
||||
echo "Running $var_name..."
|
||||
eval "$var_value"
|
||||
fi
|
||||
done
|
||||
|
||||
# Start the main process loop
|
||||
if [[ $LOG_FILE == "/dev/null" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user