Skip to content

Commit

Permalink
Merge pull request #94 from Xenira/fix-config-directory
Browse files Browse the repository at this point in the history
Fix config directory #93
  • Loading branch information
Psychokiller1888 authored Feb 5, 2021
2 parents 7e6ab01 + 681ea68 commit 9a0c1bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ engine: "%ENGINE%"
pathToConfig: "%PATHTOCONFIG%"
hardware: "%DEVICE%"
pattern: "%PATTERN%"
enableDoA: "%DOA%"
enableDoA: %DOA%
28 changes: 15 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ if [[ "$device" != "don't overwrite existing parameters" ]]; then
esac
done

defaultConfigurationPath=${USERDIR}'/.config/hermesLedControl/configuration.yml'
defaultConfigurationPath=${USERDIR}'/.config/hermesLedControl'
echo "Where should the configuration be saved to?"
read -p "Path (${defaultConfigurationPath})" configurationPath
configurationPath=${configurationPath:-$defaultConfigurationPath}
configurationFile=${configurationPath}/configuration.yml
echo "Path: $configurationPath"
escapedConfigurationPath=${configurationPath//\//\\/}
escapedConfigurationFile=${configurationFile//\//\\/}
fi

doaConfigValue="false"
Expand Down Expand Up @@ -140,27 +141,28 @@ if [[ ! -f /etc/systemd/system/hermesledcontrol.service ]]; then
cp hermesledcontrol.service /etc/systemd/system
fi

if [[ "$device" != "don't overwrite existing parameters" && -f ${configurationPath} ]]; then
rm ${configurationPath}
if [[ "$device" != "don't overwrite existing parameters" && -f ${configurationFile} ]]; then
rm ${configurationFile}
fi

if [[ "$device" != "don't overwrite existing parameters" && ! -f ${configurationPath} ]]; then
if [[ "$device" != "don't overwrite existing parameters" && ! -f ${configurationFile} ]]; then
mkdir -p ${configurationPath}
cp configuration.yml ${configurationPath}
chown ${USER} ${configurationPath}
chown ${USER} ${configurationFile}

sed -i -e "s/%ENGINE%/"${engine}"/" ${configurationFile}
sed -i -e "s/%PATHTOCONFIG%/"${pathToAssistantConfig}"/" ${configurationFile}
sed -i -e "s/%DEVICE%/"${device}"/" ${configurationFile}
sed -i -e "s/%PATTERN%/"${pattern}"/" ${configurationFile}
sed -i -e "s/%DOA%/"${doaConfigValue}"/" ${configurationFile}
fi

escaped=${USERDIR//\//\\/}
sed -i -e "s/%WORKING_DIR%/"${escaped}"\/hermesLedControl_"${VERSION}"/" /etc/systemd/system/hermesledcontrol.service
sed -i -e "s/%USER%/"${USER}"/" /etc/systemd/system/hermesledcontrol.service

if [[ "$device" != "don't overwrite existing parameters" ]]; then
sed -i -e "s/%ENGINE%/"${engine}"/" ${configurationPath}
sed -i -e "s/%PATHTOCONFIG%/"${pathToAssistantConfig}"/" ${configurationPath}
sed -i -e "s/%DEVICE%/"${device}"/" ${configurationPath}
sed -i -e "s/%PATTERN%/"${pattern}"/" ${configurationPath}
sed -i -e "s/%DOA%/"${doaConfigValue}"/" ${configurationPath}

sed -i -e "s/%EXECSTART%/"${escaped}"\/hermesLedControl_"${VERSION}"\/venv\/bin\/python3 main.py --hermesLedControlConfig="${escapedConfigurationPath}"/" /etc/systemd/system/hermesledcontrol.service
sed -i -e "s/%EXECSTART%/"${escaped}"\/hermesLedControl_"${VERSION}"\/venv\/bin\/python3 main.py --hermesLedControlConfig="${escapedConfigurationFile}"/" /etc/systemd/system/hermesledcontrol.service
fi

if [[ -d "/var/lib/hermes/skills/snips-skill-respeaker" ]]; then
Expand Down

0 comments on commit 9a0c1bb

Please # to comment.