From 3033969900afe4ed58e6050ce0727fe6c6923f36 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:20:54 +0200 Subject: [PATCH] fix: python path for mopidy sudoers file --- scripts/installscripts/install-jukebox.sh | 4 +++- scripts/installscripts/tests/test_installation.sh | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/installscripts/install-jukebox.sh b/scripts/installscripts/install-jukebox.sh index 0fc4afdaa..11cfc166a 100644 --- a/scripts/installscripts/install-jukebox.sh +++ b/scripts/installscripts/install-jukebox.sh @@ -970,7 +970,9 @@ install_main() { ${pip_install} -r "${jukebox_dir}"/requirements-spotify.txt local sudoers_mopidy="/etc/sudoers.d/mopidy" - echo "mopidy ALL=NOPASSWD: /usr/local/lib/python2.7/dist-packages/mopidy_iris/system.sh" | sudo tee "${sudoers_mopidy}" > /dev/null + # Include 'python' in the command to make testing later on easier. If this command fails it will not be included in the file. + local python_version=$(python -c 'import sys; print("python{}.{}".format(sys.version_info.major, sys.version_info.minor))') + echo "mopidy ALL=NOPASSWD: /usr/local/lib/${python_version}/dist-packages/mopidy_iris/system.sh" | sudo tee "${sudoers_mopidy}" > /dev/null sudo chown root:root "${sudoers_mopidy}" sudo chmod 440 "${sudoers_mopidy}" fi diff --git a/scripts/installscripts/tests/test_installation.sh b/scripts/installscripts/tests/test_installation.sh index e92994aaa..6b2905ba3 100755 --- a/scripts/installscripts/tests/test_installation.sh +++ b/scripts/installscripts/tests/test_installation.sh @@ -440,7 +440,8 @@ verify_spotify_config() { check_file_contains_string "client_id = ${SPOTIclientid}" "${mopidy_conf}" check_file_contains_string "client_secret = ${SPOTIclientsecret}" "${mopidy_conf}" check_file_contains_string "media_dir = ${DIRaudioFolders}" "${mopidy_conf}" - check_file_contains_string "mopidy ALL=NOPASSWD: /usr/local/lib/python2.7/dist-packages/mopidy_iris/system.sh" "/etc/sudoers.d/mopidy" + check_file_contains_string "mopidy ALL=NOPASSWD: /usr/local/lib/python" "/etc/sudoers.d/mopidy" + check_file_contains_string "/dist-packages/mopidy_iris/system.sh" "/etc/sudoers.d/mopidy" check_chmod_chown 440 root root "/etc/sudoers.d/" "mopidy" # check that mopidy service is enabled