Browse Source

Init

master
Miraty 2 months ago
parent
commit
197831c812
16 changed files with 1690 additions and 0 deletions
  1. 76
    0
      README_fr.md
  2. 49
    0
      check_process.default
  3. 6
    0
      conf/app.src
  4. 33
    0
      conf/nginx.conf
  5. 430
    0
      conf/php-fpm.conf
  6. 13
    0
      conf/systemd.service
  7. 90
    0
      manifest.json
  8. 20
    0
      scripts/_common.sh
  9. 91
    0
      scripts/backup
  10. 111
    0
      scripts/change_url
  11. 318
    0
      scripts/install
  12. 133
    0
      scripts/remove
  13. 141
    0
      scripts/restore
  14. 175
    0
      scripts/upgrade
  15. 2
    0
      sources/extra_files/app/.gitignore
  16. 2
    0
      sources/patches/.gitignore

+ 76
- 0
README_fr.md View File

@@ -0,0 +1,76 @@
1
+# App exemple pour YunoHost
2
+
3
+[![Integration level](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP)  
4
+[![Install REPLACEBYYOURAPP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP)
5
+
6
+*[Read this readme in english.](./README.md)* 
7
+
8
+> *Ce package vous permet d'installer REPLACEBYYOURAPP rapidement et simplement sur un serveur Yunohost.  
9
+Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
10
+
11
+## Vue d'ensemble
12
+Description rapide de cette application.
13
+
14
+**Version incluse:** 1.0
15
+
16
+## Captures d'écran
17
+
18
+![](Lien vers une capture d'écran pour cette application)
19
+
20
+## Démo
21
+
22
+* [Démo officielle](Lien vers un site de démonstration pour cette application)
23
+
24
+## Configuration
25
+
26
+Comment configurer cette application: via le panneau d'administration, un fichier brut en SSH ou tout autre moyen.
27
+
28
+## Documentation
29
+
30
+ * Documentation officielle: Lien vers la documentation officielle de cette application
31
+ * Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
32
+
33
+## Caractéristiques spécifiques YunoHost
34
+
35
+#### Support multi-utilisateurs
36
+
37
+L'authentification LDAP et HTTP est-elle prise en charge?
38
+L'application peut-elle être utilisée par plusieurs utilisateurs?
39
+
40
+#### Supported architectures
41
+
42
+* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
43
+* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
44
+* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/)
45
+
46
+## Limitations
47
+
48
+* Limitations connues.
49
+
50
+## Informations additionnelles
51
+
52
+* Autres informations à ajouter sur cette application
53
+
54
+**Plus d'informations sur la page de documentation:**  
55
+https://yunohost.org/packaging_apps
56
+
57
+## Links
58
+
59
+ * Signaler un bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues
60
+ * Site de l'application: Lien vers le site officiel de cette application
61
+ * Site web YunoHost: https://yunohost.org/
62
+
63
+---
64
+
65
+Informations pour les développeurs
66
+----------------
67
+
68
+**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.**
69
+Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing).
70
+
71
+Pour essayer la branche testing, procédez comme suit.
72
+```
73
+sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
74
+ou
75
+sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
76
+```

+ 49
- 0
check_process.default View File

@@ -0,0 +1,49 @@
1
+# See here for more information
2
+# https://github.com/YunoHost/package_check#syntax-check_process-file
3
+
4
+# Move this file from check_process.default to check_process when you have filled it.
5
+
6
+;; Test complet
7
+	; Manifest
8
+		domain="domain.tld"	(DOMAIN)
9
+		path="/path"	(PATH)
10
+		admin="john"	(USER)
11
+		language="fr"
12
+		is_public=1	(PUBLIC|public=1|private=0)
13
+		password="pass"
14
+		port="666"	(PORT)
15
+	; Checks
16
+		pkg_linter=1
17
+		setup_sub_dir=1
18
+		setup_root=1
19
+		setup_nourl=0
20
+		setup_private=1
21
+		setup_public=1
22
+		upgrade=1
23
+		upgrade=1	from_commit=CommitHash
24
+		backup_restore=1
25
+		multi_instance=1
26
+		incorrect_path=1
27
+		port_already_use=0
28
+		change_url=1
29
+;;; Levels
30
+	Level 1=auto
31
+	Level 2=auto
32
+	Level 3=auto
33
+# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
34
+# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
35
+	Level 4=0
36
+	Level 5=auto
37
+	Level 6=auto
38
+	Level 7=auto
39
+	Level 8=0
40
+	Level 9=0
41
+	Level 10=0
42
+;;; Options
43
+Email=
44
+Notification=none
45
+;;; Upgrade options
46
+	; commit=CommitHash
47
+		name=Name and date of the commit.
48
+		manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
49
+

+ 6
- 0
conf/app.src View File

@@ -0,0 +1,6 @@
1
+SOURCE_URL=url of app's source
2
+SOURCE_SUM=sha256 checksum
3
+SOURCE_SUM_PRG=sha256sum
4
+SOURCE_FORMAT=tar.gz
5
+SOURCE_IN_SUBDIR=true
6
+SOURCE_FILENAME=

+ 33
- 0
conf/nginx.conf View File

@@ -0,0 +1,33 @@
1
+#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
2
+location __PATH__/ {
3
+
4
+  # Path to source
5
+  alias __FINALPATH__/ ;
6
+
7
+  # Force usage of https
8
+  if ($scheme = http) {
9
+    rewrite ^ https://$server_name$request_uri? permanent;
10
+  }
11
+
12
+### Example PHP configuration (remove it if not used)
13
+  index index.php;
14
+
15
+  # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
16
+  #client_max_body_size 50M;
17
+
18
+  try_files $uri $uri/ index.php;
19
+  location ~ [^/]\.php(/|$) {
20
+    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
21
+    fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
22
+
23
+    fastcgi_index index.php;
24
+    include fastcgi_params;
25
+    fastcgi_param REMOTE_USER $remote_user;
26
+    fastcgi_param PATH_INFO $fastcgi_path_info;
27
+    fastcgi_param SCRIPT_FILENAME $request_filename;
28
+  }
29
+### End of PHP configuration part
30
+
31
+  # Include SSOWAT user panel.
32
+  include conf.d/yunohost_panel.conf.inc;
33
+}

+ 430
- 0
conf/php-fpm.conf View File

@@ -0,0 +1,430 @@
1
+; Start a new pool named 'www'.
2
+; the variable $pool can be used in any directive and will be replaced by the
3
+; pool name ('www' here)
4
+[__NAMETOCHANGE__]
5
+
6
+; Per pool prefix
7
+; It only applies on the following directives:
8
+; - 'access.log'
9
+; - 'slowlog'
10
+; - 'listen' (unixsocket)
11
+; - 'chroot'
12
+; - 'chdir'
13
+; - 'php_values'
14
+; - 'php_admin_values'
15
+; When not set, the global prefix (or /usr) applies instead.
16
+; Note: This directive can also be relative to the global prefix.
17
+; Default Value: none
18
+;prefix = /path/to/pools/$pool
19
+
20
+; Unix user/group of processes
21
+; Note: The user is mandatory. If the group is not set, the default user's group
22
+;       will be used.
23
+user = __USER__
24
+group = __USER__
25
+
26
+; The address on which to accept FastCGI requests.
27
+; Valid syntaxes are:
28
+;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
29
+;                            a specific port;
30
+;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
31
+;                            a specific port;
32
+;   'port'                 - to listen on a TCP socket to all addresses
33
+;                            (IPv6 and IPv4-mapped) on a specific port;
34
+;   '/path/to/unix/socket' - to listen on a unix socket.
35
+; Note: This value is mandatory.
36
+listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
37
+
38
+; Set listen(2) backlog.
39
+; Default Value: 511 (-1 on FreeBSD and OpenBSD)
40
+;listen.backlog = 511
41
+
42
+; Set permissions for unix socket, if one is used. In Linux, read/write
43
+; permissions must be set in order to allow connections from a web server. Many
44
+; BSD-derived systems allow connections regardless of permissions.
45
+; Default Values: user and group are set as the running user
46
+;                 mode is set to 0660
47
+listen.owner = www-data
48
+listen.group = www-data
49
+;listen.mode = 0660
50
+; When POSIX Access Control Lists are supported you can set them using
51
+; these options, value is a comma separated list of user/group names.
52
+; When set, listen.owner and listen.group are ignored
53
+;listen.acl_users =
54
+;listen.acl_groups =
55
+
56
+; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
57
+; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
58
+; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
59
+; must be separated by a comma. If this value is left blank, connections will be
60
+; accepted from any ip address.
61
+; Default Value: any
62
+;listen.allowed_clients = 127.0.0.1
63
+
64
+; Specify the nice(2) priority to apply to the pool processes (only if set)
65
+; The value can vary from -19 (highest priority) to 20 (lower priority)
66
+; Note: - It will only work if the FPM master process is launched as root
67
+;       - The pool processes will inherit the master process priority
68
+;         unless it specified otherwise
69
+; Default Value: no set
70
+; process.priority = -19
71
+
72
+; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
73
+; or group is differrent than the master process user. It allows to create process
74
+; core dump and ptrace the process for the pool user.
75
+; Default Value: no
76
+; process.dumpable = yes
77
+
78
+; Choose how the process manager will control the number of child processes.
79
+; Possible Values:
80
+;   static  - a fixed number (pm.max_children) of child processes;
81
+;   dynamic - the number of child processes are set dynamically based on the
82
+;             following directives. With this process management, there will be
83
+;             always at least 1 children.
84
+;             pm.max_children      - the maximum number of children that can
85
+;                                    be alive at the same time.
86
+;             pm.start_servers     - the number of children created on startup.
87
+;             pm.min_spare_servers - the minimum number of children in 'idle'
88
+;                                    state (waiting to process). If the number
89
+;                                    of 'idle' processes is less than this
90
+;                                    number then some children will be created.
91
+;             pm.max_spare_servers - the maximum number of children in 'idle'
92
+;                                    state (waiting to process). If the number
93
+;                                    of 'idle' processes is greater than this
94
+;                                    number then some children will be killed.
95
+;  ondemand - no children are created at startup. Children will be forked when
96
+;             new requests will connect. The following parameter are used:
97
+;             pm.max_children           - the maximum number of children that
98
+;                                         can be alive at the same time.
99
+;             pm.process_idle_timeout   - The number of seconds after which
100
+;                                         an idle process will be killed.
101
+; Note: This value is mandatory.
102
+pm = dynamic
103
+
104
+; The number of child processes to be created when pm is set to 'static' and the
105
+; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
106
+; This value sets the limit on the number of simultaneous requests that will be
107
+; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
108
+; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
109
+; CGI. The below defaults are based on a server without much resources. Don't
110
+; forget to tweak pm.* to fit your needs.
111
+; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
112
+; Note: This value is mandatory.
113
+pm.max_children = 5
114
+
115
+; The number of child processes created on startup.
116
+; Note: Used only when pm is set to 'dynamic'
117
+; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
118
+pm.start_servers = 2
119
+
120
+; The desired minimum number of idle server processes.
121
+; Note: Used only when pm is set to 'dynamic'
122
+; Note: Mandatory when pm is set to 'dynamic'
123
+pm.min_spare_servers = 1
124
+
125
+; The desired maximum number of idle server processes.
126
+; Note: Used only when pm is set to 'dynamic'
127
+; Note: Mandatory when pm is set to 'dynamic'
128
+pm.max_spare_servers = 3
129
+
130
+; The number of seconds after which an idle process will be killed.
131
+; Note: Used only when pm is set to 'ondemand'
132
+; Default Value: 10s
133
+;pm.process_idle_timeout = 10s;
134
+
135
+; The number of requests each child process should execute before respawning.
136
+; This can be useful to work around memory leaks in 3rd party libraries. For
137
+; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
138
+; Default Value: 0
139
+;pm.max_requests = 500
140
+
141
+; The URI to view the FPM status page. If this value is not set, no URI will be
142
+; recognized as a status page. It shows the following informations:
143
+;   pool                 - the name of the pool;
144
+;   process manager      - static, dynamic or ondemand;
145
+;   start time           - the date and time FPM has started;
146
+;   start since          - number of seconds since FPM has started;
147
+;   accepted conn        - the number of request accepted by the pool;
148
+;   listen queue         - the number of request in the queue of pending
149
+;                          connections (see backlog in listen(2));
150
+;   max listen queue     - the maximum number of requests in the queue
151
+;                          of pending connections since FPM has started;
152
+;   listen queue len     - the size of the socket queue of pending connections;
153
+;   idle processes       - the number of idle processes;
154
+;   active processes     - the number of active processes;
155
+;   total processes      - the number of idle + active processes;
156
+;   max active processes - the maximum number of active processes since FPM
157
+;                          has started;
158
+;   max children reached - number of times, the process limit has been reached,
159
+;                          when pm tries to start more children (works only for
160
+;                          pm 'dynamic' and 'ondemand');
161
+; Value are updated in real time.
162
+; Example output:
163
+;   pool:                 www
164
+;   process manager:      static
165
+;   start time:           01/Jul/2011:17:53:49 +0200
166
+;   start since:          62636
167
+;   accepted conn:        190460
168
+;   listen queue:         0
169
+;   max listen queue:     1
170
+;   listen queue len:     42
171
+;   idle processes:       4
172
+;   active processes:     11
173
+;   total processes:      15
174
+;   max active processes: 12
175
+;   max children reached: 0
176
+;
177
+; By default the status page output is formatted as text/plain. Passing either
178
+; 'html', 'xml' or 'json' in the query string will return the corresponding
179
+; output syntax. Example:
180
+;   http://www.foo.bar/status
181
+;   http://www.foo.bar/status?json
182
+;   http://www.foo.bar/status?html
183
+;   http://www.foo.bar/status?xml
184
+;
185
+; By default the status page only outputs short status. Passing 'full' in the
186
+; query string will also return status for each pool process.
187
+; Example:
188
+;   http://www.foo.bar/status?full
189
+;   http://www.foo.bar/status?json&full
190
+;   http://www.foo.bar/status?html&full
191
+;   http://www.foo.bar/status?xml&full
192
+; The Full status returns for each process:
193
+;   pid                  - the PID of the process;
194
+;   state                - the state of the process (Idle, Running, ...);
195
+;   start time           - the date and time the process has started;
196
+;   start since          - the number of seconds since the process has started;
197
+;   requests             - the number of requests the process has served;
198
+;   request duration     - the duration in µs of the requests;
199
+;   request method       - the request method (GET, POST, ...);
200
+;   request URI          - the request URI with the query string;
201
+;   content length       - the content length of the request (only with POST);
202
+;   user                 - the user (PHP_AUTH_USER) (or '-' if not set);
203
+;   script               - the main script called (or '-' if not set);
204
+;   last request cpu     - the %cpu the last request consumed
205
+;                          it's always 0 if the process is not in Idle state
206
+;                          because CPU calculation is done when the request
207
+;                          processing has terminated;
208
+;   last request memory  - the max amount of memory the last request consumed
209
+;                          it's always 0 if the process is not in Idle state
210
+;                          because memory calculation is done when the request
211
+;                          processing has terminated;
212
+; If the process is in Idle state, then informations are related to the
213
+; last request the process has served. Otherwise informations are related to
214
+; the current request being served.
215
+; Example output:
216
+;   ************************
217
+;   pid:                  31330
218
+;   state:                Running
219
+;   start time:           01/Jul/2011:17:53:49 +0200
220
+;   start since:          63087
221
+;   requests:             12808
222
+;   request duration:     1250261
223
+;   request method:       GET
224
+;   request URI:          /test_mem.php?N=10000
225
+;   content length:       0
226
+;   user:                 -
227
+;   script:               /home/fat/web/docs/php/test_mem.php
228
+;   last request cpu:     0.00
229
+;   last request memory:  0
230
+;
231
+; Note: There is a real-time FPM status monitoring sample web page available
232
+;       It's available in: /usr/share/php/7.0/fpm/status.html
233
+;
234
+; Note: The value must start with a leading slash (/). The value can be
235
+;       anything, but it may not be a good idea to use the .php extension or it
236
+;       may conflict with a real PHP file.
237
+; Default Value: not set
238
+;pm.status_path = /status
239
+
240
+; The ping URI to call the monitoring page of FPM. If this value is not set, no
241
+; URI will be recognized as a ping page. This could be used to test from outside
242
+; that FPM is alive and responding, or to
243
+; - create a graph of FPM availability (rrd or such);
244
+; - remove a server from a group if it is not responding (load balancing);
245
+; - trigger alerts for the operating team (24/7).
246
+; Note: The value must start with a leading slash (/). The value can be
247
+;       anything, but it may not be a good idea to use the .php extension or it
248
+;       may conflict with a real PHP file.
249
+; Default Value: not set
250
+;ping.path = /ping
251
+
252
+; This directive may be used to customize the response of a ping request. The
253
+; response is formatted as text/plain with a 200 response code.
254
+; Default Value: pong
255
+;ping.response = pong
256
+
257
+; The access log file
258
+; Default: not set
259
+;access.log = log/$pool.access.log
260
+
261
+; The access log format.
262
+; The following syntax is allowed
263
+;  %%: the '%' character
264
+;  %C: %CPU used by the request
265
+;      it can accept the following format:
266
+;      - %{user}C for user CPU only
267
+;      - %{system}C for system CPU only
268
+;      - %{total}C  for user + system CPU (default)
269
+;  %d: time taken to serve the request
270
+;      it can accept the following format:
271
+;      - %{seconds}d (default)
272
+;      - %{miliseconds}d
273
+;      - %{mili}d
274
+;      - %{microseconds}d
275
+;      - %{micro}d
276
+;  %e: an environment variable (same as $_ENV or $_SERVER)
277
+;      it must be associated with embraces to specify the name of the env
278
+;      variable. Some exemples:
279
+;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
280
+;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
281
+;  %f: script filename
282
+;  %l: content-length of the request (for POST request only)
283
+;  %m: request method
284
+;  %M: peak of memory allocated by PHP
285
+;      it can accept the following format:
286
+;      - %{bytes}M (default)
287
+;      - %{kilobytes}M
288
+;      - %{kilo}M
289
+;      - %{megabytes}M
290
+;      - %{mega}M
291
+;  %n: pool name
292
+;  %o: output header
293
+;      it must be associated with embraces to specify the name of the header:
294
+;      - %{Content-Type}o
295
+;      - %{X-Powered-By}o
296
+;      - %{Transfert-Encoding}o
297
+;      - ....
298
+;  %p: PID of the child that serviced the request
299
+;  %P: PID of the parent of the child that serviced the request
300
+;  %q: the query string
301
+;  %Q: the '?' character if query string exists
302
+;  %r: the request URI (without the query string, see %q and %Q)
303
+;  %R: remote IP address
304
+;  %s: status (response code)
305
+;  %t: server time the request was received
306
+;      it can accept a strftime(3) format:
307
+;      %d/%b/%Y:%H:%M:%S %z (default)
308
+;      The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
309
+;      e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
310
+;  %T: time the log has been written (the request has finished)
311
+;      it can accept a strftime(3) format:
312
+;      %d/%b/%Y:%H:%M:%S %z (default)
313
+;      The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
314
+;      e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
315
+;  %u: remote user
316
+;
317
+; Default: "%R - %u %t \"%m %r\" %s"
318
+;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
319
+
320
+; The log file for slow requests
321
+; Default Value: not set
322
+; Note: slowlog is mandatory if request_slowlog_timeout is set
323
+;slowlog = log/$pool.log.slow
324
+
325
+; The timeout for serving a single request after which a PHP backtrace will be
326
+; dumped to the 'slowlog' file. A value of '0s' means 'off'.
327
+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
328
+; Default Value: 0
329
+;request_slowlog_timeout = 0
330
+
331
+; The timeout for serving a single request after which the worker process will
332
+; be killed. This option should be used when the 'max_execution_time' ini option
333
+; does not stop script execution for some reason. A value of '0' means 'off'.
334
+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
335
+; Default Value: 0
336
+request_terminate_timeout = 1d
337
+
338
+; Set open file descriptor rlimit.
339
+; Default Value: system defined value
340
+;rlimit_files = 1024
341
+
342
+; Set max core size rlimit.
343
+; Possible Values: 'unlimited' or an integer greater or equal to 0
344
+; Default Value: system defined value
345
+;rlimit_core = 0
346
+
347
+; Chroot to this directory at the start. This value must be defined as an
348
+; absolute path. When this value is not set, chroot is not used.
349
+; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
350
+; of its subdirectories. If the pool prefix is not set, the global prefix
351
+; will be used instead.
352
+; Note: chrooting is a great security feature and should be used whenever
353
+;       possible. However, all PHP paths will be relative to the chroot
354
+;       (error_log, sessions.save_path, ...).
355
+; Default Value: not set
356
+;chroot =
357
+
358
+; Chdir to this directory at the start.
359
+; Note: relative path can be used.
360
+; Default Value: current directory or / when chroot
361
+chdir = __FINALPATH__
362
+
363
+; Redirect worker stdout and stderr into main error log. If not set, stdout and
364
+; stderr will be redirected to /dev/null according to FastCGI specs.
365
+; Note: on highloaded environement, this can cause some delay in the page
366
+; process time (several ms).
367
+; Default Value: no
368
+;catch_workers_output = yes
369
+
370
+; Clear environment in FPM workers
371
+; Prevents arbitrary environment variables from reaching FPM worker processes
372
+; by clearing the environment in workers before env vars specified in this
373
+; pool configuration are added.
374
+; Setting to "no" will make all environment variables available to PHP code
375
+; via getenv(), $_ENV and $_SERVER.
376
+; Default Value: yes
377
+;clear_env = no
378
+
379
+; Limits the extensions of the main script FPM will allow to parse. This can
380
+; prevent configuration mistakes on the web server side. You should only limit
381
+; FPM to .php extensions to prevent malicious users to use other extensions to
382
+; execute php code.
383
+; Note: set an empty value to allow all extensions.
384
+; Default Value: .php
385
+;security.limit_extensions = .php .php3 .php4 .php5 .php7
386
+
387
+; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
388
+; the current environment.
389
+; Default Value: clean env
390
+;env[HOSTNAME] = $HOSTNAME
391
+;env[PATH] = /usr/local/bin:/usr/bin:/bin
392
+;env[TMP] = /tmp
393
+;env[TMPDIR] = /tmp
394
+;env[TEMP] = /tmp
395
+
396
+; Additional php.ini defines, specific to this pool of workers. These settings
397
+; overwrite the values previously defined in the php.ini. The directives are the
398
+; same as the PHP SAPI:
399
+;   php_value/php_flag             - you can set classic ini defines which can
400
+;                                    be overwritten from PHP call 'ini_set'.
401
+;   php_admin_value/php_admin_flag - these directives won't be overwritten by
402
+;                                     PHP call 'ini_set'
403
+; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
404
+
405
+; Defining 'extension' will load the corresponding shared extension from
406
+; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
407
+; overwrite previously defined php.ini values, but will append the new value
408
+; instead.
409
+
410
+; Note: path INI options can be relative and will be expanded with the prefix
411
+; (pool, global or /usr)
412
+
413
+; Default Value: nothing is defined by default except the values in php.ini and
414
+;                specified at startup with the -d argument
415
+;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
416
+;php_flag[display_errors] = off
417
+;php_admin_value[error_log] = /var/log/fpm-php.www.log
418
+;php_admin_flag[log_errors] = on
419
+;php_admin_value[memory_limit] = 32M
420
+
421
+; Common values to change to increase file upload limit
422
+; php_admin_value[upload_max_filesize] = 50M
423
+; php_admin_value[post_max_size] = 50M
424
+; php_admin_flag[mail.add_x_header] = Off
425
+
426
+; Other common parameters
427
+; php_admin_value[max_execution_time] = 600
428
+; php_admin_value[max_input_time] = 300
429
+; php_admin_value[memory_limit] = 256M
430
+; php_admin_flag[short_open_tag] = On

+ 13
- 0
conf/systemd.service View File

@@ -0,0 +1,13 @@
1
+[Unit]
2
+Description=Small description of the service
3
+After=network.target
4
+
5
+[Service]
6
+Type=simple
7
+User=__APP__
8
+Group=__APP__
9
+WorkingDirectory=__FINALPATH__/
10
+ExecStart=__FINALPATH__/script >> /var/log/__APP__/__APP__.log 2>&1
11
+
12
+[Install]
13
+WantedBy=multi-user.target

+ 90
- 0
manifest.json View File

@@ -0,0 +1,90 @@
1
+{
2
+    "name": "YunoHost example app",
3
+    "id": "ynhexample",
4
+    "packaging_format": 1,
5
+    "description": {
6
+        "en": "Example package for YunoHost application.",
7
+        "fr": "Exemple de package d’application pour YunoHost."
8
+    },
9
+    "version": "1.0~ynh1",
10
+    "url": "https://example.com",
11
+    "license": "free",
12
+    "maintainer": {
13
+        "name": "John doe",
14
+        "email": "john.doe@example.com",
15
+        "url": "http://example.com"
16
+    },
17
+    "requirements": {
18
+        "yunohost": ">= 3.4"
19
+    },
20
+    "multi_instance": true,
21
+    "services": [
22
+        "nginx",
23
+        "php7.0-fpm",
24
+        "mysql"
25
+    ],
26
+    "arguments": {
27
+        "install" : [
28
+            {
29
+                "name": "domain",
30
+                "type": "domain",
31
+                "ask": {
32
+                    "en": "Choose a domain name for ynhexample",
33
+                    "fr": "Choisissez un nom de domaine pour ynhexample"
34
+                },
35
+                "example": "example.com"
36
+            },
37
+            {
38
+                "name": "path",
39
+                "type": "path",
40
+                "ask": {
41
+                    "en": "Choose a path for ynhexample",
42
+                    "fr": "Choisissez un chemin pour ynhexample"
43
+                },
44
+                "example": "/example",
45
+                "default": "/example"
46
+            },
47
+            {
48
+                "name": "admin",
49
+                "type": "user",
50
+                "ask": {
51
+                    "en": "Choose an admin user",
52
+                    "fr": "Choisissez l’administrateur"
53
+                },
54
+                "example": "johndoe"
55
+            },
56
+            {
57
+                "name": "is_public",
58
+                "type": "boolean",
59
+                "ask": {
60
+                    "en": "Is it a public application?",
61
+                    "fr": "Est-ce une application publique ?"
62
+                },
63
+                "default": true
64
+            },
65
+            {
66
+                "name": "language",
67
+                "type": "string",
68
+                "ask": {
69
+                    "en": "Choose the application language",
70
+                    "fr": "Choisissez la langue de l'application"
71
+                },
72
+                "choices": ["fr", "en"],
73
+                "default": "fr"
74
+            },
75
+            {
76
+                "name": "password",
77
+                "type": "password",
78
+                "ask": {
79
+                    "en": "Set the administrator password",
80
+                    "fr": "Définissez le mot de passe administrateur"
81
+                },
82
+                "help": {
83
+                    "en": "Use the help field to add an information for the admin about this question.",
84
+                    "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
85
+                },
86
+                "example": "Choose a password"
87
+            }
88
+        ]
89
+    }
90
+}

+ 20
- 0
scripts/_common.sh View File

@@ -0,0 +1,20 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# COMMON VARIABLES
5
+#=================================================
6
+
7
+# dependencies used by the app
8
+pkg_dependencies="deb1 deb2"
9
+
10
+#=================================================
11
+# PERSONAL HELPERS
12
+#=================================================
13
+
14
+#=================================================
15
+# EXPERIMENTAL HELPERS
16
+#=================================================
17
+
18
+#=================================================
19
+# FUTURE OFFICIAL HELPERS
20
+#=================================================

+ 91
- 0
scripts/backup View File

@@ -0,0 +1,91 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# GENERIC START
5
+#=================================================
6
+# IMPORT GENERIC HELPERS
7
+#=================================================
8
+
9
+#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
10
+source ../settings/scripts/_common.sh
11
+source /usr/share/yunohost/helpers
12
+
13
+#=================================================
14
+# MANAGE SCRIPT FAILURE
15
+#=================================================
16
+
17
+ynh_clean_setup () {
18
+	### Remove this function if there's nothing to clean before calling the remove script.
19
+	true
20
+}
21
+# Exit if an error occurs during the execution of the script
22
+ynh_abort_if_errors
23
+
24
+#=================================================
25
+# LOAD SETTINGS
26
+#=================================================
27
+ynh_print_info "Loading installation settings..."
28
+
29
+app=$YNH_APP_INSTANCE_NAME
30
+
31
+final_path=$(ynh_app_setting_get $app final_path)
32
+domain=$(ynh_app_setting_get $app domain)
33
+db_name=$(ynh_app_setting_get $app db_name)
34
+
35
+#=================================================
36
+# STANDARD BACKUP STEPS
37
+#=================================================
38
+# BACKUP THE APP MAIN DIR
39
+#=================================================
40
+ynh_print_info "Backing up the main app directory..."
41
+
42
+ynh_backup "$final_path"
43
+
44
+#=================================================
45
+# BACKUP THE NGINX CONFIGURATION
46
+#=================================================
47
+ynh_print_info "Backing up nginx web server configuration..."
48
+
49
+ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
50
+
51
+#=================================================
52
+# BACKUP THE PHP-FPM CONFIGURATION
53
+#=================================================
54
+ynh_print_info "Backing up php-fpm configuration..."
55
+
56
+ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
57
+
58
+#=================================================
59
+# BACKUP THE MYSQL DATABASE
60
+#=================================================
61
+ynh_print_info "Backing up the MySQL database..."
62
+
63
+ynh_mysql_dump_db "$db_name" > db.sql
64
+
65
+#=================================================
66
+# SPECIFIC BACKUP
67
+#=================================================
68
+# BACKUP LOGROTATE
69
+#=================================================
70
+ynh_print_info "Backing up logrotate configuration..."
71
+
72
+ynh_backup "/etc/logrotate.d/$app"
73
+
74
+#=================================================
75
+# BACKUP SYSTEMD
76
+#=================================================
77
+ynh_print_info "Backing up systemd configuration..."
78
+
79
+ynh_backup "/etc/systemd/system/$app.service"
80
+
81
+#=================================================
82
+# BACKUP A CRON FILE
83
+#=================================================
84
+
85
+ynh_backup "/etc/cron.d/$app"
86
+
87
+#=================================================
88
+# END OF SCRIPT
89
+#=================================================
90
+
91
+ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

+ 111
- 0
scripts/change_url View File

@@ -0,0 +1,111 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# GENERIC STARTING
5
+#=================================================
6
+# IMPORT GENERIC HELPERS
7
+#=================================================
8
+
9
+source _common.sh
10
+source /usr/share/yunohost/helpers
11
+
12
+#=================================================
13
+# RETRIEVE ARGUMENTS
14
+#=================================================
15
+
16
+old_domain=$YNH_APP_OLD_DOMAIN
17
+old_path=$YNH_APP_OLD_PATH
18
+
19
+new_domain=$YNH_APP_NEW_DOMAIN
20
+new_path=$YNH_APP_NEW_PATH
21
+
22
+app=$YNH_APP_INSTANCE_NAME
23
+
24
+#=================================================
25
+# LOAD SETTINGS
26
+#=================================================
27
+ynh_print_info "Loading installation settings..."
28
+
29
+# Needed for helper "ynh_add_nginx_config"
30
+final_path=$(ynh_app_setting_get $app final_path)
31
+
32
+# Add settings here as needed by your application
33
+#db_name=$(ynh_app_setting_get "$app" db_name)
34
+#db_pwd=$(ynh_app_setting_get $app db_pwd)
35
+
36
+#=================================================
37
+# CHECK THE SYNTAX OF THE PATHS
38
+#=================================================
39
+
40
+test -n "$old_path" || old_path="/"
41
+test -n "$new_path" || new_path="/"
42
+new_path=$(ynh_normalize_url_path $new_path)
43
+old_path=$(ynh_normalize_url_path $old_path)
44
+
45
+#=================================================
46
+# CHECK WHICH PARTS SHOULD BE CHANGED
47
+#=================================================
48
+
49
+change_domain=0
50
+if [ "$old_domain" != "$new_domain" ]
51
+then
52
+	change_domain=1
53
+fi
54
+
55
+change_path=0
56
+if [ "$old_path" != "$new_path" ]
57
+then
58
+	change_path=1
59
+fi
60
+
61
+#=================================================
62
+# STANDARD MODIFICATIONS
63
+#=================================================
64
+# MODIFY URL IN NGINX CONF
65
+#=================================================
66
+ynh_print_info "Updating nginx web server configuration..."
67
+
68
+nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
69
+
70
+# Change the path in the nginx config file
71
+if [ $change_path -eq 1 ]
72
+then
73
+	# Make a backup of the original nginx config file if modified
74
+	ynh_backup_if_checksum_is_different "$nginx_conf_path"
75
+	# Set global variables for nginx helper
76
+	domain="$old_domain"
77
+	path_url="$new_path"
78
+	# Create a dedicated nginx config
79
+	ynh_add_nginx_config
80
+fi
81
+
82
+# Change the domain for nginx
83
+if [ $change_domain -eq 1 ]
84
+then
85
+	# Delete file checksum for the old conf file location
86
+	ynh_delete_file_checksum "$nginx_conf_path"
87
+	mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
88
+	# Store file checksum for the new config file location
89
+	ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
90
+fi
91
+
92
+#=================================================
93
+# SPECIFIC MODIFICATIONS
94
+#=================================================
95
+# ...
96
+#=================================================
97
+
98
+#=================================================
99
+# GENERIC FINALISATION
100
+#=================================================
101
+# RELOAD NGINX
102
+#=================================================
103
+ynh_print_info "Reloading nginx web server..."
104
+
105
+systemctl reload nginx
106
+
107
+#=================================================
108
+# END OF SCRIPT
109
+#=================================================
110
+
111
+ynh_print_info "Change of URL completed for $app"

+ 318
- 0
scripts/install View File

@@ -0,0 +1,318 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# GENERIC START
5
+#=================================================
6
+# IMPORT GENERIC HELPERS
7
+#=================================================
8
+
9
+source _common.sh
10
+source /usr/share/yunohost/helpers
11
+
12
+#=================================================
13
+# MANAGE SCRIPT FAILURE
14
+#=================================================
15
+
16
+ynh_clean_setup () {
17
+	### Remove this function if there's nothing to clean before calling the remove script.
18
+	true
19
+}
20
+# Exit if an error occurs during the execution of the script
21
+ynh_abort_if_errors
22
+
23
+#=================================================
24
+# RETRIEVE ARGUMENTS FROM THE MANIFEST
25
+#=================================================
26
+
27
+domain=$YNH_APP_ARG_DOMAIN
28
+path_url=$YNH_APP_ARG_PATH
29
+admin=$YNH_APP_ARG_ADMIN
30
+is_public=$YNH_APP_ARG_IS_PUBLIC
31
+language=$YNH_APP_ARG_LANGUAGE
32
+password=$YNH_APP_ARG_PASSWORD
33
+
34
+### If it's a multi-instance app, meaning it can be installed several times independently
35
+### The id of the app as stated in the manifest is available as $YNH_APP_ID
36
+### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
37
+### The app instance name is available as $YNH_APP_INSTANCE_NAME
38
+###    - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
39
+###    - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
40
+###    - ynhexample__{N} for the subsequent installations, with N=3,4, ...
41
+### The app instance name is probably what interests you most, since this is
42
+### guaranteed to be unique. This is a good unique identifier to define installation path,
43
+### db names, ...
44
+app=$YNH_APP_INSTANCE_NAME
45
+
46
+#=================================================
47
+# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
48
+#=================================================
49
+ynh_print_info "Validating installation parameters..."
50
+
51
+### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
52
+### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
53
+final_path=/var/www/$app
54
+test ! -e "$final_path" || ynh_die "This path already contains a folder"
55
+
56
+# Normalize the url path syntax
57
+path_url=$(ynh_normalize_url_path $path_url)
58
+
59
+# Register (book) web path
60
+ynh_webpath_register $app $domain $path_url
61
+
62
+#=================================================
63
+# STORE SETTINGS FROM MANIFEST
64
+#=================================================
65
+ynh_print_info "Storing installation settings..."
66
+
67
+ynh_app_setting_set $app domain $domain
68
+ynh_app_setting_set $app path $path_url
69
+ynh_app_setting_set $app admin $admin
70
+ynh_app_setting_set $app is_public $is_public
71
+ynh_app_setting_set $app language $language
72
+
73
+#=================================================
74
+# STANDARD MODIFICATIONS
75
+#=================================================
76
+# FIND AND OPEN A PORT
77
+#=================================================
78
+ynh_print_info "Configuring firewall..."
79
+
80
+### Use these lines if you have to open a port for the application
81
+### `ynh_find_port` will find the first available port starting from the given port.
82
+### If you're not using these lines:
83
+###		- Remove the section "CLOSE A PORT" in the remove script
84
+
85
+# Find a free port
86
+port=$(ynh_find_port 8095)
87
+# Open this port
88
+ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
89
+ynh_app_setting_set $app port $port
90
+
91
+#=================================================
92
+# INSTALL DEPENDENCIES
93
+#=================================================
94
+ynh_print_info "Installing dependencies..."
95
+
96
+### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
97
+### Those deb packages will be installed as dependencies of this package.
98
+### If you're not using this helper:
99
+###		- Remove the section "REMOVE DEPENDENCIES" in the remove script
100
+###		- Remove the variable "pkg_dependencies" in _common.sh
101
+###		- As well as the section "REINSTALL DEPENDENCIES" in the restore script
102
+###		- And the section "UPGRADE DEPENDENCIES" in the upgrade script
103
+
104
+ynh_install_app_dependencies $pkg_dependencies
105
+
106
+#=================================================
107
+# CREATE A MYSQL DATABASE
108
+#=================================================
109
+ynh_print_info "Creating a MySQL database..."
110
+
111
+### Use these lines if you need a database for the application.
112
+### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
113
+### The password will be stored as 'mysqlpwd' into the app settings,
114
+### and will be available as $db_pwd
115
+### If you're not using these lines:
116
+###		- Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
117
+###		- Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
118
+###		- As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
119
+
120
+db_name=$(ynh_sanitize_dbid $app)
121
+ynh_app_setting_set $app db_name $db_name
122
+ynh_mysql_setup_db $db_name $db_name
123
+
124
+#=================================================
125
+# DOWNLOAD, CHECK AND UNPACK SOURCE
126
+#=================================================
127
+ynh_print_info "Setting up source files..."
128
+
129
+### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
130
+### downloaded from an upstream source, like a git repository.
131
+### `ynh_setup_source` use the file conf/app.src
132
+
133
+ynh_app_setting_set $app final_path $final_path
134
+# Download, check integrity, uncompress and patch the source from app.src
135
+ynh_setup_source "$final_path"
136
+
137
+#=================================================
138
+# NGINX CONFIGURATION
139
+#=================================================
140
+ynh_print_info "Configuring nginx web server..."
141
+
142
+### `ynh_add_nginx_config` will use the file conf/nginx.conf
143
+
144
+# Create a dedicated nginx config
145
+ynh_add_nginx_config
146
+
147
+#=================================================
148
+# CREATE DEDICATED USER
149
+#=================================================
150
+ynh_print_info "Configuring system user..."
151
+
152
+# Create a system user
153
+ynh_system_user_create $app
154
+
155
+#=================================================
156
+# PHP-FPM CONFIGURATION
157
+#=================================================
158
+ynh_print_info "Configuring php-fpm..."
159
+
160
+### `ynh_add_fpm_config` is used to set up a PHP config.
161
+### You can remove it if your app doesn't use PHP.
162
+### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
163
+### If you're not using these lines:
164
+###		- You can remove these files in conf/.
165
+###		- Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
166
+###		- Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
167
+###		- As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
168
+###		With the reload at the end of the script.
169
+###		- And the section "PHP-FPM CONFIGURATION" in the upgrade script
170
+
171
+# Create a dedicated php-fpm config
172
+ynh_add_fpm_config
173
+
174
+#=================================================
175
+# SPECIFIC SETUP
176
+#=================================================
177
+# ...
178
+#=================================================
179
+
180
+#=================================================
181
+# SETUP SYSTEMD
182
+#=================================================
183
+ynh_print_info "Configuring a systemd service..."
184
+
185
+### `ynh_systemd_config` is used to configure a systemd script for an app.
186
+### It can be used for apps that use sysvinit (with adaptation) or systemd.
187
+### Have a look at the app to be sure this app needs a systemd script.
188
+### `ynh_systemd_config` will use the file conf/systemd.service
189
+### If you're not using these lines:
190
+###		- You can remove those files in conf/.
191
+###		- Remove the section "BACKUP SYSTEMD" in the backup script
192
+###		- Remove also the section "STOP AND REMOVE SERVICE" in the remove script
193
+###		- As well as the section "RESTORE SYSTEMD" in the restore script
194
+###		- And the section "SETUP SYSTEMD" in the upgrade script
195
+
196
+# Create a dedicated systemd config
197
+ynh_add_systemd_config
198
+
199
+#=================================================
200
+# SETUP APPLICATION WITH CURL
201
+#=================================================
202
+
203
+### Use these lines only if the app installation needs to be finalized through
204
+### web forms. We generally don't want to ask the final user,
205
+### so we're going to use curl to automatically fill the fields and submit the
206
+### forms.
207
+
208
+# Set right permissions for curl install
209
+chown -R $app: $final_path
210
+
211
+# Set the app as temporarily public for curl call
212
+ynh_print_info "Configuring SSOwat..."
213
+ynh_app_setting_set $app skipped_uris "/"
214
+# Reload SSOwat config
215
+yunohost app ssowatconf
216
+
217
+# Reload Nginx
218
+systemctl reload nginx
219
+
220
+# Installation with curl
221
+ynh_print_info "Finalizing installation..."
222
+ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
223
+
224
+# Remove the public access
225
+if [ $is_public -eq 0 ]
226
+then
227
+	ynh_app_setting_delete $app skipped_uris
228
+fi
229
+
230
+#=================================================
231
+# MODIFY A CONFIG FILE
232
+#=================================================
233
+
234
+### `ynh_replace_string` is used to replace a string in a file.
235
+### (It's compatible with sed regular expressions syntax)
236
+
237
+ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
238
+
239
+#=================================================
240
+# STORE THE CONFIG FILE CHECKSUM
241
+#=================================================
242
+
243
+### `ynh_store_file_checksum` is used to store the checksum of a file.
244
+### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
245
+### you can make a backup of this file before modifying it again if the admin had modified it.
246
+
247
+# Calculate and store the config file checksum into the app settings
248
+ynh_store_file_checksum "$final_path/CONFIG_FILE"
249
+
250
+#=================================================
251
+# GENERIC FINALIZATION
252
+#=================================================
253
+# SECURE FILES AND DIRECTORIES
254
+#=================================================
255
+
256
+### For security reason, any app should set the permissions to root: before anything else.
257
+### Then, if write authorization is needed, any access should be given only to directories
258
+### that really need such authorization.
259
+
260
+# Set permissions to app files
261
+chown -R root: $final_path
262
+
263
+#=================================================
264
+# SETUP LOGROTATE
265
+#=================================================
266
+ynh_print_info "Configuring log rotation..."
267
+
268
+### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
269
+### Use this helper only if there is effectively a log file for this app.
270
+### If you're not using this helper:
271
+###		- Remove the section "BACKUP LOGROTATE" in the backup script
272
+###		- Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
273
+###		- As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
274
+###		- And the section "SETUP LOGROTATE" in the upgrade script
275
+
276
+# Use logrotate to manage application logfile(s)
277
+ynh_use_logrotate
278
+
279
+#=================================================
280
+# ADVERTISE SERVICE IN ADMIN PANEL
281
+#=================================================
282
+
283
+### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
284
+### You'll find the service in the 'services' section of YunoHost admin panel.
285
+### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
286
+### If you're not using these lines:
287
+###		- You can remove these files in conf/.
288
+###		- Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
289
+###		- As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
290
+
291
+yunohost service add $app --log "/var/log/$app/$app.log"
292
+# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
293
+#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log"
294
+
295
+#=================================================
296
+# SETUP SSOWAT
297
+#=================================================
298
+ynh_print_info "Configuring SSOwat..."
299
+
300
+# Make app public if necessary
301
+if [ $is_public -eq 1 ]
302
+then
303
+	# unprotected_uris allows SSO credentials to be passed anyway.
304
+	ynh_app_setting_set $app unprotected_uris "/"
305
+fi
306
+
307
+#=================================================
308
+# RELOAD NGINX
309
+#=================================================
310
+ynh_print_info "Reloading nginx web server..."
311
+
312
+systemctl reload nginx
313
+
314
+#=================================================
315
+# END OF SCRIPT
316
+#=================================================
317
+
318
+ynh_print_info "Installation of $app completed"

+ 133
- 0
scripts/remove View File

@@ -0,0 +1,133 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# GENERIC START
5
+#=================================================
6
+# IMPORT GENERIC HELPERS
7
+#=================================================
8
+
9
+source _common.sh
10
+source /usr/share/yunohost/helpers
11
+
12
+#=================================================
13
+# LOAD SETTINGS
14
+#=================================================
15
+ynh_print_info "Loading installation settings..."
16
+
17
+app=$YNH_APP_INSTANCE_NAME
18
+
19
+domain=$(ynh_app_setting_get $app domain)
20
+port=$(ynh_app_setting_get $app port)
21
+db_name=$(ynh_app_setting_get $app db_name)
22
+db_user=$db_name
23
+final_path=$(ynh_app_setting_get $app final_path)
24
+
25
+#=================================================
26
+# STANDARD REMOVE
27
+#=================================================
28
+# REMOVE SERVICE FROM ADMIN PANEL
29
+#=================================================
30
+
31
+# Remove a service from the admin panel, added by `yunohost service add`
32
+if yunohost service status $app >/dev/null 2>&1
33
+then
34
+	ynh_print_info "Removing $app service"
35
+	yunohost service remove $app
36
+fi
37
+
38
+#=================================================
39
+# STOP AND REMOVE SERVICE
40
+#=================================================
41
+ynh_print_info "Stopping and removing the systemd service"
42
+
43
+# Remove the dedicated systemd config
44
+ynh_remove_systemd_config
45
+
46
+#=================================================
47
+# REMOVE THE MYSQL DATABASE
48
+#=================================================
49
+ynh_print_info "Removing the MySQL database"
50
+
51
+# Remove a database if it exists, along with the associated user
52
+ynh_mysql_remove_db $db_user $db_name
53
+
54
+#=================================================
55
+# REMOVE DEPENDENCIES
56
+#=================================================
57
+ynh_print_info "Removing dependencies"
58
+
59
+# Remove metapackage and its dependencies
60
+ynh_remove_app_dependencies
61
+
62
+#=================================================
63
+# REMOVE APP MAIN DIR
64
+#=================================================
65
+ynh_print_info "Removing app main directory"
66
+
67
+# Remove the app directory securely
68
+ynh_secure_remove "$final_path"
69
+
70
+#=================================================
71
+# REMOVE NGINX CONFIGURATION
72
+#=================================================
73
+ynh_print_info "Removing nginx web server configuration"
74
+
75
+# Remove the dedicated nginx config
76
+ynh_remove_nginx_config
77
+
78
+#=================================================
79
+# REMOVE PHP-FPM CONFIGURATION
80
+#=================================================
81
+ynh_print_info "Removing php-fpm configuration"
82
+
83
+# Remove the dedicated php-fpm config
84
+ynh_remove_fpm_config
85
+
86
+#=================================================
87
+# REMOVE LOGROTATE CONFIGURATION
88
+#=================================================
89
+ynh_print_info "Removing logrotate configuration"
90
+
91
+# Remove the app-specific logrotate config
92
+ynh_remove_logrotate
93
+
94
+#=================================================
95
+# CLOSE A PORT
96
+#=================================================
97
+
98
+if yunohost firewall list | grep -q "\- $port$"
99
+then
100
+	ynh_print_info "Closing port $port"
101
+	ynh_exec_warn_less yunohost firewall disallow TCP $port
102
+fi
103
+
104
+#=================================================
105
+# SPECIFIC REMOVE
106
+#=================================================
107
+# REMOVE THE CRON FILE
108
+#=================================================
109
+
110
+# Remove a cron file
111
+ynh_secure_remove "/etc/cron.d/$app"
112
+
113
+# Remove a directory securely
114
+ynh_secure_remove "/etc/$app/"
115
+
116
+# Remove the log files
117
+ynh_secure_remove "/var/log/$app/"
118
+
119
+#=================================================
120
+# GENERIC FINALIZATION
121
+#=================================================
122
+# REMOVE DEDICATED USER
123
+#=================================================
124
+ynh_print_info "Removing the dedicated system user"
125
+
126
+# Delete a system user
127
+ynh_system_user_delete $app
128
+
129
+#=================================================
130
+# END OF SCRIPT
131
+#=================================================
132
+
133
+ynh_print_info "Removal of $app completed"

+ 141
- 0
scripts/restore View File

@@ -0,0 +1,141 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# GENERIC START
5
+#=================================================
6
+# IMPORT GENERIC HELPERS
7
+#=================================================
8
+
9
+#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
10
+source ../settings/scripts/_common.sh
11
+source /usr/share/yunohost/helpers
12
+
13
+#=================================================
14
+# MANAGE SCRIPT FAILURE
15
+#=================================================
16
+
17
+ynh_clean_setup () {
18
+	#### Remove this function if there's nothing to clean before calling the remove script.
19
+	true
20
+}
21
+# Exit if an error occurs during the execution of the script
22
+ynh_abort_if_errors
23
+
24
+#=================================================
25
+# LOAD SETTINGS
26
+#=================================================
27
+ynh_print_info "Loading settings..."
28
+
29
+app=$YNH_APP_INSTANCE_NAME
30
+
31
+domain=$(ynh_app_setting_get $app domain)
32
+path_url=$(ynh_app_setting_get $app path)
33
+final_path=$(ynh_app_setting_get $app final_path)
34
+db_name=$(ynh_app_setting_get $app db_name)
35
+
36
+#=================================================
37
+# CHECK IF THE APP CAN BE RESTORED
38
+#=================================================
39
+ynh_print_info "Validating restoration parameters..."
40
+
41
+ynh_webpath_available $domain $path_url \
42
+	|| ynh_die "Path not available: ${domain}${path_url}"
43
+test ! -d $final_path \
44
+	|| ynh_die "There is already a directory: $final_path "
45
+
46
+#=================================================
47
+# STANDARD RESTORATION STEPS
48
+#=================================================
49
+# RESTORE THE NGINX CONFIGURATION
50
+#=================================================
51
+
52
+ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
53
+
54
+#=================================================
55
+# RESTORE THE APP MAIN DIR
56
+#=================================================
57
+ynh_print_info "Restoring the app main directory..."
58
+
59
+ynh_restore_file "$final_path"
60
+
61
+#=================================================
62
+# RECREATE THE DEDICATED USER
63
+#=================================================
64
+ynh_print_info "Recreating the dedicated system user..."
65
+
66
+# Create the dedicated user (if not existing)
67
+ynh_system_user_create $app
68
+
69
+#=================================================
70
+# RESTORE USER RIGHTS
71
+#=================================================
72
+
73
+# Restore permissions on app files
74
+chown -R root: $final_path
75
+
76
+#=================================================
77
+# RESTORE THE PHP-FPM CONFIGURATION
78
+#=================================================
79
+
80
+ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
81
+
82
+#=================================================
83
+# SPECIFIC RESTORATION
84
+#=================================================
85
+# REINSTALL DEPENDENCIES
86
+#=================================================
87
+ynh_print_info "Reinstalling dependencies..."
88
+
89
+# Define and install dependencies
90
+ynh_install_app_dependencies $pkg_dependencies
91
+
92
+#=================================================
93
+# RESTORE THE MYSQL DATABASE
94
+#=================================================
95
+ynh_print_info "Restoring the MySQL database..."
96
+
97
+db_pwd=$(ynh_app_setting_get $app mysqlpwd)
98
+ynh_mysql_setup_db $db_name $db_name $db_pwd
99
+ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
100
+
101
+#=================================================
102
+# RESTORE SYSTEMD
103
+#=================================================
104
+ynh_print_info "Restoring the systemd configuration..."
105
+
106
+ynh_restore_file "/etc/systemd/system/$app.service"
107
+systemctl enable $app.service
108
+
109
+#=================================================
110
+# ADVERTISE SERVICE IN ADMIN PANEL
111
+#=================================================
112
+
113
+yunohost service add $app --log "/var/log/$app/$app.log"
114
+
115
+#=================================================
116
+# RESTORE THE CRON FILE
117
+#=================================================
118
+
119
+ynh_restore_file "/etc/cron.d/$app"
120
+
121
+#=================================================
122
+# RESTORE THE LOGROTATE CONFIGURATION
123
+#=================================================
124
+
125
+ynh_restore_file "/etc/logrotate.d/$app"
126
+
127
+#=================================================
128
+# GENERIC FINALIZATION
129
+#=================================================
130
+# RELOAD NGINX AND PHP-FPM
131
+#=================================================
132
+ynh_print_info "Reloading nginx web server and php-fpm..."
133
+
134
+systemctl reload php7.0-fpm
135
+systemctl reload nginx
136
+
137
+#=================================================
138
+# END OF SCRIPT
139
+#=================================================
140
+
141
+ynh_print_info "Restoration completed for $app"

+ 175
- 0
scripts/upgrade View File

@@ -0,0 +1,175 @@
1
+#!/bin/bash
2
+
3
+#=================================================
4
+# GENERIC START
5
+#=================================================
6
+# IMPORT GENERIC HELPERS
7
+#=================================================
8
+
9
+source _common.sh
10
+source /usr/share/yunohost/helpers
11
+
12
+#=================================================
13
+# LOAD SETTINGS
14
+#=================================================
15
+ynh_print_info "Loading installation settings..."
16
+
17
+app=$YNH_APP_INSTANCE_NAME
18
+
19
+domain=$(ynh_app_setting_get $app domain)
20
+path_url=$(ynh_app_setting_get $app path)
21
+admin=$(ynh_app_setting_get $app admin)
22
+is_public=$(ynh_app_setting_get $app is_public)
23
+final_path=$(ynh_app_setting_get $app final_path)
24
+language=$(ynh_app_setting_get $app language)
25
+db_name=$(ynh_app_setting_get $app db_name)
26
+
27
+#=================================================
28
+# ENSURE DOWNWARD COMPATIBILITY
29
+#=================================================
30
+ynh_print_info "Ensuring downward compatibility..."
31
+
32
+# Fix is_public as a boolean value
33
+if [ "$is_public" = "Yes" ]; then
34
+	ynh_app_setting_set $app is_public 1
35
+	is_public=1
36
+elif [ "$is_public" = "No" ]; then
37
+	ynh_app_setting_set $app is_public 0
38
+	is_public=0
39
+fi
40
+
41
+# If db_name doesn't exist, create it
42
+if [ -z $db_name ]; then
43
+	db_name=$(ynh_sanitize_dbid $app)
44
+	ynh_app_setting_set $app db_name $db_name
45
+fi
46
+
47
+# If final_path doesn't exist, create it
48
+if [ -z $final_path ]; then
49
+	final_path=/var/www/$app
50
+	ynh_app_setting_set $app final_path $final_path
51
+fi
52
+
53
+#=================================================
54
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
55
+#=================================================
56
+ynh_print_info "Backing up the app before upgrading (may take a while)..."
57
+
58
+# Backup the current version of the app
59
+ynh_backup_before_upgrade
60
+ynh_clean_setup () {
61
+	# restore it if the upgrade fails
62
+	ynh_restore_upgradebackup
63
+}
64
+# Exit if an error occurs during the execution of the script
65
+ynh_abort_if_errors
66
+
67
+#=================================================
68
+# CHECK THE PATH
69
+#=================================================
70
+
71
+# Normalize the URL path syntax
72
+path_url=$(ynh_normalize_url_path $path_url)
73
+
74
+#=================================================
75
+# STANDARD UPGRADE STEPS
76
+#=================================================
77
+# DOWNLOAD, CHECK AND UNPACK SOURCE
78
+#=================================================
79
+ynh_print_info "Upgrading source files..."
80
+
81
+# Download, check integrity, uncompress and patch the source from app.src
82
+ynh_setup_source "$final_path"
83
+
84
+#=================================================
85
+# NGINX CONFIGURATION
86
+#=================================================
87
+ynh_print_info "Upgrading nginx web server configuration..."
88
+
89
+# Create a dedicated nginx config
90
+ynh_add_nginx_config
91
+
92
+#=================================================
93
+# UPGRADE DEPENDENCIES
94
+#=================================================
95
+ynh_print_info "Upgrading dependencies..."
96
+
97
+ynh_install_app_dependencies $pkg_dependencies
98
+
99
+#=================================================
100
+# CREATE DEDICATED USER
101
+#=================================================
102
+ynh_print_info "Making sure dedicated system user exists..."
103
+
104
+# Create a dedicated user (if not existing)
105
+ynh_system_user_create $app
106
+
107
+#=================================================
108
+# PHP-FPM CONFIGURATION
109
+#=================================================
110
+ynh_print_info "Upgrading php-fpm configuration..."
111
+
112
+# Create a dedicated php-fpm config
113
+ynh_add_fpm_config
114
+
115
+#=================================================
116
+# SPECIFIC UPGRADE
117
+#=================================================
118
+# ...
119
+#=================================================
120
+
121
+### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
122
+### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
123
+ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
124
+# Recalculate and store the checksum of the file for the next upgrade.
125
+ynh_store_file_checksum "$final_path/CONFIG_FILE"
126
+
127
+#=================================================
128
+# SETUP LOGROTATE
129
+#=================================================
130
+ynh_print_info "Upgrading logrotate configuration..."
131
+
132
+# Use logrotate to manage app-specific logfile(s)
133
+ynh_use_logrotate --non-append
134
+
135
+#=================================================
136
+# SETUP SYSTEMD
137
+#=================================================
138
+ynh_print_info "Upgrading systemd configuration..."
139
+
140
+# Create a dedicated systemd config
141
+ynh_add_systemd_config
142
+
143
+#=================================================
144
+# GENERIC FINALIZATION
145
+#=================================================
146
+# SECURE FILES AND DIRECTORIES
147
+#=================================================
148
+
149
+# Set permissions on app files
150
+chown -R root: $final_path
151
+
152
+#=================================================
153
+# SETUP SSOWAT
154
+#=================================================
155
+ynh_print_info "Upgrading SSOwat configuration..."
156
+
157
+# Make app public if necessary
158
+if [ $is_public -eq 1 ]
159
+then
160
+	# unprotected_uris allows SSO credentials to be passed anyway
161
+	ynh_app_setting_set $app unprotected_uris "/"
162
+fi
163
+
164
+#=================================================
165
+# RELOAD NGINX
166
+#=================================================
167
+ynh_print_info "Reloading nginx web server..."
168
+
169
+systemctl reload nginx
170
+
171
+#=================================================
172
+# END OF SCRIPT
173
+#=================================================
174
+
175
+ynh_print_info "Upgrade of $app completed"

+ 2
- 0
sources/extra_files/app/.gitignore View File

@@ -0,0 +1,2 @@
1
+*~
2
+*.sw[op]

+ 2
- 0
sources/patches/.gitignore View File

@@ -0,0 +1,2 @@
1
+*~
2
+*.sw[op]

Loading…
Cancel
Save