Skip to content

Commit

Permalink
Add support for unattended install and check Python virtual env on st…
Browse files Browse the repository at this point in the history
…artup
  • Loading branch information
ron.record committed Oct 28, 2024
1 parent 6f4cf6b commit f953954
Show file tree
Hide file tree
Showing 14 changed files with 524 additions and 566 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

October 27, 2024 :
RoonCommandLine version 2.1.4 release 1

This release primarily provides support for unattended installation
* Check and repair the RoonCommandLine Python virtual environment

June 11, 2024 :
RoonCommandLine version 2.1.3 release 2

Expand Down
107 changes: 63 additions & 44 deletions Install
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,44 @@ PKG_SELECTED=

# User should not be root. Prompt to proceed if root user
iamroot=
SUDO="sudo -E"
if [ "${EUID}" ]
then
[ ${EUID} -eq 0 ] && iamroot=1
[ ${EUID} -eq 0 ] && {
iamroot=1
SUDO=
}
else
uid=`id -u`
[ ${uid} -eq 0 ] && iamroot=1
[ ${uid} -eq 0 ] && {
iamroot=1
SUDO=
}
fi

[ "$1" == "unattended" ] && export ROON_UNATTENDED="unattended"

[ "${iamroot}" ] && {
printf "\nThe ${BOLD}Install${NORM} command should be run as a normal user."
printf "\nIt appears it has been invoked with 'root' user privileges.\n\n"
while true
do
read -p "Do you intend to use RoonCommandLine as the 'root' user ? (y/n) " yn
case $yn in
[Yy]* )
[ "${ROON_UNATTENDED}" ] || {
printf "\nThe ${BOLD}Install${NORM} command should be run as a normal user."
printf "\nIt appears it has been invoked with 'root' user privileges.\n\n"
while true
do
read -p "Do you intend to use RoonCommandLine as the 'root' user ? (y/n) " yn
case $yn in
[Yy]* )
break
;;
[Nn]* )
[Nn]* )
printf "\nRe-run this command as a normal user."
printf "\nExiting.\n\n"
exit 0
;;
* ) echo "Please answer yes or no."
* ) echo "Please answer yes or no."
;;
esac
done
esac
done
}
}

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand Down Expand Up @@ -79,10 +90,13 @@ get_available_packages() {
install_selected() {
for pkg in ${PKG_AVAILABLE}
do
while true
do
read -p "Install ${pkg} ? ('Y'/'N'): " yn
case $yn in
if [ "${ROON_UNATTENDED}" ]; then
PKG_SELECTED="${PKG_SELECTED} $pkg"
else
while true
do
read -p "Install ${pkg} ? ('Y'/'N'): " yn
case $yn in
[Yy]*)
PKG_SELECTED="${PKG_SELECTED} $pkg"
break
Expand All @@ -93,16 +107,17 @@ install_selected() {
* )
echo "Please answer yes or no."
;;
esac
done
esac
done
fi
done
PKG_SELECTED=`echo $PKG_SELECTED | sed -e "s/^ //"`
}

