-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps_memos.yml
98 lines (84 loc) · 2.66 KB
/
apps_memos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
- name: Deply memos on LXC
gather_facts: no
hosts: memos
connection: local
ignore_errors: no
vars:
memos_version: "v0.23.1"
tasks:
- name: Read current version
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "if [ -f /opt/memos/version ]; then cat /opt/memos/version; fi"
register: result
- name: Check current version
meta: end_play
when: result.output == memos_version
- name: Use USTC mirrors
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories"
- name: Install wget
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "apk update && apk add wget"
- name: Create run directory
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "mkdir -p /opt/memos"
- name: Download memos to tmp
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "wget https://github.com/usememos/memos/releases/download/{{ memos_version }}/memos_{{ memos_version }}_linux_amd64.tar.gz -O /tmp/memos.tar.gz"
- name: Create tmp directory
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "mkdir -p /tmp/memos"
- name: Extract memos to tmp
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "tar -xzf /tmp/memos.tar.gz -C /tmp/memos"
- name: Backup old
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "if [ -f /opt/memos/memos ]; then mv -f /opt/memos/memos /opt/memos/memos.old; fi"
- name: Move news
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "mv /tmp/memos/memos /opt/memos"
- name: Create init.d
pct:
cmd: "push"
host: "{{ inventory_hostname }}"
src: "./apps/memos/init.d.sh"
dest: "/etc/init.d/memos"
extra_args: "--perms 0755"
- name: Create Update Daemon
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "rc-update add memos"
- name: Restart memos
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "/etc/init.d/memos restart"
- name: Write current version
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "echo {{ memos_version }} > /opt/memos/version"
- name: Clean
pct:
cmd: "exec"
host: "{{ inventory_hostname }}"
extra_args: "rm -rf /tmp/memos.tar.gz; rm -rf /tmp/memos"