mirror of
https://github.com/YunoHost-Apps/zabbix_ynh.git
synced 2024-09-03 20:36:14 +02:00
Merge branch 'testing' of https://github.com/YunoHost-Apps/zabbix_ynh into testing
This commit is contained in:
commit
09c93d36d5
20 changed files with 951 additions and 789 deletions
|
@ -14,9 +14,9 @@ global \$DB, \$HISTORY;
|
|||
\$DB['TYPE'] = 'MYSQL';
|
||||
\$DB['SERVER'] = 'localhost';
|
||||
\$DB['PORT'] = '0';
|
||||
\$DB['DATABASE'] = '"$(yunohost app setting zabbix db_name)"';
|
||||
\$DB['USER'] = '"$(yunohost app setting zabbix db_user)"';
|
||||
\$DB['PASSWORD'] = '"$(yunohost app setting zabbix mysqlpwd)"';
|
||||
\$DB['DATABASE'] = '__DB_NAME__';
|
||||
\$DB['USER'] = '__DB_USER__';
|
||||
\$DB['PASSWORD'] = '__DB_PWD__';
|
||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||
\$DB['SCHEMA'] = '';
|
||||
|
|
@ -9,7 +9,6 @@ location __PATH__/ {
|
|||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
### Example PHP configuration (remove it if not used)
|
||||
index index_http.php;
|
||||
|
||||
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
|
||||
|
@ -18,7 +17,7 @@ location __PATH__/ {
|
|||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php7.3-fpm-__NAME__.sock;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
|
@ -26,7 +25,6 @@ location __PATH__/ {
|
|||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
### End of PHP configuration part
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
|
|
@ -1,20 +1,434 @@
|
|||
; Start a new pool named 'www'.
|
||||
; the variable $pool can be used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[__NAMETOCHANGE__]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
; - 'access.log'
|
||||
; - 'slowlog'
|
||||
; - 'listen' (unixsocket)
|
||||
; - 'chroot'
|
||||
; - 'chdir'
|
||||
; - 'php_values'
|
||||
; - 'php_admin_values'
|
||||
; When not set, the global prefix (or /usr) applies instead.
|
||||
; Note: This directive can also be relative to the global prefix.
|
||||
; Default Value: none
|
||||
;prefix = /path/to/pools/$pool
|
||||
|
||||
; Unix user/group of processes
|
||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||
; will be used.
|
||||
user = www-data
|
||||
group = www-data
|
||||
listen = /var/run/php/php7.3-fpm-__NAMETOCHANGE__.sock
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
;listen.backlog = 511
|
||||
|
||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||
; permissions must be set in order to allow connections from a web server. Many
|
||||
; BSD-derived systems allow connections regardless of permissions.
|
||||
; Default Values: user and group are set as the running user
|
||||
; mode is set to 0660
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
;listen.mode = 0660
|
||||
; When POSIX Access Control Lists are supported you can set them using
|
||||
; these options, value is a comma separated list of user/group names.
|
||||
; When set, listen.owner and listen.group are ignored
|
||||
;listen.acl_users =
|
||||
;listen.acl_groups =
|
||||
|
||||
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||
; must be separated by a comma. If this value is left blank, connections will be
|
||||
; accepted from any ip address.
|
||||
; Default Value: any
|
||||
;listen.allowed_clients = 127.0.0.1
|
||||
|
||||
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||
; Note: - It will only work if the FPM master process is launched as root
|
||||
; - The pool processes will inherit the master process priority
|
||||
; unless it specified otherwise
|
||||
; Default Value: no set
|
||||
; process.priority = -19
|
||||
|
||||
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
|
||||
; or group is differrent than the master process user. It allows to create process
|
||||
; core dump and ptrace the process for the pool user.
|
||||
; Default Value: no
|
||||
; process.dumpable = yes
|
||||
|
||||
; Choose how the process manager will control the number of child processes.
|
||||
; Possible Values:
|
||||
; static - a fixed number (pm.max_children) of child processes;
|
||||
; dynamic - the number of child processes are set dynamically based on the
|
||||
; following directives. With this process management, there will be
|
||||
; always at least 1 children.
|
||||
; pm.max_children - the maximum number of children that can
|
||||
; be alive at the same time.
|
||||
; pm.start_servers - the number of children created on startup.
|
||||
; pm.min_spare_servers - the minimum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is less than this
|
||||
; number then some children will be created.
|
||||
; pm.max_spare_servers - the maximum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is greater than this
|
||||
; number then some children will be killed.
|
||||
; ondemand - no children are created at startup. Children will be forked when
|
||||
; new requests will connect. The following parameter are used:
|
||||
; pm.max_children - the maximum number of children that
|
||||
; can be alive at the same time.
|
||||
; pm.process_idle_timeout - The number of seconds after which
|
||||
; an idle process will be killed.
|
||||
; Note: This value is mandatory.
|
||||
pm = dynamic
|
||||
|
||||
; The number of child processes to be created when pm is set to 'static' and the
|
||||
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||
; This value sets the limit on the number of simultaneous requests that will be
|
||||
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||
; CGI. The below defaults are based on a server without much resources. Don't
|
||||
; forget to tweak pm.* to fit your needs.
|
||||
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||
; Note: This value is mandatory.
|
||||
pm.max_children = 10
|
||||
|
||||
; The number of child processes created on startup.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||
pm.start_servers = 2
|
||||
|
||||
; The desired minimum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.min_spare_servers = 1
|
||||
|
||||
; The desired maximum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
; The number of seconds after which an idle process will be killed.
|
||||
; Note: Used only when pm is set to 'ondemand'
|
||||
; Default Value: 10s
|
||||
;pm.process_idle_timeout = 10s;
|
||||
|
||||
; The number of requests each child process should execute before respawning.
|
||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||
; Default Value: 0
|
||||
pm.max_requests = 500
|
||||
|
||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||
; recognized as a status page. It shows the following informations:
|
||||
; pool - the name of the pool;
|
||||
; process manager - static, dynamic or ondemand;
|
||||
; start time - the date and time FPM has started;
|
||||
; start since - number of seconds since FPM has started;
|
||||
; accepted conn - the number of request accepted by the pool;
|
||||
; listen queue - the number of request in the queue of pending
|
||||
; connections (see backlog in listen(2));
|
||||
; max listen queue - the maximum number of requests in the queue
|
||||
; of pending connections since FPM has started;
|
||||
; listen queue len - the size of the socket queue of pending connections;
|
||||
; idle processes - the number of idle processes;
|
||||
; active processes - the number of active processes;
|
||||
; total processes - the number of idle + active processes;
|
||||
; max active processes - the maximum number of active processes since FPM
|
||||
; has started;
|
||||
; max children reached - number of times, the process limit has been reached,
|
||||
; when pm tries to start more children (works only for
|
||||
; pm 'dynamic' and 'ondemand');
|
||||
; Value are updated in real time.
|
||||
; Example output:
|
||||
; pool: www
|
||||
; process manager: static
|
||||
; start time: 01/Jul/2011:17:53:49 +0200
|
||||
; start since: 62636
|
||||
; accepted conn: 190460
|
||||
; listen queue: 0
|
||||
; max listen queue: 1
|
||||
; listen queue len: 42
|
||||
; idle processes: 4
|
||||
; active processes: 11
|
||||
; total processes: 15
|
||||
; max active processes: 12
|
||||
; max children reached: 0
|
||||
;
|
||||
; By default the status page output is formatted as text/plain. Passing either
|
||||
; 'html', 'xml' or 'json' in the query string will return the corresponding
|
||||
; output syntax. Example:
|
||||
; http://www.foo.bar/status
|
||||
; http://www.foo.bar/status?json
|
||||
; http://www.foo.bar/status?html
|
||||
; http://www.foo.bar/status?xml
|
||||
;
|
||||
; By default the status page only outputs short status. Passing 'full' in the
|
||||
; query string will also return status for each pool process.
|
||||
; Example:
|
||||
; http://www.foo.bar/status?full
|
||||
; http://www.foo.bar/status?json&full
|
||||
; http://www.foo.bar/status?html&full
|
||||
; http://www.foo.bar/status?xml&full
|
||||
; The Full status returns for each process:
|
||||
; pid - the PID of the process;
|
||||
; state - the state of the process (Idle, Running, ...);
|
||||
; start time - the date and time the process has started;
|
||||
; start since - the number of seconds since the process has started;
|
||||
; requests - the number of requests the process has served;
|
||||
; request duration - the duration in µs of the requests;
|
||||
; request method - the request method (GET, POST, ...);
|
||||
; request URI - the request URI with the query string;
|
||||
; content length - the content length of the request (only with POST);
|
||||
; user - the user (PHP_AUTH_USER) (or '-' if not set);
|
||||
; script - the main script called (or '-' if not set);
|
||||
; last request cpu - the %cpu the last request consumed
|
||||
; it's always 0 if the process is not in Idle state
|
||||
; because CPU calculation is done when the request
|
||||
; processing has terminated;
|
||||
; last request memory - the max amount of memory the last request consumed
|
||||
; it's always 0 if the process is not in Idle state
|
||||
; because memory calculation is done when the request
|
||||
; processing has terminated;
|
||||
; If the process is in Idle state, then informations are related to the
|
||||
; last request the process has served. Otherwise informations are related to
|
||||
; the current request being served.
|
||||
; Example output:
|
||||
; ************************
|
||||
; pid: 31330
|
||||
; state: Running
|
||||
; start time: 01/Jul/2011:17:53:49 +0200
|
||||
; start since: 63087
|
||||
; requests: 12808
|
||||
; request duration: 1250261
|
||||
; request method: GET
|
||||
; request URI: /test_mem.php?N=10000
|
||||
; content length: 0
|
||||
; user: -
|
||||
; script: /home/fat/web/docs/php/test_mem.php
|
||||
; last request cpu: 0.00
|
||||
; last request memory: 0
|
||||
;
|
||||
; Note: There is a real-time FPM status monitoring sample web page available
|
||||
; It's available in: /usr/share/php/7.0/fpm/status.html
|
||||
;
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
; - create a graph of FPM availability (rrd or such);
|
||||
; - remove a server from a group if it is not responding (load balancing);
|
||||
; - trigger alerts for the operating team (24/7).
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;ping.path = /ping
|
||||
|
||||
; This directive may be used to customize the response of a ping request. The
|
||||
; response is formatted as text/plain with a 200 response code.
|
||||
; Default Value: pong
|
||||
;ping.response = pong
|
||||
|
||||
; The access log file
|
||||
; Default: not set
|
||||
;access.log = log/$pool.access.log
|
||||
|
||||
; The access log format.
|
||||
; The following syntax is allowed
|
||||
; %%: the '%' character
|
||||
; %C: %CPU used by the request
|
||||
; it can accept the following format:
|
||||
; - %{user}C for user CPU only
|
||||
; - %{system}C for system CPU only
|
||||
; - %{total}C for user + system CPU (default)
|
||||
; %d: time taken to serve the request
|
||||
; it can accept the following format:
|
||||
; - %{seconds}d (default)
|
||||
; - %{miliseconds}d
|
||||
; - %{mili}d
|
||||
; - %{microseconds}d
|
||||
; - %{micro}d
|
||||
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||
; it must be associated with embraces to specify the name of the env
|
||||
; variable. Some exemples:
|
||||
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||
; %f: script filename
|
||||
; %l: content-length of the request (for POST request only)
|
||||
; %m: request method
|
||||
; %M: peak of memory allocated by PHP
|
||||
; it can accept the following format:
|
||||
; - %{bytes}M (default)
|
||||
; - %{kilobytes}M
|
||||
; - %{kilo}M
|
||||
; - %{megabytes}M
|
||||
; - %{mega}M
|
||||
; %n: pool name
|
||||
; %o: output header
|
||||
; it must be associated with embraces to specify the name of the header:
|
||||
; - %{Content-Type}o
|
||||
; - %{X-Powered-By}o
|
||||
; - %{Transfert-Encoding}o
|
||||
; - ....
|
||||
; %p: PID of the child that serviced the request
|
||||
; %P: PID of the parent of the child that serviced the request
|
||||
; %q: the query string
|
||||
; %Q: the '?' character if query string exists
|
||||
; %r: the request URI (without the query string, see %q and %Q)
|
||||
; %R: remote IP address
|
||||
; %s: status (response code)
|
||||
; %t: server time the request was received
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %T: time the log has been written (the request has finished)
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %u: remote user
|
||||
;
|
||||
; Default: "%R - %u %t \"%m %r\" %s"
|
||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_slowlog_timeout = 5s
|
||||
|
||||
; The timeout for serving a single request after which the worker process will
|
||||
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_terminate_timeout = 1d
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
;rlimit_files = 1024
|
||||
|
||||
; Set max core size rlimit.
|
||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||
; Default Value: system defined value
|
||||
;rlimit_core = 0
|
||||
|
||||
; Chroot to this directory at the start. This value must be defined as an
|
||||
; absolute path. When this value is not set, chroot is not used.
|
||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||
; will be used instead.
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; possible. However, all PHP paths will be relative to the chroot
|
||||
; (error_log, sessions.save_path, ...).
|
||||
; Default Value: not set
|
||||
;chroot =
|
||||
|
||||
; Chdir to this directory at the start.
|
||||
; Note: relative path can be used.
|
||||
; Default Value: current directory or / when chroot
|
||||
chdir = __FINALPATH__
|
||||
|
||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
; process time (several ms).
|
||||
; Default Value: no
|
||||
catch_workers_output = yes
|
||||
|
||||
; Clear environment in FPM workers
|
||||
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||
; by clearing the environment in workers before env vars specified in this
|
||||
; pool configuration are added.
|
||||
; Setting to "no" will make all environment variables available to PHP code
|
||||
; via getenv(), $_ENV and $_SERVER.
|
||||
; Default Value: yes
|
||||
;clear_env = no
|
||||
|
||||
; Limits the extensions of the main script FPM will allow to parse. This can
|
||||
; prevent configuration mistakes on the web server side. You should only limit
|
||||
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||
; execute php code.
|
||||
; Note: set an empty value to allow all extensions.
|
||||
; Default Value: .php
|
||||
;security.limit_extensions = .php .php3 .php4 .php5 .php7
|
||||
|
||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
;env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
;env[TMP] = /tmp
|
||||
;env[TMPDIR] = /tmp
|
||||
;env[TEMP] = /tmp
|
||||
|
||||
; Additional php.ini defines, specific to this pool of workers. These settings
|
||||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
||||
; Defining 'extension' will load the corresponding shared extension from
|
||||
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
|
||||
; overwrite previously defined php.ini values, but will append the new value
|
||||
; instead.
|
||||
|
||||
; Note: path INI options can be relative and will be expanded with the prefix
|
||||
; (pool, global or /usr)
|
||||
|
||||
; Default Value: nothing is defined by default except the values in php.ini and
|
||||
; specified at startup with the -d argument
|
||||
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
|
||||
;php_flag[display_errors] = off
|
||||
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
||||
|
||||
; Common values to change to increase file upload limit
|
||||
; php_admin_value[upload_max_filesize] = 50M
|
||||
; php_admin_value[post_max_size] = 50M
|
||||
; php_admin_flag[mail.add_x_header] = Off
|
||||
|
||||
; Other common parameters
|
||||
; php_admin_value[max_execution_time] = 600
|
||||
; php_admin_value[max_input_time] = 300
|
||||
; php_admin_value[memory_limit] = 256M
|
||||
; php_admin_flag[short_open_tag] = On
|
||||
|
||||
php_value[post_max_size] = 16M
|
||||
php_value[max_execution_time] = 300
|
||||
php_value[max_input_time] = 300
|
||||
|
|
|
@ -5,9 +5,9 @@ global $DB;
|
|||
$DB['TYPE'] = 'MYSQL';
|
||||
$DB['SERVER'] = 'localhost';
|
||||
$DB['PORT'] = '0';
|
||||
$DB['DATABASE'] = 'db_name';
|
||||
$DB['USER'] = 'db_user';
|
||||
$DB['PASSWORD'] = 'db_pwd';
|
||||
$DB['DATABASE'] = '__DB_NAME__';
|
||||
$DB['USER'] = '__DB_USER__';
|
||||
$DB['PASSWORD'] = '__DB_PWD__';
|
||||
|
||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||
$DB['SCHEMA'] = '';
|
|
@ -11,12 +11,6 @@ db_user=$(ynh_app_setting_get $app db_user)
|
|||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
language=$(ynh_app_setting_set $app language)
|
||||
|
||||
if [ "$language" == "fr" ];then
|
||||
lang="fr_FR"
|
||||
else
|
||||
lang="en_GB"
|
||||
fi
|
||||
|
||||
lastid=$(mysql -u$db_user -p$db_pwd $db_name -NB -e "select userid from users order by userid desc limit 1")
|
||||
lastid=$((lastid+1))
|
||||
mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ("$lastid",'"$user"', '"$name"', '"$surname"', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '"$lang"', '30s', 1, 'default', 0, '', 0, 50);"
|
||||
mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ("$lastid",'"$user"', '"$name"', '"$surname"', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '"$language"', '30s', 1, 'default', 0, '', 0, 50);"
|
||||
|
|
|
@ -15,67 +15,46 @@
|
|||
"url": "http://www.librement-votre.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.8.1"
|
||||
"yunohost": ">= 4.1.3"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx",
|
||||
"mysql",
|
||||
"php7.0-fpm",
|
||||
"snmpd"
|
||||
"php7.3-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for Zabbix",
|
||||
"fr": "Choisissez un nom de domaine pour Zabbix"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Zabbix",
|
||||
"fr": "Choisissez un chemin pour Zabbix"
|
||||
},
|
||||
"example": "/zabbix",
|
||||
"default": "/zabbix"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose an admin user",
|
||||
"fr": "Choisissez l’administrateur"
|
||||
},
|
||||
"example": "mickael"
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public application?",
|
||||
"fr": "Est-ce une application publique ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "A public app doesn't need SSO auth : the auth page is opened for everyone",
|
||||
"fr": "Une application publique ne nécessite pas une authentification SSO : sa page d'authentication est ouverte au monde entier"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["fr", "en"],
|
||||
"default": "en"
|
||||
"choices": ["fr_FR", "en_GB"],
|
||||
"default": "en_GB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -4,7 +4,16 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
pkg_dependencies="libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.3 php7.3-bcmath ttf-dejavu-core php7.3-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq zabbix-server-mysql zabbix-agent zabbix-frontend-php"
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 ttf-dejavu-core patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq zabbix-server-mysql zabbix-agent zabbix-frontend-php"
|
||||
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION}-bcmath"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#Zabbix part
|
||||
#===================GET GUEST DEFAULT USER STATE==============
|
||||
|
@ -35,35 +44,31 @@ disable_admin_user(){
|
|||
lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`")
|
||||
lastid=$((lastid + 1 ))
|
||||
$mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);"
|
||||
ynh_print_info "Default admin disabled"
|
||||
|
||||
ynh_print_info --message="Default admin disabled"
|
||||
else
|
||||
ynh_print_info "Default admin already disabled"
|
||||
|
||||
ynh_print_info --message="Default admin already disabled"
|
||||
fi
|
||||
}
|
||||
|
||||
enable_admin_user(){
|
||||
if [ $(get_state_admin_user) = "1" ] ;then
|
||||
ynh_print_info "Enable default admin"
|
||||
ynh_print_info --message="Enable default admin"
|
||||
#enable default admin temporaly
|
||||
$mysqlconn -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;"
|
||||
ynh_print_info "Default admin enabled"
|
||||
ynh_print_info --message="Default admin enabled"
|
||||
else
|
||||
ynh_print_info "Default admin already enable"
|
||||
ynh_print_info --message="Default admin already enable"
|
||||
fi
|
||||
}
|
||||
|
||||
import_template(){
|
||||
ynh_print_info "Import yunohost template"
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
enable_admin_user
|
||||
|
||||
zabbixFullpath=https://$domain$path_url
|
||||
localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml")
|
||||
sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix")
|
||||
confUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_userP_yunohost.conf")
|
||||
bashUserPpath=$(find /var/cache/yunohost/ -name "etc_zabbix_zabbix_agentd.d_yunohost.sh")
|
||||
|
||||
|
||||
cp "$sudoUserPpath" /etc/sudoers.d/zabbix
|
||||
|
||||
cp "../conf/zabbix" /etc/sudoers.d/zabbix
|
||||
|
||||
if [ -d /etc/zabbix/zabbix_agentd.d ];then
|
||||
mv /etc/zabbix/zabbix_agentd.d /etc/zabbix/zabbix_agentd.conf.d
|
||||
|
@ -72,8 +77,8 @@ import_template(){
|
|||
ln -s /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_agentd.d
|
||||
fi
|
||||
|
||||
cp "$confUserPpath" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf
|
||||
cp "$bashUserPpath" /etc/zabbix/zabbix_agentd.d/yunohost.sh
|
||||
cp "../conf/userP_yunohost.conf" /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf
|
||||
cp "../conf/yunohost.sh" /etc/zabbix/zabbix_agentd.d/yunohost.sh
|
||||
chmod a+x /etc/zabbix/zabbix_agentd.d/yunohost.sh
|
||||
|
||||
systemctl restart zabbix-agent
|
||||
|
@ -92,7 +97,7 @@ import_template(){
|
|||
|
||||
importState=$(curl $curlOptions \
|
||||
--form "config=1" \
|
||||
--form "import_file=@$localpath" \
|
||||
--form "import_file=@../conf/Template_Yunohost.xml" \
|
||||
--form "rules[groups][createMissing]=1" \
|
||||
--form "rules[templates][updateExisting]=1" \
|
||||
--form "rules[templates][createMissing]=1" \
|
||||
|
@ -119,33 +124,34 @@ import_template(){
|
|||
| grep -c "Imported successfully")
|
||||
|
||||
if [ "$importState" -eq "1" ];then
|
||||
ynh_print_info "Template Yunohost imported !"
|
||||
ynh_print_info --message="Template Yunohost imported !"
|
||||
else
|
||||
ynh_print_warn "Template Yunohost not imported !"
|
||||
ynh_print_warn --message="Template Yunohost not imported !"
|
||||
fi
|
||||
else
|
||||
ynh_print_warn "Admin user cannot connect interface !"
|
||||
ynh_print_warn --message="Admin user cannot connect interface !"
|
||||
fi
|
||||
}
|
||||
|
||||
link_template(){
|
||||
#apply template to host
|
||||
tokenapi=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{ "jsonrpc": "2.0","method": "user.login","params": {"user": "Admin","password": "zabbix"},"id": 1,"auth": null}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result')
|
||||
zabbixHostID=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.get","params":{"filter":{"host":["Zabbix server"]}},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result[0].hostid')
|
||||
zabbixTemplateID=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"template.get","params":{"filter":{"host":["Template Yunohost"]}},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result[0].templateid')
|
||||
applyTemplate=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.massadd","params":{"hosts":[{"hostid":"'"$zabbixHostID"'"}],"templates":[{"templateid":"'"$zabbixTemplateID"'"}]},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result.hostids[]')
|
||||
if [ "$applyTemplate" -eq "$zabbixHostID" ];then
|
||||
ynh_print_info "Template Yunohost linked to Zabbix server !"
|
||||
ynh_print_info --message="Template Yunohost linked to Zabbix server !"
|
||||
else
|
||||
ynh_print_warn "Template Yunohost no linked to Zabbix server !"
|
||||
ynh_print_warn --message="Template Yunohost no linked to Zabbix server !"
|
||||
fi
|
||||
|
||||
disable_admin_user
|
||||
|
||||
ynh_permission_update --permission="main" --remove="visitors"
|
||||
}
|
||||
|
||||
check_proc_zabbixserver(){
|
||||
pgrep zabbix_server >/dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
ynh_print_info "zabbix server is started !"
|
||||
ynh_print_info --message="zabbix server is started !"
|
||||
else
|
||||
ynh_print_err "Zabbix Server not started, try to start it with the yunohost interface."
|
||||
ynh_print_err "If Zabbix Server can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
|
@ -153,13 +159,13 @@ check_proc_zabbixserver(){
|
|||
}
|
||||
|
||||
check_proc_zabbixagent(){
|
||||
pgrep zabbix_agentd >/dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
ynh_print_info "zabbix agent is started"
|
||||
else
|
||||
ynh_print_err "Zabbix agent not started, try to start it with the yunohost interface."
|
||||
ynh_print_err "If Zabbix agent can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
fi
|
||||
pgrep zabbix_agentd >/dev/null
|
||||
if [ $? -eq 0 ];then
|
||||
ynh_print_info --message="zabbix agent is started"
|
||||
else
|
||||
ynh_print_err "Zabbix agent not started, try to start it with the yunohost interface."
|
||||
ynh_print_err "If Zabbix agent can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
fi
|
||||
}
|
||||
|
||||
install_zabbix_repo(){
|
||||
|
@ -171,14 +177,15 @@ remove_zabbix_repo(){
|
|||
}
|
||||
|
||||
update_initZabbixConf(){
|
||||
if [ ! -d /etc/zabbix/web ] ;then mkdir -p /etc/zabbix/web ;fi
|
||||
cp $(find /var/cache/yunohost/ -name "etc_zabbix_web_init.zabbix.conf.php.sh") /etc/zabbix/web/init.zabbix.conf.php.sh
|
||||
chmod 700 /etc/zabbix/web/init.zabbix.conf.php.sh
|
||||
cp $(find /var/cache/yunohost/ -name "etc_apt_apt.conf.d_100update_force_init_zabbix_frontend_config") /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config
|
||||
if [ ! -d /etc/zabbix/web ] ;then mkdir -p /etc/zabbix/web ;fi
|
||||
ynh_add_config --template="../conf/init.zabbix.conf.php.sh" --destination="/etc/zabbix/web/init.zabbix.conf.php.sh"
|
||||
chmod 700 /etc/zabbix/web/init.zabbix.conf.php.sh
|
||||
ynh_add_config --template="../conf/100update_force_init_zabbix_frontend_config" --destination="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
}
|
||||
|
||||
delete_initZabbixConf(){
|
||||
if [ -f /etc/zabbix/web/init.zabbix.conf.php.sh ] ; then ynh_secure_remove /etc/zabbix/web/init.zabbix.conf.php.sh;fi
|
||||
if [ -f /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config ] ;then ynh_secure_remove /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config ;fi
|
||||
if [ -f /etc/zabbix/web/init.zabbix.conf.php.sh ] ; then ynh_secure_remove --file="/etc/zabbix/web/init.zabbix.conf.php.sh" ;fi
|
||||
if [ -f /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config ] ;then ynh_secure_remove --file="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config" ;fi
|
||||
}
|
||||
|
||||
#Patch timeout too short for zabbix agent if needed
|
||||
|
@ -204,7 +211,7 @@ set_mediatype_default_yunohost(){
|
|||
set -x
|
||||
if [ $($mysqlconn -BN -e "SELECT count(*) FROM media_type WHERE smtp_server LIKE 'mail.example.com' AND status=1;") -eq 1 ] ; then
|
||||
$mysqlconn -BN -e "UPDATE media_type SET smtp_server = 'localhost', smtp_helo = '"$domain"', smtp_email = 'zabbix@"$domain"', smtp_port = '587', status=0 , smtp_security=1 WHERE smtp_server LIKE 'mail.example.com' AND status=1;"
|
||||
ynh_print_info "Default Media type added !"
|
||||
ynh_print_info --message="Default Media type added !"
|
||||
fi
|
||||
set +x
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -14,7 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -23,58 +23,59 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app="zabbix"
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
nonfree=$(ynh_app_setting_get $app nonfree)
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
#backup frontend config
|
||||
ynh_print_info "Backup $final_path conf/zabbix.conf.php"
|
||||
ynh_backup "$final_path/conf/zabbix.conf.php"
|
||||
ynh_print_info "Backup /etc/zabbix/web"
|
||||
ynh_backup "/etc/zabbix/web"
|
||||
#ynh_print_info "Backup /etc/zabbix/web/init.zabbix.conf.php.sh"
|
||||
#ynh_backup "/etc/zabbix/web/init.zabbix.conf.php.sh"
|
||||
ynh_print_info "Backup /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
ynh_backup "/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
|
||||
#backup server confif
|
||||
ynh_print_info "Backup /etc/zabbix/zabbix_server.conf"
|
||||
ynh_backup "/etc/zabbix/zabbix_server.conf"
|
||||
|
||||
#backup agent config
|
||||
ynh_print_info "Backup /etc/zabbix/zabbix_agentd.conf"
|
||||
ynh_backup "/etc/zabbix/zabbix_agentd.conf"
|
||||
ynh_print_info "Backup /etc/zabbix/zabbix_agentd.d"
|
||||
ynh_backup "/etc/zabbix/zabbix_agentd.d"
|
||||
|
||||
#backup sudo file
|
||||
ynh_print_info "Backup /etc/sudoers.d/zabbix"
|
||||
ynh_backup "/etc/sudoers.d/zabbix"
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backup /etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backup /etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# Backup frontend config
|
||||
ynh_backup --src_path="$final_path/conf/zabbix.conf.php"
|
||||
ynh_backup --src_path="/etc/zabbix"
|
||||
ynh_backup --src_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
|
||||
# Backup server config
|
||||
ynh_backup --src_path="/etc/zabbix/zabbix_server.conf"
|
||||
|
||||
# Backup agent config
|
||||
ynh_backup --src_path="/etc/zabbix/zabbix_agentd.conf"
|
||||
ynh_backup --src_path="/etc/zabbix/zabbix_agentd.d"
|
||||
|
||||
# Backup sudo file
|
||||
ynh_backup --src_path="/etc/sudoers.d/zabbix"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Backup Zabbix database"
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
|
@ -25,22 +24,32 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
#db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#db_user=$db_name
|
||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
|
@ -63,29 +72,30 @@ fi
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
# Change the path in the NGINX config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
# Make a backup of the original NGINX config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -99,5 +109,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app"
|
||||
|
|
402
scripts/install
402
scripts/install
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
##=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
|
@ -19,95 +20,59 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
export domain="$YNH_APP_ARG_DOMAIN"
|
||||
export path_url="$YNH_APP_ARG_PATH"
|
||||
admin="$YNH_APP_ARG_ADMIN"
|
||||
is_public="$YNH_APP_ARG_IS_PUBLIC"
|
||||
language="$YNH_APP_ARG_LANGUAGE"
|
||||
export domain=$YNH_APP_ARG_DOMAIN
|
||||
export path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||
### The app instance name is probably what interests you most, since this is
|
||||
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||
### db names, ...
|
||||
app="$YNH_APP_INSTANCE_NAME"
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
||||
final_path=/var/www/zabbix
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available --domain="$domain" --path_url="$path_url"
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Get infos from manifest" -w 1
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" path "$path_url"
|
||||
ynh_app_setting_set "$app" admin "$admin"
|
||||
ynh_app_setting_set "$app" language "$language"
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
|
||||
### Use these lines if you have to open a port for the application
|
||||
### `ynh_find_port` will find the first available port starting from the given port.
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "CLOSE A PORT" in the remove script
|
||||
|
||||
### Zabbix server is not opened by default for external usage.
|
||||
### if you want use zabbix server with external agent (in active mode), setup the listen address in server configuration and open port on firewall via the cmd yunohost firewall
|
||||
|
||||
# Find a free port
|
||||
#port=$(ynh_find_port 8095)
|
||||
# Open this port
|
||||
#yunohost firewall allow --no-upnp TCP $port 2>&1
|
||||
#ynh_app_setting_set $app port $port
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||
### Those deb packages will be installed as dependencies of this package.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
pid=$(pgrep -f '/usr/bin/python3 /usr/bin/unattended-upgrade --download-only' || true)
|
||||
if [ ! -z "$pid" ] ;then
|
||||
ynh_script_progression --message="Check and wait end of unattended-upgrade of package_check" -w 1
|
||||
tail --pid=$pid -f /dev/null
|
||||
ynh_script_progression --message="Check and wait end of unattended-upgrade of package_check"
|
||||
tail --pid=$pid -f /dev/null
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Remove Zabbix if already installed" -w 1
|
||||
ynh_script_progression --message="Remove Zabbix if already installed"
|
||||
apt-get purge zabbix* -y
|
||||
if compgen -G "/var/cache/apt/archives/zabbix-server-mysql*" > /dev/null; then
|
||||
ynh_secure_remove /var/cache/apt/archives/zabbix-server-mysql*
|
||||
ynh_secure_remove --file="/var/cache/apt/archives/zabbix-server-mysql*"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Install Zabbix repository" -w 3
|
||||
ynh_script_progression --message="Install Zabbix repository"
|
||||
install_zabbix_repo
|
||||
|
||||
ynh_script_progression --message="Update and install dependencies" -w 5
|
||||
ynh_script_progression --message="Update and install dependencies"
|
||||
#ynh_package_update no need cause ynh_install_app_dependencies after
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
dpkg -i --force-confmiss /var/cache/apt/archives/zabbix-server-mysql*
|
||||
|
@ -115,36 +80,52 @@ dpkg -i --force-confmiss /var/cache/apt/archives/zabbix-server-mysql*
|
|||
ynh_replace_string --match_string="# fr_FR.UTF-8 UTF-8" --replace_string="fr_FR.UTF-8 UTF-8" --target_file=/etc/locale.gen
|
||||
locale-gen
|
||||
|
||||
ln -s /usr/share/zabbix "$final_path"
|
||||
if [ -f "$final_path/conf/zabbix.conf.php" ];then
|
||||
ynh_secure_remove "$final_path/conf/zabbix.conf.php"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creation of database " -w 10
|
||||
ynh_script_progression --message="Creating a MySQL database..."
|
||||
|
||||
### Use these lines if you need a database for the application.
|
||||
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
||||
### The password will be stored as 'mysqlpwd' into the app settings,
|
||||
### and will be available as $db_pwd
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
|
||||
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
|
||||
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ln -s /usr/share/zabbix "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring PHP-FPM..."
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# IMPORT DEFAULT DATA
|
||||
#=================================================
|
||||
ynh_script_progression --message="Import default data in database..."
|
||||
|
||||
declare db_pwd
|
||||
db_name=$(ynh_sanitize_dbid "$app")
|
||||
db_user="$db_name"
|
||||
ynh_app_setting_set "$app" db_name "$db_name"
|
||||
ynh_app_setting_set "$app" db_user "$db_user"
|
||||
ynh_mysql_setup_db "$db_user" "$db_name"
|
||||
export mysqlconn="mysql -u$db_user -p$db_pwd $db_name"
|
||||
mysql --user=$db_user --password=$db_pwd --database=zabbix -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||||
|
||||
ynh_script_progression --message="Import default data in database..." -w 25
|
||||
|
||||
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn
|
||||
|
||||
convert_ZabbixDB
|
||||
|
@ -152,29 +133,23 @@ convert_ZabbixDB
|
|||
#sso integration
|
||||
$mysqlconn -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;"
|
||||
|
||||
if [ "$language" == "fr" ];then
|
||||
lang="fr_FR"
|
||||
else
|
||||
lang="en_GB"
|
||||
fi
|
||||
|
||||
#admin creation
|
||||
surname=$(ynh_user_get_info "$admin" lastname)
|
||||
name=$(ynh_user_get_info "$admin" firstname)
|
||||
|
||||
$mysqlconn -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'$admin', '$admin', '$admin', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 3, 'default', 0, '', 0, 50);"
|
||||
$mysqlconn -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'$admin', '$admin', '$admin', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$language', '30s', 3, 'default', 0, '', 0, 50);"
|
||||
$mysqlconn -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) VALUES (5, 7, 3);"
|
||||
|
||||
#users creation in zabbix database
|
||||
i=4
|
||||
for user in $(ynh_user_list);
|
||||
do
|
||||
if [ "$user" != "$admin" ];then
|
||||
surname=$(ynh_user_get_info "$user" lastname)
|
||||
name=$(ynh_user_get_info "$user" firstname)
|
||||
$mysqlconn -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ($i,'$user', '$name', '$surname', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$lang', '30s', 1, 'default', 0, '', 0, 50);"
|
||||
i=$((i+1))
|
||||
fi
|
||||
if [ "$user" != "$admin" ];then
|
||||
surname=$(ynh_user_get_info "$user" lastname)
|
||||
name=$(ynh_user_get_info "$user" firstname)
|
||||
$mysqlconn -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ($i,'$user', '$name', '$surname', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$language', '30s', 1, 'default', 0, '', 0, 50);"
|
||||
i=$((i+1))
|
||||
fi
|
||||
done
|
||||
|
||||
disable_guest_user
|
||||
|
@ -182,113 +157,11 @@ disable_guest_user
|
|||
set_mediatype_default_yunohost
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||
### downloaded from an upstream source, like a git repository.
|
||||
### `ynh_setup_source` use the file conf/app.src
|
||||
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
#ynh_setup_source "$final_path"
|
||||
|
||||
ynh_script_progression --message="Generate web config" -w 5
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
#ynh_system_user_create $app
|
||||
#
|
||||
### zabbix user created in zabbix server dpkg install
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
### `ynh_add_fpm_config` is used to set up a PHP config.
|
||||
### You can remove it if your app doesn't use PHP.
|
||||
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
||||
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
||||
### With the reload at the end of the script.
|
||||
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
||||
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
||||
### Have a look at the app to be sure this app needs a systemd script.
|
||||
### `ynh_systemd_config` will use the file conf/systemd.service
|
||||
### If you're not using these lines:
|
||||
### - You can remove those files in conf/.
|
||||
### - Remove the section "BACKUP SYSTEMD" in the backup script
|
||||
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
|
||||
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
||||
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||
|
||||
# Create a dedicated systemd config
|
||||
#ynh_add_systemd_config
|
||||
|
||||
### Systemd service created when dpkg install
|
||||
|
||||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
|
||||
### Use these lines only if the app installation needs to be finalized through
|
||||
### web forms. We generally don't want to ask the final user,
|
||||
### so we're going to use curl to automatically fill the fields and submit the
|
||||
### forms.
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Reload Nginx
|
||||
systemctl reload nginx
|
||||
|
||||
# Installation with curl
|
||||
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
### `ynh_replace_string` is used to replace a string in a file.
|
||||
### (It's compatible with sed regular expressions syntax)
|
||||
|
||||
ynh_script_progression -m "Generate zabbix config files" -w 5
|
||||
|
||||
confServerPath=$(find /var/cache/yunohost/ -name "usr_share_zabbix_conf_zabbix.conf.php")
|
||||
cp --remove-destination "$confServerPath" /usr/share/zabbix/conf/zabbix.conf.php
|
||||
ynh_replace_string --match_string="db_name" --replace_string="$db_name" --target_file=/usr/share/zabbix/conf/zabbix.conf.php
|
||||
ynh_replace_string --match_string="db_user" --replace_string="$db_user" --target_file=/usr/share/zabbix/conf/zabbix.conf.php
|
||||
ynh_replace_string --match_string="db_pwd" --replace_string="$db_pwd" --target_file=/usr/share/zabbix/conf/zabbix.conf.php
|
||||
ynh_add_config --template="../conf/zabbix.conf.php" --destination="/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
|
||||
chown -R www-data. /usr/share/zabbix
|
||||
|
||||
|
@ -296,117 +169,38 @@ ynh_replace_string --match_string="DBName=zabbix" --replace_string="DBName=$db_n
|
|||
ynh_replace_string --match_string="DBUser=zabbix" --replace_string="DBUser=$db_user" --target_file=/etc/zabbix/zabbix_server.conf
|
||||
ynh_replace_string --match_string="# DBPassword=" --replace_string="# DBPassword=\nDBPassword=$db_pwd" --target_file=/etc/zabbix/zabbix_server.conf
|
||||
|
||||
systemctl enable zabbix-agent --quiet && systemctl restart zabbix-agent
|
||||
change_timeoutAgent
|
||||
systemctl enable zabbix-server --quiet && systemctl restart zabbix-server
|
||||
|
||||
#=================================================
|
||||
# INSTALL hook to verify if conf file is broken (after an update for example)
|
||||
#=================================================
|
||||
|
||||
update_initZabbixConf
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# IMPORT YUNOHOST TEMPLATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Importing YunoHost template in Zabbix"
|
||||
|
||||
### `ynh_store_file_checksum` is used to store the checksum of a file.
|
||||
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
|
||||
### you can make a backup of this file before modifying it again if the admin had modified it.
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
#ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
||||
import_template
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
### For security reason, any app should set the permissions to root: before anything else.
|
||||
### Then, if write authorization is needed, any access should be given only to directories
|
||||
### that really need such authorization.
|
||||
|
||||
# Set permissions to app files
|
||||
#chown -R root: $final_path
|
||||
yunohost service add snmpd --description="Management of SNMP Daemon"
|
||||
yunohost service add zabbix-server --description="Management Zabbix server daemon : Collect, agregate, compute and notify"
|
||||
yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
||||
### Use this helper only if there is effectively a log file for this app.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
||||
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
|
||||
### - And the section "SETUP LOGROTATE" in the upgrade script
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
#native logrotate because install officials packages.
|
||||
#ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
|
||||
### You'll find the service in the 'services' section of YunoHost admin panel.
|
||||
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
|
||||
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
|
||||
|
||||
yunohost service add snmpd -d "Management of SNMP Daemon"
|
||||
yunohost service add zabbix-server -d "Management Zabbix server daemon : Collect, agregate, compute and notify"
|
||||
yunohost service add zabbix-agent -d "Management Zabbix agent daemon : send informations about this host to the server"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
systemctl reload php7.3-fpm
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
|
||||
#=================================================
|
||||
# Import Yunohost template
|
||||
#=================================================
|
||||
ynh_script_progression -m "Importing last template Yunohost in Zabbix" -w 5
|
||||
import_template
|
||||
|
||||
#=================================================
|
||||
# Link Yunohost template to the ZAbbix Server Host
|
||||
#=================================================
|
||||
ynh_script_progression -m "Importing last template Yunohost in Zabbix" -w 5
|
||||
link_template
|
||||
|
||||
#=================================================
|
||||
# disable default admin
|
||||
#=================================================
|
||||
disable_admin_user
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# Make app public if necessary
|
||||
if [ "$is_public" -eq 1 ]
|
||||
then
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
systemctl reload php7.3-fpm
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
systemctl enable zabbix-agent --quiet && systemctl restart zabbix-agent
|
||||
change_timeoutAgent
|
||||
systemctl enable zabbix-server --quiet && systemctl restart zabbix-server
|
||||
|
||||
#test if zabbix server is started
|
||||
check_proc_zabbixagent
|
||||
|
@ -414,8 +208,28 @@ check_proc_zabbixagent
|
|||
#test if zabbix agent is started
|
||||
check_proc_zabbixserver
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
|
|
127
scripts/remove
127
scripts/remove
|
@ -12,35 +12,32 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
port=$(ynh_app_setting_get "$app" port)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
#final_path=$(ynh_app_setting_get "$app" final_path) #not used
|
||||
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
yunohost service remove snmpd
|
||||
yunohost service remove zabbix-server
|
||||
yunohost service remove zabbix-agent
|
||||
|
||||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
timeout 5 systemctl stop zabbix-server || killall zabbix_server
|
||||
systemctl disable zabbix-server --quiet
|
||||
killall zabbix_server
|
||||
|
@ -49,90 +46,90 @@ timeout 5 systemctl stop zabbix-agent || killall zabbix_agentd
|
|||
systemctl disable zabbix-agent --quiet
|
||||
killall zabbix_agentd
|
||||
|
||||
#Remove config file detection
|
||||
delete_initZabbixConf
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive apt-get purge zabbix-release -y
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#force removing if ynh_remove_app_dependencies not work (old zabbix version)
|
||||
for zabbix_pkg in $(apt list --installed | grep -Po "\K(zabbix-.*)(?=/)")
|
||||
do
|
||||
DEBIAN_FRONTEND=noninteractive apt-get purge --allow-change-held-packages "$zabbix_pkg" -y
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the MySQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db "$db_user" "$db_name"
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove config file detection
|
||||
delete_initZabbixConf
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive apt-get purge zabbix-release -y
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
# Force removing if ynh_remove_app_dependencies not work (old zabbix version)
|
||||
for zabbix_pkg in $(apt list --installed | grep -Po "\K(zabbix-.*)(?=/)")
|
||||
do
|
||||
DEBIAN_FRONTEND=noninteractive apt-get purge --allow-change-held-packages "$zabbix_pkg" -y
|
||||
done
|
||||
|
||||
remove_zabbix_repo
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing PHP-FPM configuration..."
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
echo "Close port $port" >&2
|
||||
yunohost firewall disallow TCP "$port" 2>&1
|
||||
fi
|
||||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE THE CRON FILE
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
remove_zabbix_repo
|
||||
|
||||
if [ -d /var/www/zabbix ] ;then ynh_secure_remove /var/www/zabbix;fi
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove a directory securely
|
||||
if [ -d /etc/zabbix ] ;then ynh_secure_remove "/etc/zabbix";fi
|
||||
if [ -d /etc/zabbix ] ;then ynh_secure_remove --file="/etc/$app";fi
|
||||
|
||||
# Remove the log files
|
||||
if [ -d /var/log/zabbix ] ;then ynh_secure_remove "/var/log/zabbix";fi
|
||||
if [ -d /var/log/zabbix ] ;then ynh_secure_remove --file="/var/log/$app";fi
|
||||
|
||||
# Remove the pid/socket files
|
||||
if [ -d /run/zabbix ] ;then ynh_secure_remove "/run/zabbix";fi
|
||||
if [ -d /run/zabbix ] ;then ynh_secure_remove --file="/run/zabbix";fi
|
||||
|
||||
# Remove the sudoers file
|
||||
if [ -f /etc/sudoers.d/zabbix ] ;then ynh_secure_remove "/etc/sudoers.d/zabbix";fi
|
||||
|
||||
|
||||
#REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1)
|
||||
nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free)
|
||||
if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader") -eq 1 ] ;then
|
||||
ynh_print_info "Removing snmp-mibs-downloader (non-free package)"
|
||||
cp /var/lib/dpkg/status{,.$(date "+%m%d%y")}
|
||||
ynh_replace_string --match_string=" snmp-mibs-downloader," --replace_string="" --target_file=/var/lib/dpkg/status
|
||||
DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y
|
||||
if [ -f /etc/apt/sources.list.d/non-free.list ];then
|
||||
ynh_secure_remove /etc/apt/sources.list.d/non-free.list
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /etc/sudoers.d/zabbix ] ;then ynh_secure_remove --file="/etc/sudoers.d/zabbix";fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete zabbix
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
|
|
196
scripts/restore
196
scripts/restore
|
@ -1,10 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -15,46 +17,59 @@ source /usr/share/yunohost/helpers
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||
### The app instance name is probably what interests you most, since this is
|
||||
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||
### db names, ...
|
||||
app="zabbix"
|
||||
final_path="/var/www/zabbix"
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
||||
ynh_secure_remove $final_path
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
#path_url=$(ynh_app_setting_get $app path) #not used
|
||||
#admin=$(ynh_app_setting_get $app admin) #not used
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
#language=$(ynh_app_setting_get $app language) #not used
|
||||
nonfree=$(ynh_app_setting_get $app nonfree)
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ln -s /usr/share/zabbix /var/www/zabbix
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
ynh_print_info "Install Zabbix repository"
|
||||
install_zabbix_repo
|
||||
|
||||
ynh_print_info "Update and install dependencies"
|
||||
ynh_package_update
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php
|
||||
|
@ -62,109 +77,76 @@ DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend
|
|||
ynh_replace_string --match_string="# fr_FR.UTF-8 UTF-8" --replace_string="fr_FR.UTF-8 UTF-8" --target_file=/etc/locale.gen
|
||||
locale-gen
|
||||
|
||||
ln -s /usr/share/zabbix /var/www/zabbix
|
||||
ynh_secure_remove $final_path/conf/zabbix.conf.php
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..."
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
convert_ZabbixDB
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
# Restore frontend config
|
||||
ynh_restore_file --origin_path="$final_path/conf/zabbix.conf.php"
|
||||
chown -R www-data. /usr/share/zabbix
|
||||
ynh_restore_file --origin_path="/etc/zabbix"
|
||||
ls -Rail "/etc/zabbix"
|
||||
ynh_restore_file --origin_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
|
||||
# Create a dedicated nginx config
|
||||
# Restore server config
|
||||
ynh_restore_file --origin_path="/etc/zabbix/zabbix_server.conf"
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
# Restore agent config
|
||||
ynh_restore_file --origin_path="/etc/zabbix/zabbix_agentd.conf"
|
||||
if [ ! -L /etc/zabbix/zabbix_agentd.d ];then
|
||||
ln -s /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_agentd.d
|
||||
fi
|
||||
|
||||
# Restore sudo file
|
||||
ynh_restore_file "/etc/sudoers.d/zabbix"
|
||||
ynh_restore_file --origin_path="/etc/sudoers.d/zabbix"
|
||||
|
||||
#=================================================
|
||||
# Restore db
|
||||
#=================================================
|
||||
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_user=$(ynh_app_setting_get $app db_user)
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
|
||||
ynh_mysql_setup_db "$db_user" "$db_name" "$db_pwd"
|
||||
convert_ZabbixDB
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add snmpd --description="Management of SNMP Daemon"
|
||||
yunohost service add zabbix-server --description="Management Zabbix server daemon : Collect, agregate, compute and notify"
|
||||
yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server"
|
||||
|
||||
#=================================================
|
||||
# Restore configs files
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
### `ynh_replace_string` is used to replace a string in a file.
|
||||
### (It's compatible with sed regular expressions syntax)
|
||||
|
||||
ynh_restore_file "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
|
||||
chown -R www-data. /usr/share/zabbix
|
||||
|
||||
ynh_restore_file "/etc/zabbix"
|
||||
ls -Rail "/etc/zabbix"
|
||||
#ynh_restore_file "/etc/zabbix/web"
|
||||
#ynh_restore_file "/etc/zabbix/web/init.zabbix.conf.php.sh"
|
||||
ynh_restore_file "/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
if [ ! -L /etc/zabbix/zabbix_agentd.d ];then
|
||||
ln -s /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_agentd.d
|
||||
fi
|
||||
systemctl enable --quiet zabbix-agent && systemctl restart zabbix-agent
|
||||
change_timeoutAgent
|
||||
systemctl enable --quiet zabbix-server && systemctl restart zabbix-server
|
||||
|
||||
yunohost service add snmpd -d "Management of SNMP Daemon"
|
||||
yunohost service add zabbix-server -d "Management Zabbix server daemon : Collect, agregate, compute and notify"
|
||||
yunohost service add zabbix-agent -d "Management Zabbix agent daemon : send informations about this host to the server"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
||||
### Use this helper only if there is effectively a log file for this app.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
||||
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
|
||||
### - And the section "SETUP LOGROTATE" in the upgrade script
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
#ynh_use_logrotate
|
||||
#no need, use native logrotate in zabbix packages
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# Make app public if necessary
|
||||
if [ "$is_public" -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
||||
systemctl reload php7.0-fpm
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
|
||||
#test if zabbix server is started
|
||||
check_proc_zabbixagent
|
||||
|
||||
#test if zabbix agent is started
|
||||
check_proc_zabbixserver
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
||||
|
||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
|
|
313
scripts/upgrade
313
scripts/upgrade
|
@ -12,221 +12,184 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
trustedversion="4.4-1+stretch"
|
||||
forceupdate=0
|
||||
export domain=$(ynh_app_setting_get "$app" domain)
|
||||
export path_url=$(ynh_app_setting_get "$app" path)
|
||||
#admin=$(ynh_app_setting_get "$app" admin) #not used
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
#language=$(ynh_app_setting_get "$app" language) #not used
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
db_user=$(ynh_app_setting_get "$app" db_user)
|
||||
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
yunohost service stop zabbix-server
|
||||
yunohost service stop zabbix-agent
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set "$app" is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set "$app" is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid "$app")
|
||||
ynh_app_setting_set "$app" db_name "$db_name"
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
fi
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
export mysqlconn="mysql -u$db_user -p$db_pwd $db_name"
|
||||
|
||||
#=================================================
|
||||
# DISABLED SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "disable SSOWAT temporaly"
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
systemctl reload nginx
|
||||
yunohost app ssowatconf
|
||||
|
||||
#=================================================
|
||||
# Enable default admin temporaly
|
||||
#=================================================
|
||||
enable_admin_user
|
||||
|
||||
#=================================================
|
||||
# Import Yunohost template
|
||||
#=================================================
|
||||
import_template
|
||||
|
||||
#=================================================
|
||||
# Link Yunohost template to the ZAbbix Server Host
|
||||
#=================================================
|
||||
link_template
|
||||
|
||||
#=================================================
|
||||
# Disable default admin for security issue
|
||||
#=================================================
|
||||
disable_admin_user
|
||||
|
||||
#=================================================
|
||||
# Disable default guest for security issue
|
||||
#=================================================
|
||||
disable_guest_user
|
||||
|
||||
#Patch timeout too short for zabbix agent if needed
|
||||
change_timeoutAgent
|
||||
|
||||
#patch if zabbix-release installed
|
||||
if [ "$(dpkg -l zabbix-release 2>/dev/null | wc -l)" -ne 0 ];then
|
||||
DEBIAN_FRONTEND=noninteractive apt purge zabbix-release -y
|
||||
install_zabbix_repo
|
||||
fi
|
||||
|
||||
#patch if zabbix-release has Candidate version but no Installed version
|
||||
if [ -f "/etc/apt/sources.list.d/zabbix.list" ];then
|
||||
if [ "$(grep -c "4.2" /etc/apt/sources.list.d/zabbix.list)" -eq 1 ];then
|
||||
install_zabbix_repo
|
||||
forceupdate=1
|
||||
fi
|
||||
fi
|
||||
|
||||
#patch to remove old zabbix-client service
|
||||
if [ ! -z "$(yunohost service status | grep zabbix-client)" ];then
|
||||
ynh_print_info "remove zabbix-client old service"
|
||||
yunohost service remove zabbix-client
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
#REMOVE DUPLICATE LOG ENTRY IN LOGROTATE PATCH IF NEEDED
|
||||
ynh_remove_logrotate
|
||||
|
||||
ynh_print_info "Check if new zabbix version is available on repo"
|
||||
ynh_package_update
|
||||
|
||||
zabbixReleaseInstalledVersion=$(apt-cache policy zabbix-release | sed -n '2p' | grep -Po ".* \K(.*)")
|
||||
|
||||
if [[ "$trustedversion" > "$zabbixReleaseInstalledVersion" ]] || [[ "$forceupdate" == "1" ]]
|
||||
then
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# Migrate legacy permissions to new system
|
||||
#=================================================
|
||||
if ynh_legacy_permissions_exists
|
||||
then
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
yunohost service stop zabbix-server
|
||||
yunohost service stop zabbix-agent
|
||||
|
||||
cp -rp /etc/zabbix /tmp/
|
||||
cp -p /usr/share/zabbix/conf/zabbix.conf.php /tmp/
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive apt-mark unhold zabbix-server-mysql zabbix-frontend-php
|
||||
ynh_package_remove zabbix-server-mysql zabbix-frontend-php
|
||||
|
||||
ynh_print_info "Update zabbix via apt package"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_secure_remove /usr/share/zabbix/conf/zabbix.conf.php
|
||||
cp -rpf /tmp/zabbix /etc/
|
||||
cp -pf /tmp/zabbix.conf.php /usr/share/zabbix/conf/
|
||||
|
||||
ynh_secure_remove /tmp/zabbix*
|
||||
|
||||
#If needed.
|
||||
yunohost service add snmpd -d "Management of SNMP Daemon"
|
||||
yunohost service add zabbix-server -d "Management Zabbix server daemon : Collect, agregate, compute and notify"
|
||||
yunohost service add zabbix-agent -d "Management Zabbix agent daemon : send informations about this host to the server"
|
||||
|
||||
yunohost service start zabbix-server
|
||||
yunohost service start zabbix-agent
|
||||
|
||||
#test if zabbix server is started
|
||||
check_proc_zabbixagent
|
||||
|
||||
#test if zabbix agent is started
|
||||
check_proc_zabbixserver
|
||||
|
||||
else
|
||||
ynh_print_info "No repo update ! (Trusted version)"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
cp -rp /etc/zabbix /tmp/
|
||||
cp -p /usr/share/zabbix/conf/zabbix.conf.php /tmp/
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive apt-mark unhold zabbix-server-mysql zabbix-frontend-php
|
||||
ynh_package_remove zabbix-server-mysql zabbix-frontend-php
|
||||
|
||||
ynh_script_progression --message="Install Zabbix repository"
|
||||
install_zabbix_repo
|
||||
|
||||
ynh_print_info "Update zabbix via apt package"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_secure_remove --file="/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
cp -rpf /tmp/zabbix /etc/
|
||||
cp -pf /tmp/zabbix.conf.php /usr/share/zabbix/conf/
|
||||
|
||||
ynh_secure_remove --file="/tmp/zabbix*"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# INSTALL hook to verify if conf file is broken (after an update for example)
|
||||
#=================================================
|
||||
|
||||
update_initZabbixConf
|
||||
|
||||
#=================================================
|
||||
# Update db to utf8
|
||||
#=================================================
|
||||
|
||||
convert_ZabbixDB
|
||||
|
||||
#=================================================
|
||||
# Add settings for yunohost mail server
|
||||
#=================================================
|
||||
|
||||
set_mediatype_default_yunohost
|
||||
|
||||
#=================================================
|
||||
# Update php-fpm confi
|
||||
# IMPORT YUNOHOST TEMPLATE
|
||||
#=================================================
|
||||
ynh_print_info "Update php-fpm config"
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
ynh_script_progression --message="Importing YunoHost template in Zabbix"
|
||||
|
||||
import_template
|
||||
|
||||
#=================================================
|
||||
# Update nginx config
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
ynh_print_info "Update nginx config"
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
|
||||
#=================================================
|
||||
# RE-ENABLE SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "re-enable SSOWAT"
|
||||
# Make app private if necessary
|
||||
if [ $is_public -eq 0 ]
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_delete "$app" unprotected_uris
|
||||
else
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
ynh_add_nginx_config
|
||||
systemctl reload nginx
|
||||
yunohost app ssowatconf
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add snmpd --description="Management of SNMP Daemon"
|
||||
yunohost service add zabbix-server --description="Management Zabbix server daemon : Collect, agregate, compute and notify"
|
||||
yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
systemctl enable zabbix-agent --quiet && systemctl restart zabbix-agent
|
||||
change_timeoutAgent
|
||||
systemctl enable zabbix-server --quiet && systemctl restart zabbix-server
|
||||
|
||||
#test if zabbix server is started
|
||||
check_proc_zabbixagent
|
||||
|
||||
#test if zabbix agent is started
|
||||
check_proc_zabbixserver
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
|
|
2
sources/extra_files/app/.gitignore
vendored
2
sources/extra_files/app/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
Loading…
Add table
Reference in a new issue