summaryrefslogtreecommitdiffstats
path: root/ctdb/common/event_script.h
blob: bf5a8fdf9a218016ac33c58b3e6431c2d2b87db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
   Low level event script handling

   Copyright (C) Amitay Isaacs  2017
   Copyright (C) Martin Schwenke  2018

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __CTDB_SCRIPT_H__
#define __CTDB_SCRIPT_H__

#include "replace.h"
#include "system/filesys.h"

#include <talloc.h>

/**
 * @file script.h
 *
 * @brief Script listing and manipulation
 */


struct event_script {
	char *name;
	char *path;
	bool enabled;
};

struct event_script_list {
	unsigned int num_scripts;
	struct event_script **script;
};


/**
 * @brief Retrieve a list of scripts
 *
 * @param[in] mem_ctx Talloc memory context
 * @param[in] script_dir Directory containing scripts
 * @param[out] out List of scripts
 * @return 0 on success, errno on failure
 */
int event_script_get_list(TALLOC_CTX *mem_ctx,
			  const char *script_dir,
			  struct event_script_list **out);

/**
 * @brief Make a script executable or not executable
 *
 * @param[in] script_dir Directory containing script
 * @param[in] script_name Name of the script to enable
 * @param[in] executable True if script should be made executable
 * @return 0 on success, errno on failure
 */
int event_script_chmod(const char *script_dir,
		       const char *script_name,
		       bool executable);

#endif /* __CTDB_SCRIPT_H__ */