Skip to content

Commit

Permalink
get username with whoami
Browse files Browse the repository at this point in the history
to be compatible with containers
  • Loading branch information
AlvinSchiller committed Oct 15, 2023
1 parent db5ff9b commit 9ee515e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DATETIME=$(date +"%Y%m%d_%H%M%S")
SCRIPTNAME="$(basename $0)"
JOB="${SCRIPTNAME}"

CURRENT_USER="${SUDO_USER:-$USER}"
CURRENT_USER="${SUDO_USER:-$(whoami)}"
HOME_DIR=$(getent passwd "$CURRENT_USER" | cut -d: -f6)
echo "Current User: $CURRENT_USER"
echo "User home dir: $HOME_DIR"
Expand Down Expand Up @@ -97,15 +97,15 @@ checkPrerequisite() {
#currently the user 'pi' is mandatory
#https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1785
if [ "${CURRENT_USER}" != "pi" ]; then
echo
echo
echo "ERROR: User must be 'pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
exit 2
fi

if [ "${HOME_DIR}" != "/home/pi" ]; then
echo
echo
echo "ERROR: HomeDir must be '/home/pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
Expand Down
8 changes: 4 additions & 4 deletions scripts/installscripts/buster-install-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DATETIME=$(date +"%Y%m%d_%H%M%S")
SCRIPTNAME="$(basename $0)"
JOB="${SCRIPTNAME}"

CURRENT_USER="${SUDO_USER:-$USER}"
CURRENT_USER="${SUDO_USER:-$(whoami)}"
HOME_DIR=$(getent passwd "$CURRENT_USER" | cut -d: -f6)
echo "Current User: $CURRENT_USER"
echo "User home dir: $HOME_DIR"
Expand Down Expand Up @@ -97,15 +97,15 @@ checkPrerequisite() {
#currently the user 'pi' is mandatory
#https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1785
if [ "${CURRENT_USER}" != "pi" ]; then
echo
echo
echo "ERROR: User must be 'pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
exit 2
fi

if [ "${HOME_DIR}" != "/home/pi" ]; then
echo
echo
echo "ERROR: HomeDir must be '/home/pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
Expand Down Expand Up @@ -864,7 +864,7 @@ install_main() {

sudo wget -q -O /etc/apt/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/${OS_CODENAME}.list

${apt_get} update
${apt_get} upgrade
${apt_get} install libspotify-dev
Expand Down
2 changes: 1 addition & 1 deletion scripts/installscripts/tests/test_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
INSTALLATION_EXITCODE="${1:-0}"

PATHDATA="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
USER_NAME="$USER"
USER_NAME="$(whoami)"
HOME_DIR="$HOME"

tests=0
Expand Down

0 comments on commit 9ee515e

Please sign in to comment.