Commit 99c71c85 authored by Franco Fichtner's avatar Franco Fichtner

firmware: plugin detection via configd

parent 9d73770c
...@@ -545,6 +545,7 @@ ...@@ -545,6 +545,7 @@
/usr/local/opnsense/scripts/firmware/launcher.sh /usr/local/opnsense/scripts/firmware/launcher.sh
/usr/local/opnsense/scripts/firmware/license.sh /usr/local/opnsense/scripts/firmware/license.sh
/usr/local/opnsense/scripts/firmware/lock.sh /usr/local/opnsense/scripts/firmware/lock.sh
/usr/local/opnsense/scripts/firmware/plugin.sh
/usr/local/opnsense/scripts/firmware/reinstall.sh /usr/local/opnsense/scripts/firmware/reinstall.sh
/usr/local/opnsense/scripts/firmware/remove.sh /usr/local/opnsense/scripts/firmware/remove.sh
/usr/local/opnsense/scripts/firmware/running.sh /usr/local/opnsense/scripts/firmware/running.sh
......
#!/bin/sh
# Copyright (c) 2017 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
PLUGIN=${1}
PREFIX="os-"
SUFFIX="-devel"
RETURN="0"
# Return "1" if the plugin is installed. It will fuzzy-match the
# development version, unless specifically given the development
# version (os-plugin-devel-devel doesn't match obviously).
if pkg query %n "${PREFIX}${PLUGIN}" > /dev/null; then
RETURN="1"
elif pkg query %n "${PREFIX}${PLUGIN}${SUFFIX}" > /dev/null; then
RETURN="1"
fi
echo ${RETURN}
...@@ -89,6 +89,12 @@ parameters:%s ...@@ -89,6 +89,12 @@ parameters:%s
type:script type:script
message:issued firmware hotfix for %s message:issued firmware hotfix for %s
[plugin]
command: /usr/local/opnsense/scripts/firmware/plugin.sh
parameters:%s
type:script_output
message:Tested for presence of plugin %s
[status] [status]
command: /usr/bin/touch /tmp/pkg_upgrade.progress 2>&1; /bin/cat /tmp/pkg_upgrade.progress 2>&1 command: /usr/bin/touch /tmp/pkg_upgrade.progress 2>&1; /bin/cat /tmp/pkg_upgrade.progress 2>&1
parameters: parameters:
......
...@@ -76,8 +76,8 @@ function remove_duplicate($array, $field) ...@@ -76,8 +76,8 @@ function remove_duplicate($array, $field)
$interfaces = legacy_config_get_interfaces(array('virtual' => false)); $interfaces = legacy_config_get_interfaces(array('virtual' => false));
$leasesfile = services_dhcpd_leasesfile(); $leasesfile = services_dhcpd_leasesfile();
/* Check if WOL plugin is installed */
$plugin_installed = count(plugins_scan('wol')); $wol_installed = trim(configd_run('firmware plugin wol'));
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$awk = "/usr/bin/awk"; $awk = "/usr/bin/awk";
...@@ -420,7 +420,7 @@ include("head.inc");?> ...@@ -420,7 +420,7 @@ include("head.inc");?>
<td><?=$data['ip'];?></td> <td><?=$data['ip'];?></td>
<td> <td>
<?php <?php
if ($plugin_installed): ?> if ($wol_installed): ?>
<a href="services_wol.php?if=<?=$data['if'];?>&amp;mac=<?=$data['mac'];?>" title="<?=gettext("send Wake on LAN packet to this MAC address");?>"> <a href="services_wol.php?if=<?=$data['if'];?>&amp;mac=<?=$data['mac'];?>" title="<?=gettext("send Wake on LAN packet to this MAC address");?>">
<?=$data['mac'];?> <?=$data['mac'];?>
</a> </a>
...@@ -447,7 +447,7 @@ include("head.inc");?> ...@@ -447,7 +447,7 @@ include("head.inc");?>
<?php <?php
endif;?> endif;?>
<?php <?php
if ($plugin_installed): ?> if ($wol_installed): ?>
<a class="btn btn-default btn-xs" href="services_wol_edit.php?if=<?=$data['if'];?>&amp;mac=<?=$data['mac'];?>&amp;descr=<?=$data['hostname'];?>"> <a class="btn btn-default btn-xs" href="services_wol_edit.php?if=<?=$data['if'];?>&amp;mac=<?=$data['mac'];?>&amp;descr=<?=$data['hostname'];?>">
<span class="glyphicon glyphicon-flash" data-toggle="tooltip" title="<?=gettext("add a Wake on LAN mapping for this MAC address");?>" alt="add"></span> <span class="glyphicon glyphicon-flash" data-toggle="tooltip" title="<?=gettext("add a Wake on LAN mapping for this MAC address");?>" alt="add"></span>
</a> </a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment