Added flags to specify distribution and release code

This commit is contained in:
Duncan Sommerville 2015-03-11 14:39:41 -04:00
parent 53fc0ac667
commit c9607e9376
1 changed files with 47 additions and 28 deletions

75
install
View File

@ -22,6 +22,10 @@ showhelp () {
No output except errors No output except errors
-f, --force -f, --force
Turn off interactive prompts Turn off interactive prompts
--distribution
Linux distribution the installation is being run on
--release
Distribution release
-d, --ignore-dependencies -d, --ignore-dependencies
Don't install binary dependencies Don't install binary dependencies
-w, --web-user=WEB_USER -w, --web-user=WEB_USER
@ -66,6 +70,8 @@ _v=0
# Quiet # Quiet
_q=0 _q=0
upgrade="f" upgrade="f"
dist=""
code=""
function verbose() { function verbose() {
if [[ ${_v} -eq 1 ]]; then if [[ ${_v} -eq 1 ]]; then
@ -100,11 +106,6 @@ function checkCommandExists() {
set -e set -e
} }
function checkDistro() {
distro=$@
unameStr=`uname -a`
eval echo "${unameStr}" | grep --quiet "${distro}"
}
while :; do while :; do
case "$1" in case "$1" in
--help) --help)
@ -122,6 +123,40 @@ while :; do
--force) --force)
_i=0 _i=0
;; ;;
--distribution)
if [ "$2" ]; then
dist=$2
shift 2
continue
else
echo 'ERROR: Must specify a non-empty "--distribution DISTRIBUTION" argument.' >&2
exit 1
fi
;;
--distribution=?*)
dist=${1#*=} # Delete everything up to "=" and assign the remainder.
;;
--distribution=)
echo 'ERROR: Must specify a non-empty "--distribution DISTRIBUTION" argument.' >&2
exit 1
;;
--release)
if [ "$2" ]; then
code=$2
shift 2
continue
else
echo 'ERROR: Must specify a non-empty "--release RELEASE" argument.' >&2
exit 1
fi
;;
--release=?*)
code=${1#*=} # Delete everything up to "=" and assign the remainder.
;;
--release=)
echo 'ERROR: Must specify a non-empty "--release RELEASE" argument.' >&2
exit 1
;;
--ignore-dependencies) --ignore-dependencies)
ignore_dependencies="t" ignore_dependencies="t"
;; ;;
@ -251,28 +286,12 @@ echo "/ | \ || | \ | | | / Y \| \ "
echo "\____|__ /___||____|_ / |____| |___\____|__ /_______ / " echo "\____|__ /___||____|_ / |____| |___\____|__ /_______ / "
echo -e " \/ \/ \/ \/ \n" echo -e " \/ \/ \/ \/ \n"
# Check for the distribution without using lsb_release, which not all distros have installed by default # If we don't pass the distribution/release into the installer,
if checkDistro "wheezy"; then # install lsb-release and fetch them
dist="debian" if [ -z "${distro}" ]; then
code="wheezy" loudCmd "apt-get install lsb-release"
elif checkDistro "jessie"; then dist=`lsb_release -ds | awk '{print tolower($1);}'`
dist="debian" code=`lsb_release -cs`
code="jessie"
elif checkDistro "trusty"; then
dist="ubuntu"
code="trusty"
elif checkDistro "saucy"; then
dist="ubuntu"
code="saucy"
elif checkDistro "precise"; then
dist="ubuntu"
code="precise"
elif checkDistro "trusty"; then
dist="ubuntu"
code="trusty"
else
dist="unknown"
code="unknown"
fi fi
if [ "$ignore_dependencies" = "f" ]; then if [ "$ignore_dependencies" = "f" ]; then
@ -282,7 +301,7 @@ if [ "$ignore_dependencies" = "f" ]; then
verbose "\n * Reading requirements-${dist,,}-${code,,}.apt..." verbose "\n * Reading requirements-${dist,,}-${code,,}.apt..."
set +e set +e
loudCmd "sudo apt-get update" loudCmd "apt-get update"
if [ -f ${SCRIPT_DIR}/installer/lib/requirements-${dist,,}-${code,,}.apt ]; then if [ -f ${SCRIPT_DIR}/installer/lib/requirements-${dist,,}-${code,,}.apt ]; then
loudCmd "DEBIAN_FRONTEND=noninteractive apt-get -y -m --force-yes install $(grep -vE '^\s*#' ${SCRIPT_DIR}/installer/lib/requirements-${dist,,}-${code,,}.apt | tr '\n' ' ')" loudCmd "DEBIAN_FRONTEND=noninteractive apt-get -y -m --force-yes install $(grep -vE '^\s*#' ${SCRIPT_DIR}/installer/lib/requirements-${dist,,}-${code,,}.apt | tr '\n' ' ')"
else else