Script asks user for name and directory if not supplied

This commit is contained in:
Paul Brown
2026-08-01 15:47:51 +02:00
parent 44fc1af970
commit d492dbd1be

23
mkosi.extra/usr/bin/set-up-systemd-extension Normal file → Executable file
View File

@@ -11,9 +11,6 @@ usage() {
set -e
# Test to see if the user added a name for their extension. Otherwise use 'kde'
SYSEXT_NAME="kde"
# Check for parameters (see "usage" function above)
while getopts "n:d:h" option; do
case "${option}" in
@@ -23,16 +20,32 @@ while getopts "n:d:h" option; do
d)
SYSEXT_DIR="$OPTARG"
;;
h | *)
h)
usage
exit 0
;;
esac
done
# If name has not been defined, offer the user the possibility of defining it now or accepting the default 'kde'
if [ -z ${SYSEXT_NAME} ]; then
echo -e "Extension name [default: kde]: \c"
read -r
SYSEXT_NAME="${REPLY:-kde}"
fi
# If a directory has been defined, the extension will be under 'directory/name'; if not, the extension will be under 'name'
if [ -z ${SYSEXT_DIR} ]; then
SYSEXT_DIR="${SYSEXT_NAME}"
echo -e "Extension directory [default: current directory]: \c"
read -r
if [ -z "${REPLY}" ]; then
SYSEXT_DIR="${SYSEXT_NAME}"
else
SYSEXT_DIR="${REPLY}/${SYSEXT_NAME}"
fi
else
SYSEXT_DIR="${SYSEXT_DIR}/${SYSEXT_NAME}"
fi