mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-04 08:55:51 +02:00
Load installers's common functions
Signed-off-by: Matt Darfeuille <matdarf@gmail.com> Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
a3fc110dc9
commit
4e771083c7
@ -36,50 +36,12 @@ usage() # $1 = exit status
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error()
|
|
||||||
{
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
split() {
|
|
||||||
local ifs
|
|
||||||
ifs=$IFS
|
|
||||||
IFS=:
|
|
||||||
set -- $1
|
|
||||||
echo $*
|
|
||||||
IFS=$ifs
|
|
||||||
}
|
|
||||||
|
|
||||||
qt()
|
|
||||||
{
|
|
||||||
"$@" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
mywhich() {
|
|
||||||
local dir
|
|
||||||
|
|
||||||
for dir in $(split $PATH); do
|
|
||||||
if [ -x $dir/$1 ]; then
|
|
||||||
echo $dir/$1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
|
|
||||||
cant_autostart()
|
cant_autostart()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
echo "WARNING: Unable to configure shorewall to start automatically at boot" >&2
|
echo "WARNING: Unable to configure shorewall to start automatically at boot" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_file() # $1 = file to delete
|
|
||||||
{
|
|
||||||
rm -f $1
|
|
||||||
}
|
|
||||||
|
|
||||||
install_file() # $1 = source $2 = target $3 = mode
|
install_file() # $1 = source $2 = target $3 = mode
|
||||||
{
|
{
|
||||||
if cp -f $1 $2; then
|
if cp -f $1 $2; then
|
||||||
@ -98,16 +60,16 @@ install_file() # $1 = source $2 = target $3 = mode
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
require()
|
|
||||||
{
|
|
||||||
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Change to the directory containing this script
|
# Change to the directory containing this script
|
||||||
#
|
#
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source common functions
|
||||||
|
#
|
||||||
|
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse the run line
|
# Parse the run line
|
||||||
#
|
#
|
||||||
|
@ -41,38 +41,6 @@ usage() # $1 = exit status
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error()
|
|
||||||
{
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
split() {
|
|
||||||
local ifs
|
|
||||||
ifs=$IFS
|
|
||||||
IFS=:
|
|
||||||
set -- $1
|
|
||||||
echo $*
|
|
||||||
IFS=$ifs
|
|
||||||
}
|
|
||||||
|
|
||||||
qt()
|
|
||||||
{
|
|
||||||
"$@" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
mywhich() {
|
|
||||||
local dir
|
|
||||||
|
|
||||||
for dir in $(split $PATH); do
|
|
||||||
if [ -x $dir/$1 ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
|
|
||||||
cant_autostart()
|
cant_autostart()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
@ -97,23 +65,16 @@ install_file() # $1 = source $2 = target $3 = mode
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
make_directory() # $1 = directory , $2 = mode
|
|
||||||
{
|
|
||||||
mkdir -p $1
|
|
||||||
chmod 0755 $1
|
|
||||||
[ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1
|
|
||||||
}
|
|
||||||
|
|
||||||
require()
|
|
||||||
{
|
|
||||||
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Change to the directory containing this script
|
# Change to the directory containing this script
|
||||||
#
|
#
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source common functions
|
||||||
|
#
|
||||||
|
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse the run line
|
# Parse the run line
|
||||||
#
|
#
|
||||||
|
@ -34,50 +34,12 @@ usage() # $1 = exit status
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error()
|
|
||||||
{
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
split() {
|
|
||||||
local ifs
|
|
||||||
ifs=$IFS
|
|
||||||
IFS=:
|
|
||||||
set -- $1
|
|
||||||
echo $*
|
|
||||||
IFS=$ifs
|
|
||||||
}
|
|
||||||
|
|
||||||
qt()
|
|
||||||
{
|
|
||||||
"$@" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
mywhich() {
|
|
||||||
local dir
|
|
||||||
|
|
||||||
for dir in $(split $PATH); do
|
|
||||||
if [ -x $dir/$1 ]; then
|
|
||||||
echo $dir/$1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
|
|
||||||
cant_autostart()
|
cant_autostart()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
echo "WARNING: Unable to configure $Product to start automatically at boot" >&2
|
echo "WARNING: Unable to configure $Product to start automatically at boot" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_file() # $1 = file to delete
|
|
||||||
{
|
|
||||||
rm -f $1
|
|
||||||
}
|
|
||||||
|
|
||||||
install_file() # $1 = source $2 = target $3 = mode
|
install_file() # $1 = source $2 = target $3 = mode
|
||||||
{
|
{
|
||||||
if cp -f $1 $2; then
|
if cp -f $1 $2; then
|
||||||
@ -96,19 +58,6 @@ install_file() # $1 = source $2 = target $3 = mode
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
make_directory() # $1 = directory , $2 = mode
|
|
||||||
{
|
|
||||||
mkdir -p $1
|
|
||||||
chmod 755 $1
|
|
||||||
[ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
require()
|
|
||||||
{
|
|
||||||
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Change to the directory containing this script
|
# Change to the directory containing this script
|
||||||
#
|
#
|
||||||
@ -122,6 +71,11 @@ else
|
|||||||
Product="Shorewall6 Lite"
|
Product="Shorewall6 Lite"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source common functions
|
||||||
|
#
|
||||||
|
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse the run line
|
# Parse the run line
|
||||||
#
|
#
|
||||||
|
@ -39,38 +39,6 @@ usage() # $1 = exit status
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error()
|
|
||||||
{
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
split() {
|
|
||||||
local ifs
|
|
||||||
ifs=$IFS
|
|
||||||
IFS=:
|
|
||||||
set -- $1
|
|
||||||
echo $*
|
|
||||||
IFS=$ifs
|
|
||||||
}
|
|
||||||
|
|
||||||
qt()
|
|
||||||
{
|
|
||||||
"$@" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
mywhich() {
|
|
||||||
local dir
|
|
||||||
|
|
||||||
for dir in $(split $PATH); do
|
|
||||||
if [ -x $dir/$1 ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
|
|
||||||
run_install()
|
run_install()
|
||||||
{
|
{
|
||||||
if ! install $*; then
|
if ! install $*; then
|
||||||
@ -86,21 +54,11 @@ cant_autostart()
|
|||||||
echo "WARNING: Unable to configure $PRODUCT to start automatically at boot" >&2
|
echo "WARNING: Unable to configure $PRODUCT to start automatically at boot" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_file() # $1 = file to delete
|
|
||||||
{
|
|
||||||
rm -f $1
|
|
||||||
}
|
|
||||||
|
|
||||||
install_file() # $1 = source $2 = target $3 = mode
|
install_file() # $1 = source $2 = target $3 = mode
|
||||||
{
|
{
|
||||||
run_install $T $OWNERSHIP -m $3 $1 ${2}
|
run_install $T $OWNERSHIP -m $3 $1 ${2}
|
||||||
}
|
}
|
||||||
|
|
||||||
require()
|
|
||||||
{
|
|
||||||
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
if [ -f shorewall.service ]; then
|
if [ -f shorewall.service ]; then
|
||||||
@ -111,6 +69,11 @@ else
|
|||||||
Product=Shorewall6
|
Product=Shorewall6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source common functions
|
||||||
|
#
|
||||||
|
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse the run line
|
# Parse the run line
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user