diff --git a/.github/ISSUE_TEMPLATE/bug_template.md b/.github/ISSUE_TEMPLATE/bug_template.md index 1be942778..508cf50b9 100644 --- a/.github/ISSUE_TEMPLATE/bug_template.md +++ b/.github/ISSUE_TEMPLATE/bug_template.md @@ -50,7 +50,7 @@ Otherwise the output of `cat /etc/os-release` i.e. `master` the following command will help with that -`cd /home/pi/RPi-Jukebox-RFID/ && git status | head -2` +`cd ~/RPi-Jukebox-RFID/ && git status | head -2` --> ### Installscript diff --git a/.github/workflows/test_docker_debian_codename_sub_v3.yml b/.github/workflows/test_docker_debian_codename_sub_v3.yml index 54abd142a..97924c4bf 100644 --- a/.github/workflows/test_docker_debian_codename_sub_v3.yml +++ b/.github/workflows/test_docker_debian_codename_sub_v3.yml @@ -27,6 +27,10 @@ on: type: string default: ubuntu-latest +env: + TEST_USER_NAME: testuser + TEST_USER_GROUP: testusergroup + # let only one instance run the test so cache is not corrupted. # cancel already running instances as only the last run will be relevant concurrency: @@ -101,6 +105,8 @@ jobs: cache-to: type=gha,mode=max,scope=${{ steps.vars.outputs.cache_scope }} build-args: | DEBIAN_CODENAME=${{ inputs.debian_codename }} + USER_NAME=${{ env.TEST_USER_NAME }} + USER_GROUP=${{ env.TEST_USER_GROUP }} GIT_BRANCH=${{ github.head_ref || github.ref_name }} GIT_USER=${{ github.event.pull_request.head.user.login || github.repository_owner }} @@ -137,11 +143,7 @@ jobs: strategy: fail-fast: false matrix: - username: ['pi'] test_script: ['run_install_common.sh', 'run_install_faststartup.sh', 'run_install_webapp_local.sh', 'run_install_webapp_download.sh'] - include: - - username: hans - test_script: run_install_user_not_pi.sh steps: - name: Set up QEMU @@ -160,11 +162,11 @@ jobs: docker load --input ${{ needs.build.outputs.image_file_name }} # Run test - - name: Run Test ${{ inputs.debian_codename }}-${{ matrix.username }}-${{ matrix.test_script }} + - name: Run Test ${{ inputs.debian_codename }}-${{ env.TEST_USER_NAME }}-${{ matrix.test_script }} uses: tj-actions/docker-run@v2 with: image: ${{ needs.build.outputs.image_tag_name }} - options: --platform ${{ inputs.platform }} --user ${{ matrix.username }} --init + options: --platform ${{ inputs.platform }} --user ${{ env.TEST_USER_NAME }} --init name: ${{ matrix.test_script }} args: | ./${{ matrix.test_script }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3bc03705..dbf12f84d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ For bug fixes and improvements just open an issue or PR as described below. If y * By default this will get you to the `future3/main` branch. You will move to the `future3/develop` branch, do this: ~~~bash -cd /home/pi/RPi-Jukebox-RFID +cd ~/RPi-Jukebox-RFID git checkout future3/develop git fetch origin git reset --hard origin/future3/develop @@ -122,7 +122,7 @@ If you touched *any* Python file (even if only for fixing spelling errors), run It contains out setup file. ~~~bash -cd /home/pi/RPi-Jukebox-RFID +cd ~/RPi-Jukebox-RFID ./run_flake8.sh ~~~ @@ -135,7 +135,7 @@ Tests are very few at the moment, but it cannot hurt to run them. If you have te them. ~~~bash -cd /home/pi/RPi-Jukebox-RFID/ +cd ~/RPi-Jukebox-RFID/ ./run_pytest.sh ~~~ diff --git a/ci/ci-debian.Dockerfile b/ci/ci-debian.Dockerfile index 1a227755a..5228d83d5 100644 --- a/ci/ci-debian.Dockerfile +++ b/ci/ci-debian.Dockerfile @@ -7,7 +7,7 @@ ARG DEBIAN_CODENAME ENV TERM=xterm DEBIAN_FRONTEND=noninteractive ENV CI_RUNNING=true -# create pi configs to test installation +# create RPi configs to test installation RUN touch /boot/config.txt RUN echo "logo.nologo" > /boot/cmdline.txt @@ -40,8 +40,8 @@ RUN echo "--- install packages (1) ---" \ RUN echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections # ------ -# Base Target for setting up the default user. user can be selected with the docker '--user YYY' option -FROM base as user +# Base Target for setting up a test user. user can be selected with the docker '--user YYY' option +FROM base as test-user ARG USER_NAME=pi ARG USER_GROUP=$USER_NAME ARG USER_ID=1000 @@ -56,18 +56,6 @@ RUN groupadd --gid 1000 $USER_GROUP \ ENV XDG_RUNTIME_DIR=/run/user/$USER_ID DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$USER_ID/bus # ------ - -# Target for setting up an alternativ user 'hans:wurst'. user can be selected with the docker '--user YYY' option -FROM user as test-user - -RUN export USER_ALT=hans \ - && export USER_ALT_GROUP=wurst \ - && groupadd --gid 1001 $USER_ALT_GROUP \ - && useradd -u 1001 -g $USER_ALT_GROUP -G sudo,$TEST_USER_GROUP -d /home/$USER_ALT -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER_ALT \ - && echo "$USER_ALT ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER_ALT -# ------ - - # Target for adding envs and scripts from the repo to test installation FROM test-user as test-code ARG GIT_BRANCH diff --git a/ci/installation/run_install_user_not_pi.sh b/ci/installation/run_install_user_not_pi.sh deleted file mode 100644 index 76a8cd576..000000000 --- a/ci/installation/run_install_user_not_pi.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -# Install Phoniebox and test it -# Used e.g. for tests on Docker - -# Objective: Test installation with script using a simple configuration - -SOURCE="${BASH_SOURCE[0]}" -SCRIPT_DIR="$(dirname "$SOURCE")" -LOCAL_INSTALL_SCRIPT_PATH="${INSTALL_SCRIPT_PATH:-${SCRIPT_DIR}/../../installation}" -LOCAL_INSTALL_SCRIPT_PATH="${LOCAL_INSTALL_SCRIPT_PATH%/}" - -# Run installation (in interactive mode) -# - - Installation must abort early - -"${LOCAL_INSTALL_SCRIPT_PATH}/install-jukebox.sh" -INSTALLATION_EXITCODE=$? - -# only count abortion due to "not user pi" as success -if [ "${INSTALLATION_EXITCODE}" -eq 2 ]; then - INSTALLATION_EXITCODE=0 -else - INSTALLATION_EXITCODE=1 -fi -exit "${INSTALLATION_EXITCODE}" diff --git a/documentation/builders/autohotspot.md b/documentation/builders/autohotspot.md index 7f064cb53..69e6f4d6a 100644 --- a/documentation/builders/autohotspot.md +++ b/documentation/builders/autohotspot.md @@ -28,7 +28,7 @@ After connecting to the `Phoniebox_Hotspot` you are able to connect via ssh to your Jukebox ``` bash -ssh pi@10.0.0.5 +ssh @10.0.0.5 ``` ## Changing basic configuration of the hotspot diff --git a/documentation/builders/installation.md b/documentation/builders/installation.md index d0befca29..fadc77aac 100644 --- a/documentation/builders/installation.md +++ b/documentation/builders/installation.md @@ -16,7 +16,7 @@ Before you can install the Phoniebox software, you need to prepare your Raspberr * Click `Edit Settings` * Switch to the `General` tab * Provide a hostname. (When on Mac, you will be able to use it to connect via SSH) - * Username currently MUST be `pi`. Other usernames are currently not supported. + * Username * Password * Wifi * Set locale settings @@ -72,7 +72,7 @@ You will need a terminal, like PuTTY for Windows or the Terminal app for Mac to 7. Eject your SD card and insert it into your Raspberry Pi. 8. Start your Raspberry Pi by attaching a power supply. -9. Login into your Raspberry Pi, username is `pi` and password is `raspberry`. +9. Login into your Raspberry Pi If `raspberrypi.local` does not work, find out your Raspberry Pi's IP address from your router. diff --git a/documentation/builders/system.md b/documentation/builders/system.md index 5b1ce5c0c..873d489f6 100644 --- a/documentation/builders/system.md +++ b/documentation/builders/system.md @@ -10,9 +10,8 @@ The system consists of 4. [Web UI](system.md#web-ui) which is served through an Nginx web server 5. A set of [Configuration Tools](../developers/coreapps.md#configuration-tools) and a set of [Developer Tools](../developers/coreapps.md#developer-tools) -.. note:: The default install puts everything into the folder `/home/pi/RPi-Jukebox-RFID`. - Another folder might work, but is certainly not tested. Things are installed for the default user `pi`. Again, - another user might work, but is not tested. +.. note:: The default install puts everything into the users home folder `~/RPi-Jukebox-RFID`. + Another folder might work, but is certainly not tested. ## Music Player Daemon (MPD) @@ -102,7 +101,7 @@ Starting and stopping the service can be useful for debugging or configuration c The Web UI is served using nginx. Nginx runs as a system service. The home directory is localed at ``` -/home/pi/RPi-Jukebox-RFID/src/webapp/build +~/RPi-Jukebox-RFID/src/webapp/build ``` The Nginx configuration is located at diff --git a/documentation/developers/known-issues.md b/documentation/developers/known-issues.md index 598ecd791..2ec52c3c2 100644 --- a/documentation/developers/known-issues.md +++ b/documentation/developers/known-issues.md @@ -7,7 +7,7 @@ browser for now. ## Configuration -In `jukebox.yaml` (and all other config files): do not use relative paths with `~/some/dir`. -Always use entire explicit path, e.g. `/home/pi/some/dir`. +In `jukebox.yaml` (and all other config files): +Always use relative path from settingsfile `../../`, but do not use relative paths with `~/`. **Sole** exception is in `playermpd.mpd_conf`. diff --git a/installation/install-jukebox.sh b/installation/install-jukebox.sh index b72dd32ff..90f78800f 100755 --- a/installation/install-jukebox.sh +++ b/installation/install-jukebox.sh @@ -47,33 +47,6 @@ _check_os_type() { fi } -# currently the user 'pi' is mandatory -# https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1785 -_check_user() { - 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 - - if [ ! -d "${HOME_PATH}" ]; then - echo - echo "ERROR: HomeDir ${HOME_PATH} does not exist." - echo " Please create it and start again." - exit 2 - fi -} - # Manipulate file descriptor for logging # Behavior: # Write To logfile: @@ -154,7 +127,6 @@ _load_sources() { ### CHECK PREREQUISITE _check_os_type -_check_user ### SETUP LOGGING _setup_logging diff --git a/installation/routines/setup_autohotspot.sh b/installation/routines/setup_autohotspot.sh index a385352dd..cc40b7794 100644 --- a/installation/routines/setup_autohotspot.sh +++ b/installation/routines/setup_autohotspot.sh @@ -68,7 +68,10 @@ _other_configuration() { _install_service_and_timer() { sudo cp "${INSTALLATION_PATH}"/resources/autohotspot/autohotspot.service /etc/systemd/system/autohotspot.service sudo systemctl enable autohotspot.service - sudo cp "${INSTALLATION_PATH}"/resources/autohotspot/autohotspot.timer /etc/cron.d/autohotspot + + local cron_autohotspot_file="/etc/cron.d/autohotspot" + sudo cp "${INSTALLATION_PATH}"/resources/autohotspot/autohotspot.timer "${cron_autohotspot_file}" + sudo sed -i "s|%%USER%%|${CURRENT_USER}|g" "${cron_autohotspot_file}" } _install_autohotspot_script() { diff --git a/installation/routines/setup_jukebox_webapp.sh b/installation/routines/setup_jukebox_webapp.sh index df58188fb..54c573654 100644 --- a/installation/routines/setup_jukebox_webapp.sh +++ b/installation/routines/setup_jukebox_webapp.sh @@ -72,6 +72,7 @@ _jukebox_webapp_register_as_system_service_with_nginx() { sudo mv -f "${WEBAPP_NGINX_SITE_DEFAULT_CONF}" "${WEBAPP_NGINX_SITE_DEFAULT_CONF}.orig" sudo cp -f "${INSTALLATION_PATH}/resources/default-settings/nginx.default" "${WEBAPP_NGINX_SITE_DEFAULT_CONF}" + sudo sed -i "s|%%INSTALLATION_PATH%%|${INSTALLATION_PATH}|g" "${WEBAPP_NGINX_SITE_DEFAULT_CONF}" # make sure nginx can access the home directory of the user sudo chmod o+x "${HOME_PATH}" diff --git a/resources/autohotspot/autohotspot.timer b/resources/autohotspot/autohotspot.timer index a35f15757..eb2acaebe 100644 --- a/resources/autohotspot/autohotspot.timer +++ b/resources/autohotspot/autohotspot.timer @@ -1,3 +1,3 @@ # cron timer for autohotspot -*/5 * * * * pi sudo /usr/bin/autohotspot 2>&1 | logger -t autohotspot -@reboot pi sudo /usr/bin/autohotspot 2>&1 | logger -t autohotspot +*/5 * * * * %%USER%% sudo /usr/bin/autohotspot 2>&1 | logger -t autohotspot +@reboot %%USER%% sudo /usr/bin/autohotspot 2>&1 | logger -t autohotspot diff --git a/resources/default-settings/jukebox.default.yaml b/resources/default-settings/jukebox.default.yaml index 6e565c684..91ada74c6 100644 --- a/resources/default-settings/jukebox.default.yaml +++ b/resources/default-settings/jukebox.default.yaml @@ -1,5 +1,5 @@ # IMPORTANT: -# Do not use paths with '~/some/dir' - always use '/home/pi/some/dir' +# Always use relative path from settingsfile `../../`, but do not use relative paths with `~/`. # Sole (!) exception is in playermpd.mpd_conf system: box_name: Jukebox diff --git a/resources/default-settings/nginx.default b/resources/default-settings/nginx.default index b949beb26..d664f4cdd 100644 --- a/resources/default-settings/nginx.default +++ b/resources/default-settings/nginx.default @@ -2,7 +2,7 @@ server { listen 80 default_server; listen [::]:80 default_server; - root /home/pi/RPi-Jukebox-RFID/src/webapp/build; + root %%INSTALLATION_PATH%%/src/webapp/build; index index.html index.htm; @@ -21,7 +21,7 @@ server { } location /logs { - root /home/pi/RPi-Jukebox-RFID/shared; + root %%INSTALLATION_PATH%%/shared; autoindex on; autoindex_exact_size off; @@ -31,14 +31,14 @@ server { } location @buildwebui { - root /home/pi/RPi-Jukebox-RFID/resources/html; + root %%INSTALLATION_PATH%%/resources/html; try_files /runbuildui.html =404; internal; } error_page 404 = /404.html; location /404.html { - root /home/pi/RPi-Jukebox-RFID/resources/html; + root %%INSTALLATION_PATH%%/resources/html; internal; } } diff --git a/src/webapp/src/config.js b/src/webapp/src/config.js index 4383a7897..35b5a980e 100644 --- a/src/webapp/src/config.js +++ b/src/webapp/src/config.js @@ -17,9 +17,7 @@ const SUBSCRIPTIONS = [ 'volume.level', ]; -// TODO: This is not optimal, we should not know about this path here! -// Let's try to work with relatives paths in the RPC only! -const DEFAULT_AUDIO_DIR = '/home/pi/RPi-Jukebox-RFID/shared/audiofolders'; +const DEFAULT_AUDIO_DIR = '../../shared/audiofolders'; const ROOT_DIRS = ['./', DEFAULT_AUDIO_DIR];