2010-09-02 11:12:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
## live-build(7) - System Build Scripts
|
2014-02-08 15:47:02 -01:00
|
|
|
## Copyright (C) 2006-2014 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
|
2013-03-11 04:35:40 -01:00
|
|
|
DESCRIPTION="$(Echo 'utility to build live systems')"
|
2010-09-02 11:12:37 +00:00
|
|
|
HELP="FIXME"
|
|
|
|
USAGE="FIXME"
|
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
-h|--help)
|
|
|
|
if [ -x "$(which man 2>/dev/null)" ]
|
|
|
|
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
|
|
|
|
Echo_error "need root privileges"
|
|
|
|
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}"
|
2010-09-02 11:12:37 +00:00
|
|
|
elif [ -x "$(which ${COMMAND} 2>/dev/null)" ]
|
|
|
|
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
|
2012-07-03 14:05:31 +00: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
|