config is in zentyal-core 2.3.4.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | #!/bin/bash
set -e
. /usr/share/debconf/confmodule
# This will be replaced with debian/zentyal-core.scripts-common which includes
# helper functions to set the password
PORT=443
# This function uses the eBox API to fetch the configured apache port used
# by eBox
#
# Usage: port=$(fetch_ebox_port)
fetch_ebox_port()
{
set +e
ret=$(perl -e '
use EBox;
use EBox::Global;
EBox::init();
my $apache = EBox::Global->modInstance('apache');
print $apache->port();
exit 0;
' 2> /dev/null );
if [ $? -eq 0 ]; then
PORT=$ret;
fi
set -e
}
# This function is used to try guess if a given port is available. It tries
# to connect to the port. Note that it does not distinguish if the port
# is being already used by eBox.
#
# Usage: check_port_available port_number
check_port_available()
{
check_port=$1
set +e
perl -e '
use IO::Socket;
my $port = $ARGV[0];
IO::Socket::INET->new(
PeerAddr => "127.0.0.1",
PeerPort => $port,
Proto => "tcp",
Timeout => 5) or exit 0;
exit 1;
' $check_port 2> /dev/null;
ret=$?
set -e
return $ret;
}
# This function uses the eBox API to set the apache port to be used by eBox.
#
# In case the current port and the new port are the same it returns without
# modifying the current value.
#
# We have to do two things to set the port:
#
# Tell apache module its new port
# Save changes in apache and services
#
# Usage: set_ebox_port new_port
set_ebox_port()
{
db_get zentyal-core/port
new_port=$RET
fetch_ebox_port;
if [ $new_port -eq $PORT ]; then
return 0;
fi
set +e
ret=$(perl -e '
use EBox;
use EBox::Global;
EBox::init();
my $port = $ARGV[0];
my $global = EBox::Global->getInstance();
my $apache = $global->modInstance('apache');
$apache->setPort($port);
$apache->saveConfig();
if ($global->modExists('services')) {
$global->modInstance('services')->saveConfig();
}
' $new_port);
set -e
}
# ask zentyal port
conf_port() {
while true; do
db_input high zentyal-core/port || true
db_go || true
db_get zentyal-core/port
new_port="$RET"
# check if the entry is valid port number
nodigits="$(echo $new_port | sed 's/[[:digit:]]//g')"
if [ -n "$nodigits" ]; then
continue
fi
if [ $new_port -ge 65535 ] || [ $new_port -lt 1 ]; then
continue;
fi
if ! check_port_available $new_port; then
db_input high zentyal-core/port_used || true
db_go || true
db_get zentyal-core/port_used
if [ "$RET" = "true" ]; then
break;
fi
else
break;
fi
done
}
# check non-existance of ebox user as a normal user
EBOX_UID=`getent passwd ebox | cut -d: -f3`
if [ -n "$EBOX_UID" ] && [ $EBOX_UID -ge 1000 ]
then
db_input high zentyal-core/user_exists || true
db_go || true
exit 1
fi
if [ "$1" = reconfigure ] || [ -z "$2" ]; then
conf_port
fi
exit 0
|