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" __codename__ = "Indian Summer"

View file

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

View file

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