From b9a09df332ab1f81e22016abefde48b8c29e2647 Mon Sep 17 00:00:00 2001 From: KyleMaas Date: Sun, 7 Jul 2013 15:31:38 -0400 Subject: [PATCH] Link to correct directory within user's home even when running under sudo Open-webOS-DCO-1.0-Signed-off-by: Kyle Maas kylemaasdev@gmail.com --- install-webos-desktop.sh | 12 ++++++++++++ local.sh.default | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/install-webos-desktop.sh b/install-webos-desktop.sh index 7be06bf..579fe5a 100755 --- a/install-webos-desktop.sh +++ b/install-webos-desktop.sh @@ -29,6 +29,18 @@ export SCRIPT_DIR=$PWD source ./webos-desktop-common.sh +if [ -z "$BASE" ]; then + echo "You have a problem with your local.sh script which is" + echo "preventing install-luna-sysmgr.sh from locating your" + echo "binaries. Please correct the problem and try again." + exit +fi + +if [ $EUID -ne 0 ]; then + echo "This script must be run as root." + exit +fi + if [ "$1" = "--help" ] ; then echo "Usage: sudo ./install-luna-sysmgr.sh [OPTION]" echo "Installs the luna-sysmgr component and its dependencies." diff --git a/local.sh.default b/local.sh.default index 53d6b5e..7805769 100644 --- a/local.sh.default +++ b/local.sh.default @@ -26,7 +26,11 @@ ## This has been the default target location for build-desktop since its initial creation ## -export BASE="${HOME}/luna-desktop-binaries" +if [ -z "${SUDO_USER}" ]; then + export BASE="${HOME}/luna-desktop-binaries" +else + export BASE="$(getent passwd ${SUDO_USER} | grep -o [^:]*:[^:]*$ | grep -o ^[^:]*)/luna-desktop-binaries" +fi #########################################