-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpi-hole.html
118 lines (104 loc) · 4.99 KB
/
pi-hole.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<script type="text/x-red" data-template-name="pi-hole">
<div class="form-row">
<label for="node-input-command"><i class="fa fa-file"></i> Command</label>
<select type="text" id="node-input-command" style="width:70%">
<option value="">None</option>
<option value="enable">Enable Pi-hole</option>
<option value="disable">Disable Pi-hole</option>
<option value="restart">Restart Pi-hole</option>
<option value="updatePihole">Update Pi-hole subsystems</option>
<option value="updateGravity">Update the list of ad-serving domains</option>
<option value="flush">Flush Pi-hole logs</option>
<option value="status">Get Pi-hole status</option>
<option value="chronometer --json">Get Pi-hole stats (json formatted string)</option>
<option value="version">Get Pi-hole version</option>
<option value="logging on">Enable Pi-hole logging</option>
<option value="logging off">Disable Pi-hole logging</option>
<option value="query">Search the adlist for msg.payload/input</option>
<option value="query -exact">Search the adlist exactly for msg.payload/input</option>
<option value="whitelist">Whitelist: Add msg.payload/input to list</option>
<option value="whitelist -d">Whitelist: Remove msg.payload/input from list</option>
<option value="whitelist -l">Whitelist: Get list</option>
<option value="blacklist">Blacklist: Add msg.payload/input to list</option>
<option value="blacklist -d">Blacklist: Remove msg.payload/input from list</option>
<option value="blacklist -l">Blacklist: Get list</option>
</select>
</div>
<div class="form-row">
<label for="node-input-addpay"><i class="fa fa-plus"></i> Append</label>
<input type="checkbox" id="node-input-addpay" style="display:inline-block; width:auto; vertical-align:top;">
msg.payload
</div>
<div class="form-row">
<label for="node-input-append"> </label>
<input type="text" id="node-input-append" placeholder="extra input parameters">
</div>
<div class="form-row">
<label for="node-input-timer"><i class="fa fa-clock-o"></i> Timeout</label>
<input type="text" id="node-input-timer" style="width:65px;" placeholder="optional">
seconds
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="pi-hole">
<p>A node to control a local Pi-hole installation</p>
<h3>Prerequisites</h3>
<p>
The user account that runs Node-RED must be able to run the pihole command directly or through sudo without a password.<br>
<br>
For the sudo option, try this: <br>
<code>sudo visudo</code><br>
Append the following to the bottom of the file, replacing username with the user that runs Node-RED and your path to pihole:<br>
<code>username ALL=(ALL) NOPASSWD: /usr/local/bin/pihole</code><br>
<br>
You can run <code>whereis pihole</code> to figure out where pihole is installed on your system.
</p>
<h3>Command</h3>
<p>
Select which command we should send to pi-hole. You can use None to let msg.payload specify the command to run.<br>
<br>
Some of the commands should (normally) always be used together with the Append feature (e.g. to specify which domain to search for when using the Search command).
</p>
<h3>Append</h3>
<p>
The first option lets you append the input msg.payload to pi-hole, and the second allows you to specify additional parameters to send.<br>
<br>
Use this for any custom parameters you want to send to the pihole command.
</p>
<h3>Timeout</h3>
<p>How long we wait for your pi-hole command to finish. Please note that updating pi-hole or updating the list of ad-serving domains might take a while.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('pi-hole',{
category: 'function',
color:"#FFAAAA",
defaults: {
command: {value:""},
addpay: {value:true},
append: {value:""},
useSpawn: {value:"false"},
timer: {value:""},
oldrc: {value:false},
name: {value:""}
},
inputs:1,
outputs:3,
outputLabels: ["stdout","stderr","return code"],
icon: "pihole.png",
align: "left",
label: function() {
return this.name||this.command;
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if ($("#node-input-command").val() === null) {
$("#node-input-command").val(this.command.toString());
}
}
});
</script>