fix for installation on bullseye with sudo and autostart

This commit is contained in:
avollkopf 2023-10-18 20:30:26 +02:00
parent bead2b30ae
commit 1b666be9bc
3 changed files with 6 additions and 3 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.2.0.a4"
__version__ = "4.2.0.a5"
__codename__ = "Indian Summer"

View file

@ -151,6 +151,9 @@ class CraftBeerPiCli():
print("CraftBeerPi Autostart is {}OFF{}".format(Fore.RED,Style.RESET_ALL))
elif(name == "on"):
user=os.getlogin()
path="/usr/local/bin/cbpi start"
if os.path.exists("/home/"+user+"/.local/bin/cbpi") is True:
path="/home/"+user+"/.local/bin/cbpi start"
print("Add craftbeerpi.service to systemd")
try:
if os.path.exists(os.path.join("/etc/systemd/system","craftbeerpi.service")) is False:
@ -166,7 +169,7 @@ class CraftBeerPiCli():
srcfile=str(srcfile).replace('\\','/')
template = templateEnv.get_template("craftbeerpi.service")
outputText = template.render(user=user)
outputText = template.render(user=user, path=path)
with open(srcfile, "w") as fh:
fh.write(outputText)
destfile = os.path.join("/etc/systemd/system")

View file

@ -3,7 +3,7 @@ Description=Craftbeer Pi
[Service]
WorkingDirectory=/home/{{ user }}
ExecStart=/home/{{ user }}/.local/bin/cbpi start
ExecStart={{ path }} start
[Install]
WantedBy=multi-user.target