Commit e528090c authored by Charlie Root's avatar Charlie Root

added script pkg_updates.sh

parent 4a847c87
#!/bin/sh
# Copyright (C) 2014 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:
#
# 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 ``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.
# USAGE:
# Add this file to a CRON job to check for pakcage updates regularly
#
# It generates different files to reflect repository/packages state
# /tmp/pkg_updates.output -> Output of pkg update
# /tmp/pkg_connection_issue -> Empty file to signal a connection issue
# /tmp/pkg_repository.error -> Empty file to signal a repository error
# /tmp/pkg_upgrades.output -> Output of pkg upgrade -n
# /tmp/pkg_updates.available -> File with content the number of upgrades or new installs
# /tmp/pkg_core_update.available -> File with content the new OPNsense version number
pkg_running=""
# Check if pkg is already runnig
pkg_running=`ps | grep "pkg " | grep -v "grep"`
if [ "$pkg_running" == "" ]; then
# start pkg update
pkg update -f > /tmp/pkg_updates.output 2>&1 &
pid=$!
# wait for defined number of seconds for connection
sleep 5
# check if pkg is done, if not we have a connection issue
pkg_running=`ps | grep $pid | grep -v "grep"`
if [ "$pkg_running" == "" ]; then
# Connection is ok
# Lets cleanup old connection errors
if [ -f /tmp/pkg_connection_issue ]; then
rm /tmp/pkg_connection_issue
fi
repo_ok=`cat /tmp/pkg_updates.output | grep 'Unable to update repository'`
if [ "$repo_ok" == "" ]; then
# Repository can be used for updates
# Check if earlier attemps left repository error file
if [ -f /tmp/pkg_repository.error ]; then
# Remove previous error file
rm /tmp/pkg_repository.error
fi
# Now check if there are upgrades
pkg upgrade -n > /tmp/pkg_upgrades.output
updates=`cat /tmp/pkg_upgrades.output | grep 'The following' | awk -F '[ ]' '{print $3}'`
if [ "$updates" == "" ]; then
# There are no updates
# Lets remove any leftover update files
if [ -f /tmp/pkg_updates.available ]; then
rm /tmp/pkg_updates.available
fi
else
echo $updates > /tmp/pkg_updates.available
opnsense_core_update=`cat /tmp/pkg_upgrades.output | grep 'opnsense:' | awk -F '[ ]' '{print $4}'`
if [ "$opnsense_core_update" == "" ]; then
# There is no update
# Lets cleanup leftovers
if [ -f /tmp/pkg_core_update.available] ]; then
rm /tmp/pkg_core_update.available
fi
else
echo $opnse_core_update > /tmp/pkg_core_update.available
fi
fi
else
# There is an issue with the repository
# lets let other process know
touch /tmp/pkg_repository.error
fi
else
# We have an connection issue and can reach the pkg repository in timely fashion
touch /tmp/pkg_connection_issue
killall pkg
fi
else
# pkg is already running, quitting
fi
......@@ -632,30 +632,6 @@ function enable_change(enable_change) {
<?=gettext("If this option is set, only the most recent login per username will be active. Subsequent logins will cause machines previously logged in with the same username to be disconnected."); ?></td>
</tr>
<tr>
<td valign="top" class="vncell"><?=gettext("MAC filtering"); ?> </td>
<td class="vtable">
<input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked=\"checked\""; ?> />
<strong><?=gettext("Disable MAC filtering"); ?></strong><br />
<?=gettext("If this option is set, no attempts will be made to ensure that the MAC address of clients stays the same while they're logged in." .
"This is required when the MAC address of the client cannot be determined (usually because there are routers between"); ?> <?php echo $g['product_name'] ?> <?=gettext("and the clients)."); ?>
<?=gettext("If this is enabled, RADIUS MAC authentication cannot be used."); ?></td>
</tr>
<tr>
<td valign="top" class="vncell"><?=gettext("Pass-through MAC Auto Entry"); ?></td>
<td class="vtable">
<input name="passthrumacadd" type="checkbox" class="formfld" id="passthrumacadd" value="yes" <?php if ($pconfig['passthrumacadd']) echo "checked=\"checked\""; ?> />
<strong><?=gettext("Enable Pass-through MAC automatic additions"); ?></strong><br />
<?=gettext("If this option is set, a MAC passthrough entry is automatically added after the user has successfully authenticated. Users of that MAC address will never have to authenticate again."); ?>
<?=gettext("To remove the passthrough MAC entry you either have to log in and remove it manually from the"); ?> <a href="services_captiveportal_mac.php"><?=gettext("MAC tab"); ?></a> <?=gettext("or send a POST from another system to remove it."); ?>
<?=gettext("If this is enabled, RADIUS MAC authentication cannot be used. Also, the logout window will not be shown."); ?>
<br /><br />
<input name="passthrumacaddusername" type="checkbox" class="formfld" id="passthrumacaddusername" value="yes" <?php if ($pconfig['passthrumacaddusername']) echo "checked=\"checked\""; ?> />
<strong><?=gettext("Enable Pass-through MAC automatic addition with username"); ?></strong><br />
<?=gettext("If this option is set, with the automatically MAC passthrough entry created the username, used during authentication, will be saved."); ?>
<?=gettext("To remove the passthrough MAC entry you either have to log in and remove it manually from the"); ?> <a href="services_captiveportal_mac.php"><?=gettext("MAC tab"); ?></a> <?=gettext("or send a POST from another system to remove it."); ?>
</td>
</tr>
<tr>
<td valign="top" class="vncell"><?=gettext("Per-user bandwidth restriction"); ?></td>
<td class="vtable">
<input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked=\"checked\""; ?> />
......
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