Created
February 18, 2021 12:48
-
-
Save jal25jal25/7b118e1c5b52bb28f127e6116bc2690e to your computer and use it in GitHub Desktop.
Configurable /home/pi/lcv_startall.sh for Jamulus client on Raspberry Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Log last invocation to file for debugging | |
LOGFILE=/home/pi/lcv_startall.log | |
exec > ${LOGFILE} 2>&1 | |
# This value can be overridden by the LCV config file | |
JAMULUS_SERVER_DEFAULT="your_jamulus_server_hostname_or_ip_address" | |
JACKD_FRAMES_PER_PERIOD_DEFAULT=128 | |
# If LCV config file exists, read the variables there | |
LCV_CONFIG=/boot/lcv_config.txt | |
JAMULUS_INI=/home/pi/.config/Jamulus/Jamulus.ini | |
if [ -f ${LCV_CONFIG} ]; then | |
source ${LCV_CONFIG} | |
if [ ! -f ${JAMULUS_INI} ] || [ ${LCV_CONFIG} -nt ${JAMULUS_INI} ]; then | |
echo "*** Reading LCV config file found at ${LCV_CONFIG}" | |
# Base64 encode the name and city | |
export JAMULUS_NAME_BASE64=$(echo -n "${JAMULUS_NAME}" | /usr/bin/base64) | |
export JAMULUS_CITY_BASE64=$(echo -n "${JAMULUS_CITY}" | /usr/bin/base64) | |
echo "*** Writing new Jamulus.ini" | |
/usr/bin/envsubst < /home/pi/Jamulus.ini.template > ${JAMULUS_INI} | |
fi | |
else | |
# LCV config file cannot be read | |
echo "*** No LCV config file found at ${LCV_CONFIG}" | |
JAMULUS_SERVER=${JAMULUS_SERVER_DEFAULT} | |
JACKD_FRAMES_PER_PERIOD=${JACKD_FRAMES_PER_PERIOD_DEFAULT} | |
fi | |
JACKD_CMD="/usr/bin/jackd -R -dalsa -dhw:1 -r48000 -p${JACKD_FRAMES_PER_PERIOD} -n2" | |
JAMULUS_CMD="Jamulus -c ${JAMULUS_SERVER}" | |
# Start jackd if it is not already running | |
if ps -ef |grep "[ ]/usr/bin/jackd" >/dev/null; then | |
echo "*** jackd already running - not attempting to start" | |
else | |
echo "*** Starting jackd: ${JACKD_CMD}" | |
${JACKD_CMD} & | |
if [ $? != 0 ]; then | |
echo "*** Failed to start jackd - exiting" | |
exit 1 | |
fi | |
# Give everything a chance to settle | |
sleep 5 | |
fi | |
# Start Jamulus if it is not already running | |
if ps -ef |grep "[J]amulus" >/dev/null; then | |
echo "*** Jamulus already running - not attempting to start" | |
else | |
echo "*** Starting Jamulus: ${JAMULUS_CMD}" | |
${JAMULUS_CMD} & | |
if [ $? == 0 ]; then | |
echo "*** Successfully started Jamulus" | |
else | |
echo "*** Jamulus failed to start" | |
exit 2 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment