Skip to content

Commit

Permalink
Service: put the restart flag into /tmp (evcc-io#6430)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauxus authored Feb 25, 2023
1 parent 6971eb3 commit 4956725
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packaging/scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ set -e
USER_CHOICE_CONFIG="/etc/evcc-userchoices.sh"
ETC_SERVICE="/etc/systemd/system/evcc.service"
USR_LOCAL_BIN="/usr/local/bin/evcc"
RESTART_FLAG_FILE=/var/lib/evcc/.restartOnUpgrade
RESTART_FLAG_FILE="/tmp/.restartEvccOnUpgrade"

# Usage: askUserKeepFile <file>
# Return: 1 = keep, 0 = delete
askUserKeepFile() {
while true; do
echo "Shall '$1' be deleted? [Y/n]: "
read answer
case "$answer" in
case "$answer" in
n*|N*)
echo "Ok. We will keep that file. Keep in mind that you may need to alter it if any changes are done upstream. Your answer is saved for the future."
return 1
Expand Down Expand Up @@ -45,15 +45,15 @@ if [ "$1" = "configure" ]; then
echo "This is probably due to a previous manual installation."
echo "You probably want to delete this file now. Your evcc configuration stays untouched!"
askUserKeepFile "$ETC_SERVICE" || KEEP_ETC_SERVICE=$?
fi
fi
if [ -f "$USR_LOCAL_BIN" ] && [ "$KEEP_USR_LOCAL_BIN" -eq 0 ]; then
echo "An alternate evcc binary was detected under '$USR_LOCAL_BIN'."
echo "This is probably due to a previous manual installation."
echo "You probably want to delete this file now. Your evcc configuration stays untouched!"
askUserKeepFile "$USR_LOCAL_BIN" || KEEP_USR_LOCAL_BIN=$?
fi
# Save the user decision
cat > "$USER_CHOICE_CONFIG" <<EOF
cat > "$USER_CHOICE_CONFIG" <<EOF
#!/bin/sh
KEEP_ETC_SERVICE=$KEEP_ETC_SERVICE
KEEP_USR_LOCAL_BIN=$KEEP_USR_LOCAL_BIN
Expand Down
2 changes: 1 addition & 1 deletion packaging/scripts/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -e
EVCC_USER=evcc
EVCC_GROUP=evcc
EVCC_HOME="/var/lib/$EVCC_USER"
RESTART_FLAG_FILE=$EVCC_HOME/.restartOnUpgrade
RESTART_FLAG_FILE="/tmp/.restartEvccOnUpgrade"

copyDbToUserDir() {
CURRENT_USER=$(systemctl show -pUser evcc | cut -d= -f2)
Expand Down

0 comments on commit 4956725

Please sign in to comment.