2010-09-02 11:12:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
## live-build(7) - System Build Scripts
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Including common functions
|
2012-08-27 13:52:29 +00:00
|
|
|
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
|
2010-09-02 11:12:37 +00:00
|
|
|
|
|
|
|
# Setting static variables
|
2015-02-05 02:30:47 -01:00
|
|
|
DESCRIPTION="Utility to build live systems"
|
2020-02-25 08:00:06 -01:00
|
|
|
HELP=""
|
|
|
|
USAGE="lb {clean|config|build}"
|
2010-09-02 11:12:37 +00:00
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
-h|--help)
|
2020-02-22 13:33:01 -01:00
|
|
|
if [ $(which man) ]
|
2010-09-02 11:12:37 +00:00
|
|
|
then
|
2011-01-01 15:55:57 -01:00
|
|
|
man lb
|
2010-09-02 11:12:37 +00:00
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
${0} --usage
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
""|-u|--usage)
|
|
|
|
Usage
|
|
|
|
;;
|
|
|
|
|
|
|
|
-v|--version)
|
2012-07-18 19:38:58 +00:00
|
|
|
echo "${VERSION}"
|
|
|
|
exit 0
|
2010-09-02 11:12:37 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2012-08-27 13:59:56 +00:00
|
|
|
COMMAND="${1}"
|
2010-09-02 11:12:37 +00:00
|
|
|
shift
|
|
|
|
|
2012-06-06 19:32:08 +00:00
|
|
|
ENV=""
|
|
|
|
|
2013-11-15 20:13:32 -01:00
|
|
|
if [ "${COMMAND}" != "config" ]
|
|
|
|
then
|
|
|
|
# Checking user account
|
|
|
|
if [ "$(id -u)" -ne "0" ]
|
|
|
|
then
|
2015-01-06 02:10:15 -01:00
|
|
|
Echo_error "Root privileges needed!"
|
2013-11-15 20:13:32 -01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-06-06 19:32:08 +00:00
|
|
|
for _FILE in config/environment config/environment.binary
|
|
|
|
do
|
|
|
|
if [ -e "${_FILE}" ]
|
|
|
|
then
|
|
|
|
ENV="${ENV} $(grep -v '^#' ${_FILE})"
|
|
|
|
fi
|
|
|
|
done
|
2012-05-31 11:15:18 +00:00
|
|
|
|
2012-07-19 17:37:26 +00:00
|
|
|
if [ -x "${LIVE_BUILD}/scripts/build/${COMMAND}" ]
|
2010-09-02 11:12:37 +00:00
|
|
|
then
|
2012-08-27 12:54:20 +00:00
|
|
|
# User has live-build copied locally in the system
|
2012-07-19 17:37:26 +00:00
|
|
|
SCRIPT="${LIVE_BUILD}/scripts/build/${COMMAND}"
|
2012-08-27 12:55:15 +00:00
|
|
|
elif [ -x "local/live-build/scripts/build/${COMMAND}" ]
|
|
|
|
then
|
2013-03-11 14:20:13 -01:00
|
|
|
# User has live-build copied locally in the config
|
2012-08-27 12:55:15 +00:00
|
|
|
SCRIPT="local/live-build/scripts/build/${COMMAND}"
|
2012-07-19 00:59:55 +00:00
|
|
|
elif [ -x /usr/lib/live/build/${COMMAND} ]
|
2010-09-02 11:12:37 +00:00
|
|
|
then
|
2012-08-27 12:54:20 +00:00
|
|
|
# User has live-build installed in the system
|
2012-07-19 00:59:55 +00:00
|
|
|
SCRIPT=/usr/lib/live/build/"${COMMAND}"
|
2020-02-22 13:33:01 -01:00
|
|
|
elif [ $(which "${COMMAND}") ]
|
2010-09-02 11:12:37 +00:00
|
|
|
then
|
2012-08-27 12:54:20 +00:00
|
|
|
# User has live-build commands in path
|
2012-01-12 20:22:57 -01:00
|
|
|
SCRIPT="${COMMAND}"
|
2010-09-02 11:12:37 +00:00
|
|
|
else
|
2015-01-06 02:10:15 -01:00
|
|
|
Echo_error "No such script: ${COMMAND}"
|
2010-09-02 11:12:37 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2012-01-12 20:22:57 -01:00
|
|
|
|
2012-08-27 13:59:56 +00:00
|
|
|
Echo "[%s] %s" "$(date +'%F %T')" "lb ${COMMAND} $(echo ${@})"
|
2012-08-27 13:16:09 +00:00
|
|
|
${ENV} exec "${SCRIPT}" "${@}"
|
2010-09-02 11:12:37 +00:00
|
|
|
;;
|
|
|
|
esac
|