system: move add_user script out of shell scripts

Shell scripts are for opnsense-shell.
This commit is contained in:
Franco Fichtner 2022-07-05 08:54:45 +02:00
parent dd677931fa
commit b6167bfd90
3 changed files with 24 additions and 23 deletions

2
plist
View File

@ -727,6 +727,7 @@
/usr/local/opnsense/scripts/OPNsense/Monit/carp_status
/usr/local/opnsense/scripts/OPNsense/Monit/gateway_alert
/usr/local/opnsense/scripts/OPNsense/Monit/setup.sh
/usr/local/opnsense/scripts/auth/add_user.php
/usr/local/opnsense/scripts/dhcp/cleanup_leases4.php
/usr/local/opnsense/scripts/dhcp/get_leases.py
/usr/local/opnsense/scripts/dhcp/prefixes.php
@ -838,7 +839,6 @@
/usr/local/opnsense/scripts/shaper/dummynet_stats.py
/usr/local/opnsense/scripts/shaper/lib/__init__.py
/usr/local/opnsense/scripts/shaper/update_tables
/usr/local/opnsense/scripts/shell/add_user
/usr/local/opnsense/scripts/shell/banner.php
/usr/local/opnsense/scripts/shell/defaults.php
/usr/local/opnsense/scripts/shell/firmware.sh

View File

@ -1,29 +1,30 @@
#!/usr/local/bin/php
<?php
/*
* Copyright (C) 2021 Deciso B.V.
* All rights reserved.
* Copyright (C) 2021 Deciso B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 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.
* 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.
* 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 ``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 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.
* THIS SOFTWARE IS PROVIDED ``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 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.
*/
require_once("auth.inc");
@ -33,7 +34,7 @@ $opts = getopt('hu:o', array(), $optind);
$args = array_slice($argv, $optind);
if (isset($opts['h']) || empty($opts['u'])) {
echo "Usage: add_user [-h] \n";
echo "Usage: add_user.php [-h] \n";
echo "\t-h show this help text and exit\n";
echo "\t-u [required] username\n";
echo "\t-o origin (default=automation)";

View File

@ -1,11 +1,11 @@
[user.changed]
command:/usr/local/sbin/pluginctl
parameters: -c user_changed %s
parameters: -c user_changed %s
type:script
message: User %s changed
[add.user]
command:/usr/local/opnsense/scripts/shell/add_user
command:/usr/local/opnsense/scripts/auth/add_user.php
parameters: -u %s
type:script_output
message: Add user %s