plat=`uname -s`
if [ "$plat" == "Darwin" ]
then
./macInstall
./macInstall ${ROON_UNATTENDED}
else
debian=
have_apt=`type -p apt`
Expand Down Expand Up @@ -189,49 +204,53 @@ else
then
if [ "${have_apt}" ]
then
sudo apt install "${PKG}"
${SUDO} apt install "${PKG}"
else
if [ "${have_dpkg}" ]
then
sudo dpkg -i "${PKG}"
${SUDO} dpkg -i "${PKG}"
else
echo "Cannot locate either apt or dpkg to install. Skipping."
fi
fi
else
if [ "${have_yum}" ]
then
sudo yum localinstall "${PKG}"
${SUDO} yum localinstall "${PKG}"
else
if [ "${have_rpm}" ]
then
sudo rpm -i "${PKG}"
${SUDO} rpm -i "${PKG}"
else
echo "Cannot locate either yum or rpm to install. Skipping."
fi
fi
fi
done
else
while true
do
echo ""
echo "No packages for version ${PKG_VER} are currently available."
echo "Would you like to perform a scripted install on this platform?"
echo ""
read -p "Install ${pkg} ? ('Y'/'N'): " yn
case $yn in
[Yy]*)
./linInstall
break
;;
[Nn]*)
break
;;
*)
echo "Please answer yes or no."
;;
esac
done
if [ "${ROON_UNATTENDED}" ]; then
./linInstall unattended
else
while true
do
echo ""
echo "No packages for version ${PKG_VER} are currently available."
echo "Would you like to perform a scripted install on this platform?"
echo ""
read -p "Install ${pkg} ? ('Y'/'N'): " yn
case $yn in
[Yy]*)
./linInstall
break
;;
[Nn]*)
break
;;
*)
echo "Please answer yes or no."
;;
esac
done
fi
fi
fi
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION=2.1.3
RELEASE=2
VERSION=2.1.4
RELEASE=1
27 changes: 22 additions & 5 deletions bin/roon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# roon - frontend script to issue commands to Roon via the Python Roon API
#
Expand Down Expand Up @@ -59,7 +59,7 @@ usage() {
rich " [cyan]-F[/] [yellow]\[from zone][/] [cyan]-f[/] [yellow]\[on|onlog|off|status][/] [cyan]-g[/] [yellow]genre[/] [cyan]-G[/] [yellow]zone_group[/] [cyan]-i[/]" --print
rich " [cyan]-I -l[/] [yellow]\[albums|artists|artalbums|albtracks|arttracks|composers|comalbums|[/]" --print
rich " [yellow]genres|genalbums|genartists|playlists|playtracks|tags|zones][/]" --print
rich " [cyan]-c[/] [yellow]\[group|ungroup|play|play_all|pause|pause_all|stop|stop_all|[/]" --print
rich " [cyan]-c[/] [yellow]\[discover|group|ungroup|play|play_all|pause|pause_all|stop|stop_all|[/]" --print
rich " [yellow]next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all][/]" --print
rich " [cyan]-s[/] [yellow]search[/] [cyan]-p[/] [yellow]playlist[/] [cyan]-T[/] [yellow]track[/] [cyan]-t[/] [yellow]tag[/] [cyan]-z[/] [yellow]zone[/] [cyan]-L[/] [cyan]-S[/] [cyan]-r[/] [yellow]radio[/]" --print
rich " [cyan]-X[/] [yellow]ex_album[/] [cyan]-x[/] [yellow]ex_artist[/] [cyan]\[-EuU][/]" --print
Expand Down Expand Up @@ -97,7 +97,7 @@ usage() {
rich " [cyan]-T[/] [yellow]track[/] specifies a track to play" --print
rich " [cyan]-t[/] [yellow]tag[/] selects an tag to play" --print
rich " [cyan]-z[/] [yellow]zone[/] selects the Roon Zone in which to play" --print
rich " [cyan]-c[/] [yellow]\[group|ungroup|play|play_all|pause|pause_all|playpause|stop|stop_all|[/]" --print
rich " [cyan]-c[/] [yellow]\[discover|group|ungroup|play|play_all|pause|pause_all|playpause|stop|stop_all|[/]" --print
rich " [yellow]next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all][/]" --print
rich " issues the command in the selected zone" --print
rich " '[italic green]roon -c mute[/]' toggles the zone's muted or unmuted state" --print
Expand Down Expand Up @@ -131,7 +131,7 @@ usage() {
printf "\n\t-F [from zone] -f [on|onlog|off|status] -g genre -G zone_group -i"
printf "\n\t-I -l [albums|artists|artalbums|albtracks|arttracks|composers|comalbums|"
printf "\n\t genres|genalbums|genartists|playlists|playtracks|tags|zones]"
printf "\n\t-c [group|ungroup|play|play_all|pause|pause_all|stop|stop_all|"
printf "\n\t-c [discover|group|ungroup|play|play_all|pause|pause_all|stop|stop_all|"
printf "\n\t next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all]"
printf "\n\t-s search -p playlist -T track -t tag -z zone -L -S -r radio"
printf "\n\t-X ex_album -x ex_artist [-EuU]"
Expand Down Expand Up @@ -168,7 +168,7 @@ usage() {
printf "\n\t-T track specifies a track to play"
printf "\n\t-t tag selects an tag to play"
printf "\n\t-z zone selects the Roon Zone in which to play"
printf "\n\t-c [group|ungroup|play|play_all|pause|pause_all|playpause|stop|stop_all|"
printf "\n\t-c [discover|group|ungroup|play|play_all|pause|pause_all|playpause|stop|stop_all|"
printf "\n\t next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all]"
printf "\n\t issues the command in the selected zone"
printf "\n\t 'mute' toggles the zone's muted or unmuted state"
Expand Down Expand Up @@ -800,6 +800,13 @@ LOCAL=false
BOLD=$(tput bold 2>/dev/null)
NORMAL=$(tput sgr0 2>/dev/null)

# Check Python virtual environment
[ -e ${ROON}/venv/bin/python3 ] || {
printf "\nRepairing RoonCommandLine Python virtual environment ..."
[ -x ${ROONETC}/upgrade-venv ] && ${ROONETC}/upgrade-venv
printf " done\n"
}

[ -f ${ROON}/venv/bin/activate ] && source ${ROON}/venv/bin/activate
[ -x ${ROON}/venv/bin/python ] && export PYTHON=${ROON}/venv/bin/python

Expand Down Expand Up @@ -2168,6 +2175,16 @@ while getopts A:a:bBc:C:dD:f:F:g:G:hHiImnNOp:T:t:z:l:s:LSr:v:x:X:EuU flag; do
esac
done

[ "${comm}" == "discover" ] && {
if [ -x ${ROONETC}/discover ]; then
${ROONETC}/discover
exit 0
else
echo "ERROR: ${ROONETC}/discover not found or not executable. Reinstall."
exit 1
fi
}

[ "${inst_roon_gui}" ] && {
[ -x ${ROON}/etc/install-roon-gui ] && ${ROON}/etc/install-roon-gui
if [ -x ${ROON}/bin/roongui ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/roon_fade
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Written by Ron Record <[email protected]> December, 2022
#
Expand Down
2 changes: 1 addition & 1 deletion bin/roonanim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# roonanim - display, animate, zoom RoonCommandLine splash screen using Kitty
#
Expand Down
2 changes: 1 addition & 1 deletion bin/roontui
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# roontui - Frontend for roon-tui terminal user interface for Roon
# Default to ~/.config/roon-tui/ for roon-tui configuration and log files
Expand Down
Loading

0 comments on commit f953954

Please sign in to comment.