Skip to content

Commit

Permalink
fix: python path for mopidy sudoers file
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller committed Apr 5, 2024
1 parent 8c679e0 commit 837fbbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion scripts/installscripts/install-jukebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions scripts/installscripts/tests/test_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ check_file_exists() {
check_file_contains_string() {
local string="$1"
local file="$2"
local allowPartCheck="$3"

local grep_option="w"
if [ -v allowPartCheck ]; then
grep_option=""
fi

# sudo is required for checking /etc/mopidy/mopidy.conf
if [[ ! $(sudo grep -iw "${string}" "${file}") ]]; then
if [[ ! $(sudo grep -i"${grep_option}" "${string}" "${file}") ]]; then
echo " ERROR: '${string}' not found in ${file}"
((failed_tests++))
fi
Expand Down Expand Up @@ -440,7 +446,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" allowPartCheck
check_file_contains_string "/dist-packages/mopidy_iris/system.sh" "/etc/sudoers.d/mopidy" allowPartCheck
check_chmod_chown 440 root root "/etc/sudoers.d/" "mopidy"

# check that mopidy service is enabled
Expand Down

0 comments on commit 837fbbd

Please sign in to comment.