2021-08-20 13:16:14 -05:00
|
|
|
#!/usr/bin/env bash
|
2020-04-23 08:55:32 -05:00
|
|
|
|
|
|
|
SUDO=''
|
2020-04-24 09:59:00 -05:00
|
|
|
if [ ! -w "/etc/loolwsd" ]; then
|
|
|
|
if (( $EUID != 0 )); then
|
|
|
|
if hash sudo 2>/dev/null; then
|
|
|
|
SUDO='sudo'
|
|
|
|
else
|
|
|
|
echo "Run the script as root."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-23 08:55:32 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /etc/loolwsd/proof_key ]; then
|
|
|
|
echo "/etc/loolwsd/proof_key exists already."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if hash ssh-keygen 2>/dev/null; then
|
|
|
|
$SUDO ssh-keygen -t rsa -N "" -m PEM -f /etc/loolwsd/proof_key
|
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
if id -u lool >/dev/null 2>&1; then
|
|
|
|
$SUDO chown lool: /etc/loolwsd/proof_key
|
|
|
|
else
|
|
|
|
echo "User lool does not exist. Please reinstall loolwsd package, or in case of manual installation from source, create the lool user manually."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "ssh-keygen command not found. Please install openssh client tools."
|
|
|
|
exit 127
|
|
|
|
fi
|
|
|
|
|