#!/bin/bash

# Load gparted live functions
. /usr/share/gparted/bin/gl-functions

# If no boot parameter gp_prerun, return.
# //NOTE// Do not use "exit 1", use "return 1" here since all these script here is run as function like this:
# for script in /etc/gparted-live/gparted-live.d/S[0-9][0-9]*; do
#  . $script
# done
# So if it's "exit 1", the scripts (e.g. S09start-X) after this script "S08pre-run" will not be run.
if ! grep -q -Ew gp_prerun /proc/cmdline; then
  return 1
fi
parse_cmdline_option "gp_prerun"

if [ -n "$gp_prerun" ]; then
  # Run it
  echo "Running $gp_prerun..."
  . $gp_prerun
fi
