diff --git a/scripts/installscripts/buster-install-default.sh b/scripts/installscripts/buster-install-default.sh index 72e94ca31..a3ab8f637 100755 --- a/scripts/installscripts/buster-install-default.sh +++ b/scripts/installscripts/buster-install-default.sh @@ -125,10 +125,11 @@ reset_install_config_file() { # from such a config file with no user input. # Remove existing config file - rm "${HOME_DIR}/PhonieboxInstall.conf" + #rm "${HOME_DIR}/PhonieboxInstall.conf" # Create empty config file - touch "${HOME_DIR}/PhonieboxInstall.conf" - echo "# Phoniebox config" > "${HOME_DIR}/PhonieboxInstall.conf" + #touch "${HOME_DIR}/PhonieboxInstall.conf" + #echo "# Phoniebox config" > "${HOME_DIR}/PhonieboxInstall.conf" + echo "# Phoniebox config" } config_wifi() { @@ -202,6 +203,7 @@ read -rp "Hit ENTER to proceed to the next step." INPUT check_existing() { local jukebox_dir="$1" local backup_dir="$2" + local home_dir="$3" ##################################################### # Check for existing Phoniebox @@ -230,10 +232,44 @@ check_existing() { # get the current short commit hash of the repo CURRENT_REMOTE_COMMIT="$(git ls-remote https://github.com/MiczFlor/RPi-Jukebox-RFID.git ${GIT_BRANCH} | cut -c1-7)" fi - echo "IMPORTANT: you can use the existing content and configuration files for your new install." + echo "IMPORTANT: you can use the existing content and configuration" + echo "files for your new install." echo "Whatever you chose to keep will be moved to the new install." echo "Everything else will remain in a folder called 'BACKUP'. " + + ### + # See if we find the PhonieboxInstall.conf file + # We need to do this first, because if we re-use the .conf file, we need to append + # the variables regarding the found content to the also found configuration file. + # That way, reading the configuration file for the (potentially) non-interactive + # install procedure will: + # a) overwrite whatever variables regarding re-cycling existing content which might + # be stored in the config file + # b) if there are no variables for dealing with re-cycled context, we will append + # them - to have them for this install + if [ -f "${jukebox_dir}"/settings/PhonieboxInstall.conf ]; then + # ask for re-using the found configuration file + echo "The configuration of your last Phoniebox install was found." + read -rp "Use existing configuration for this installation? [Y/n] " response + case "$response" in + [nN][oO]|[nN]) + EXISTINGusePhonieboxInstall=NO + ;; + *) + EXISTINGusePhonieboxInstall=YES + # Copy PhonieboxInstall.conf configuration file to settings folder + sudo cp "${jukebox_dir}"/settings/PhonieboxInstall.conf "${home_dir}"/PhonieboxInstall.conf + sudo chown pi:www-data "${home_dir}"/PhonieboxInstall.conf + sudo chmod 775 "${home_dir}"/PhonieboxInstall.conf + echo "The existing configuration will be used." + echo "Just a few more questions to answer." + read -rp "Hit ENTER to proceed to the next step." INPUT + clear + ;; + esac + fi + # Delete or use existing installation? read -rp "Re-use config, audio and RFID codes for the new install? [Y/n] " response case "$response" in @@ -331,6 +367,25 @@ check_existing() { fi # append variables to config file echo "EXISTINGuse=$EXISTINGuse" >> "${HOME_DIR}/PhonieboxInstall.conf" + + # Check if we found a Phoniebox install configuration earlier and ask if to run this now + if [ "${EXISTINGusePhonieboxInstall}" == "YES" ]; then + clear + echo "Using the existing configuration, you can run a non-interactive install." + echo "This will re-cycle found content (specified just now) as well as the" + echo "system information from last time (wifi, audio interface, spotify, etc.)." + read -rp "Do you want to run a non-interactive installation? [Y/n] " response + case "$response" in + [nN][oO]|[nN]) + ;; + *) + cd "${home_dir}" + clear + ./buster-install-default.sh -a + exit + ;; + esac + fi } config_audio_interface() { @@ -1089,9 +1144,9 @@ finish_installation() { main() { if [[ ${INTERACTIVE} == "true" ]]; then welcome - reset_install_config_file + #reset_install_config_file config_wifi - check_existing "${JUKEBOX_HOME_DIR}" "${JUKEBOX_BACKUP_DIR}" + check_existing "${JUKEBOX_HOME_DIR}" "${JUKEBOX_BACKUP_DIR}" "${HOME_DIR}" config_audio_interface config_spotify config_mpd @@ -1106,6 +1161,12 @@ main() { wifi_settings "${JUKEBOX_HOME_DIR}/misc/sampleconfigs" "/etc/dhcpcd.conf" "/etc/wpa_supplicant/wpa_supplicant.conf" existing_assets "${JUKEBOX_HOME_DIR}" "${JUKEBOX_BACKUP_DIR}" folder_access "${JUKEBOX_HOME_DIR}" "pi:www-data" 775 + + # Copy PhonieboxInstall.conf configuration file to settings folder + sudo cp "${HOME_DIR}/PhonieboxInstall.conf" "${JUKEBOX_HOME_DIR}/settings/" + sudo chown pi:www-data "${JUKEBOX_HOME_DIR}/settings/PhonieboxInstall.conf" + sudo chmod 775 "${JUKEBOX_HOME_DIR}/settings/PhonieboxInstall.conf" + if [[ ${INTERACTIVE} == "true" ]]; then finish_installation "${JUKEBOX_HOME_DIR}" else diff --git a/scripts/playout_controls.sh b/scripts/playout_controls.sh index 3f1964eaf..6252a2655 100755 --- a/scripts/playout_controls.sh +++ b/scripts/playout_controls.sh @@ -570,6 +570,7 @@ case $COMMAND in # write latest folder played to settings file sudo echo ${FOLDER} > ${PATHDATA}/../settings/Latest_Folder_Played + sudo chown pi:www-data ${PATHDATA}/../settings/Latest_Folder_Played sudo chmod 777 ${PATHDATA}/../settings/Latest_Folder_Played if [ "${DEBUG_playout_controls_sh}" == "TRUE" ]; then echo " echo ${FOLDER} > ${PATHDATA}/../settings/Latest_Folder_Played" >> ${PATHDATA}/../logs/debug.log; fi if [ "${DEBUG_playout_controls_sh}" == "TRUE" ]; then echo " VAR Latest_Folder_Played: ${FOLDER}" >> ${PATHDATA}/../logs/debug.log; fi diff --git a/scripts/rfid_trigger_play.sh b/scripts/rfid_trigger_play.sh index 3b638328e..47eac6d44 100755 --- a/scripts/rfid_trigger_play.sh +++ b/scripts/rfid_trigger_play.sh @@ -466,6 +466,7 @@ if [ ! -z "$FOLDER" -a ! -z ${FOLDER+x} -a -d "${AUDIOFOLDERSPATH}/${FOLDER}" ]; if [ "${DEBUG_rfid_trigger_play_sh}" == "TRUE" ]; then echo " Command: $PATHDATA/playout_controls.sh -c=playlistaddplay -v=\"${PLAYLISTNAME}\" -d=\"${FOLDER}\"" >> $PATHDATA/../logs/debug.log; fi # save latest playlist not to file sudo echo ${PLAYLISTNAME} > $PATHDATA/../settings/Latest_Playlist_Played + sudo chown pi:www-data $PATHDATA/../settings/Latest_Playlist_Played sudo chmod 777 $PATHDATA/../settings/Latest_Playlist_Played fi if [ "$PLAYPLAYLIST" == "skipnext" ]