Compare commits
4 Commits
8c4de33b2a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
fe0b002258
|
|||
|
f96e9dbecd
|
|||
|
49581d9829
|
|||
|
d66c55f2ab
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
|||||||
# SPDX-FileCopyrightText: 2023 Max Mehl <https://mehl.mx>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@ and makes sure all requirements and systemd jobs are set up properly.
|
|||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* [ansible-role-users](https://src.mehl.mx/mxmehl/ansible-role-users)
|
* [ansible-role-users](https://src.mehl.mx/mxmehl/ansible-role-users)
|
||||||
|
* [ansible-role-systemd-user](https://src.mehl.mx/mxmehl/ansible-role-systemd-user)
|
||||||
|
|
||||||
## Configure
|
## Configure
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 Max Mehl <https://mehl.mx>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
---
|
---
|
||||||
seafile_cron:
|
seafile_cron:
|
||||||
minute: "20"
|
minute: "20"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ StartLimitBurst=3
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/bin/seaf-daemon -c {{ seafile_local_user_info.home }}/.ccnet -d {{ seafile_local_user_info.home }}/config/seafile-data -w {{ seafile_local_user_info.home }}/config/seafile
|
ExecStart=/usr/bin/seaf-daemon -c %h/.ccnet -d %h/config/seafile-data -w %h/config/seafile
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
# Restart every day
|
# Restart every day
|
||||||
@@ -17,19 +17,12 @@
|
|||||||
name:
|
name:
|
||||||
- moreutils # chronic
|
- moreutils # chronic
|
||||||
- pipx
|
- pipx
|
||||||
- systemd-container # necessary to use machinectl become_method
|
|
||||||
- seafile-cli
|
- seafile-cli
|
||||||
become: false # need to do this as root
|
become: false # need to do this as root
|
||||||
|
|
||||||
- name: Register user info of {{ seafile_local_user.user }}
|
|
||||||
user:
|
|
||||||
name: "{{ seafile_local_user.user }}"
|
|
||||||
check_mode: true
|
|
||||||
register: seafile_local_user_info
|
|
||||||
|
|
||||||
- name: Define directory for Seafile mirror service as fact
|
- name: Define directory for Seafile mirror service as fact
|
||||||
set_fact:
|
set_fact:
|
||||||
seafile_mirror_dir: "{{ seafile_local_user_info.home }}/seafile_mirror"
|
seafile_mirror_dir: "~/seafile_mirror"
|
||||||
|
|
||||||
- name: Ensure directory for Seafile mirror service exists
|
- name: Ensure directory for Seafile mirror service exists
|
||||||
file:
|
file:
|
||||||
@@ -63,46 +56,24 @@
|
|||||||
month: "{{ seafile_cron.month }}"
|
month: "{{ seafile_cron.month }}"
|
||||||
weekday: "{{ seafile_cron.weekday }}"
|
weekday: "{{ seafile_cron.weekday }}"
|
||||||
|
|
||||||
- name: Ensure user systemd directory exists
|
|
||||||
file:
|
|
||||||
path: "{{ seafile_local_user_info.home }}/.config/systemd/user/"
|
|
||||||
state: directory
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Ensure systemd service file is present
|
|
||||||
template:
|
|
||||||
src: seaf-daemon.service.j2
|
|
||||||
dest: "{{ seafile_local_user_info.home }}/.config/systemd/user/seaf-daemon.service"
|
|
||||||
mode: "0644"
|
|
||||||
|
|
||||||
- name: Ensure Seafile config dir exists
|
- name: Ensure Seafile config dir exists
|
||||||
file:
|
file:
|
||||||
path: "{{ seafile_local_user_info.home }}/config"
|
path: "~/config"
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: Ensure Seafile config dir is initialised
|
- name: Ensure Seafile config dir is initialised
|
||||||
command:
|
command:
|
||||||
cmd: seaf-cli init -d "{{ seafile_local_user_info.home }}/config"
|
cmd: seaf-cli init -d "~/config"
|
||||||
register: result
|
register: result
|
||||||
changed_when: '"already exists" not in result.stdout'
|
changed_when: '"already exists" not in result.stdout'
|
||||||
|
|
||||||
- name: "Check whether user is lingering: {{ seafile_local_user.user }}"
|
- name: Setup systemd user service
|
||||||
stat:
|
include_role:
|
||||||
path: "/var/lib/systemd/linger/{{ seafile_local_user.user }}"
|
name: systemd-user
|
||||||
register: seafile_local_user_lingering
|
apply:
|
||||||
|
|
||||||
- name: Ensure systemd lingering is enabled for user {{ seafile_local_user.user }}
|
|
||||||
command: loginctl enable-linger {{ seafile_local_user.user }}
|
|
||||||
become: false
|
become: false
|
||||||
changed_when: false
|
vars:
|
||||||
when: not seafile_local_user_lingering.stat.exists
|
user: "{{ seafile_local_user.user }}"
|
||||||
|
service: seaf-daemon
|
||||||
- name: Ensure systemd service is running and enabled
|
copy_file: seaf-daemon.service
|
||||||
systemd:
|
|
||||||
name: seaf-daemon
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
daemon_reload: true
|
|
||||||
scope: user
|
|
||||||
become_method: community.general.machinectl # in order to get XDG_RUNTIME_DIR and user's DBUS session
|
|
||||||
|
|||||||
Reference in New Issue
Block a user