f07ff8c7e0
Signed-off-by: Andras Timar <andras.timar@collabora.com> Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
34 lines
862 B
Bash
Executable file
34 lines
862 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
SUDO=''
|
|
if [ ! -w "/etc/coolwsd" ]; then
|
|
if (( $EUID != 0 )); then
|
|
if hash sudo 2>/dev/null; then
|
|
SUDO='sudo'
|
|
else
|
|
echo "Run the script as root."
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ -f /etc/coolwsd/proof_key ]; then
|
|
echo "/etc/coolwsd/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/coolwsd/proof_key
|
|
if [ $? -ne 0 ] ; then
|
|
exit $?
|
|
fi
|
|
if id -u cool >/dev/null 2>&1; then
|
|
$SUDO chown cool: /etc/coolwsd/proof_key
|
|
else
|
|
echo "User cool does not exist. Please reinstall coolwsd package, or in case of manual installation from source, create the cool user manually."
|
|
fi
|
|
else
|
|
echo "ssh-keygen command not found. Please install openssh client tools."
|
|
exit 127
|
|
fi
|
|
|