Skip to content

Commit

Permalink
future3: Abort installation if user is not "pi" (MiczFlor#2077)
Browse files Browse the repository at this point in the history
* check for user 'pi' and home '/home/pi'

retrieve correct information even if called with sudo

* removed obsolete v2.x workflow files
  • Loading branch information
AlvinSchiller authored Oct 10, 2023
1 parent b11606a commit f803185
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 62 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/dockerimage.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/pythonpackage.yml

This file was deleted.

33 changes: 32 additions & 1 deletion installation/install-jukebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,37 @@ GIT_BRANCH=${GIT_BRANCH:-"future3/main"}
# Constants
GIT_REPO_NAME="RPi-Jukebox-RFID"
GIT_URL="https://github.com/${GIT_USER}/${GIT_REPO_NAME}"
HOME_PATH="/home/pi"
echo GIT_BRANCH $GIT_BRANCH
echo GIT_URL $GIT_URL

CURRENT_USER="${SUDO_USER:-$USER}"
HOME_PATH=$(getent passwd "$CURRENT_USER" | cut -d: -f6)
echo "Current User: $CURRENT_USER"
echo "User home dir: $HOME_PATH"

INSTALLATION_PATH="${HOME_PATH}/${GIT_REPO_NAME}"
INSTALL_ID=$(date +%s)

checkPrerequisite() {
#currently the user 'pi' is mandatory
#https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1785
if [ "${CURRENT_USER}" != "pi" ]; then
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_PATH}" != "/home/pi" ]; then
echo
echo "ERROR: HomeDir must be '/home/pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
exit 2
fi
}

download_jukebox_source() {
wget -qO- "${GIT_URL}/tarball/${GIT_BRANCH}" | tar xz
# Use case insensitive search/sed because user names in Git Hub are case insensitive
Expand All @@ -41,6 +68,10 @@ download_jukebox_source() {
unset GIT_REPO_DOWNLOAD
}


### CHECK PREREQUISITE
checkPrerequisite

### RUN INSTALLATION
INSTALLATION_LOGFILE="${HOME_PATH}/INSTALL-${INSTALL_ID}.log"
exec 3>&1 1>>"${INSTALLATION_LOGFILE}" 2>&1 || { echo "Cannot create log file. Panic."; exit 1; }
Expand Down

0 comments on commit f803185

Please sign in to comment.