80 lines
1.7 KiB
Bash
Executable File
80 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "*** kerio config generator ***" >&2
|
|
|
|
while true; do
|
|
echo -n "Enter server address: " >&2
|
|
read SERVER < /dev/tty
|
|
echo >&2
|
|
|
|
if [[ -z "$SERVER" ]]; then
|
|
echo "Server address cannot be empty. Try again." >&2
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
while true; do
|
|
echo -n "Enter server fingerprint: " >&2
|
|
read FINGERPRINT < /dev/tty
|
|
echo >&2
|
|
|
|
if [[ -z "$FINGERPRINT" ]]; then
|
|
echo "Server fingerprint cannot be empty. Try again." >&2
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
while true; do
|
|
echo -n "Enter username: " >&2
|
|
read USERNAME < /dev/tty
|
|
echo >&2
|
|
|
|
if [[ -z "$USERNAME" ]]; then
|
|
echo "Username cannot be empty. Try again." >&2
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
while true; do
|
|
echo -n "Enter password: " >&2
|
|
read -s PASSWORD < /dev/tty
|
|
echo >&2
|
|
echo -n "Confirm password: " >&2
|
|
read -s PASSWORDCONF < /dev/tty
|
|
echo >&2
|
|
|
|
if [[ -z "${PASSWORD}" ]]; then
|
|
echo "Password cannot be empty. Try again." >&2
|
|
elif [[ "${PASSWORD}" != "${PASSWORDCONF}" ]]; then
|
|
echo "Passwords do not match. Try again." >&2
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
case "$SERVER" in
|
|
*:*) PORT=`echo $SERVER | sed 's/.*://'`; SERVER=`echo $SERVER | sed 's/:.*//'`;;
|
|
*) PORT=4090;;
|
|
esac
|
|
|
|
XOR=""
|
|
for i in `echo -n "$PASSWORD" | od -t d1 -A n`; do XOR=$(printf "%s%02x" "$XOR" $((i ^ 85))); done
|
|
|
|
cat << EOF
|
|
<config>
|
|
<connections>
|
|
<connection type="persistent">
|
|
<server>${SERVER}</server>
|
|
<port>${PORT}</port>
|
|
<username>${USERNAME}</username>
|
|
<password>XOR:${XOR}</password>
|
|
<fingerprint>${FINGERPRINT}</fingerprint>
|
|
<active>1</active>
|
|
</connection>
|
|
</connections>
|
|
</config>
|
|
EOF
|