Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd user service #3510

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,13 @@ elseif(BUILD_CLIENT)
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(INSTALL_SYSTEMD "Install systemd user service" ON)
if(INSTALL_SYSTEMD)
set(bindir ${CMAKE_INSTALL_FULL_BINDIR})
configure_file(systemd/nextcloud-desktop.service.in ${CMAKE_CURRENT_BINARY_DIR}/nextcloud-desktop.service)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of nextcloud-desktop please use this cmake variable LINUX_APPLICATION_ID
that is already in use with the .desktop file generation (https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt#L732)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nextcloud-desktop.service DESTINATION lib/systemd/user)
endif()
endif()

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)
17 changes: 17 additions & 0 deletions systemd/nextcloud-desktop.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda <andrea@pappacoda.it>
#
# SPDX-License-Identifier: GPL-2.0-or-later

[Unit]
Description=Nextcloud desktop user service
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please replace Nextcloud by this variable from cmake APPLICATION_NAME

Wants=network-online.target

[Service]
ExecStart=@bindir@/nextcloud --background
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executable name is defined as a variable in cmake files
please replace this by this variable APPLICATION_EXECUTABLE

Restart=on-failure
RestartSec=5s
NoNewPrivileges=true
RestrictRealtime=true

[Install]
WantedBy=default.target