12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import os.path
- import sys
- from piket_client.gui import PiketMainWindow
- icons_dir = PiketMainWindow.icons_dir
- systemd_user_dir = os.path.expanduser("~/.config/systemd/user")
- python_interpreter_dir = os.path.dirname(sys.executable)
- uwsgi_path = os.path.join(python_interpreter_dir, "uwsgi")
- piket_client_path = os.path.join(python_interpreter_dir, "piket-client")
- piket_manage_people_path = os.path.join(python_interpreter_dir, "piket-manage-people")
- server_template = f"""[Unit]
- Description=piket server daemon
- [Service]
- ExecStart={uwsgi_path} --http :5000 --master --threads 2 --module piket_server:app
- KillSignal=SIGINT
- Type=notify
- NotifyAccess=all
- Environment=SENTRY_DSN={os.environ.get("SENTRY_DSN")}
- [Install]
- WantedBy=default.target
- """
- client_template = f"""[Unit]
- Description=piket client
- Requires=piket-server.service
- After=piket-server.service
- [Service]
- ExecStart={piket_client_path}
- Environment=SENTRY_DSN={os.environ.get("SENTRY_DSN")}
- [Install]
- WantedBy=graphical.target
- """
- os.makedirs(systemd_user_dir, exist_ok=True)
- with open(os.path.join(systemd_user_dir, "piket-server.service"), "w") as f:
- f.write(server_template)
- with open(os.path.join(systemd_user_dir, "piket-client.service"), "w") as f:
- f.write(client_template)
- # Desktop files
- main_template = f"""[Desktop Entry]
- Version=0.1.0
- Type=Application
- Name=Start Bierlijst
- Terminal=False
- Comment=V-V-V-OUWEN!!!
- Exec=systemctl --user start piket-client
- Icon={os.path.join(icons_dir, "white_beer_bottle.svg")}
- """
- manage_people = f"""[Desktop Entry]
- Version=0.1.0
- Type=Application
- Name=Personen aanwezig
- Terminal=False
- Comment=Stel in wie er is.
- Exec={sys.executable} -m piket_client.set_active
- Icon={os.path.join(icons_dir, "white_add_person.svg")}
- """
- with open(
- os.path.join(os.path.expanduser("~/Desktop"), "piket-client.desktop"), "w"
- ) as f:
- f.write(main_template)
- with open(
- os.path.join(os.path.expanduser("~/Desktop"), "piket-manage-people.desktop"), "w"
- ) as f:
- f.write(manage_people)
- print("Done! Don't forget to systemctl --user daemon-reload.")
|