27 lines
538 B
Plaintext
27 lines
538 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
if ! [ $# -ge 3 ]; then
|
||
|
echo "[ERROR] Not enough arguments."
|
||
|
exit 2
|
||
|
fi
|
||
|
|
||
|
EVENT=$1
|
||
|
USER=$2
|
||
|
FILE=$3
|
||
|
DOMAIN=$(hostname -d)
|
||
|
|
||
|
if ! [[ $USER == "administrator@${DOMAIN}" ]]; then
|
||
|
echo "[NOTICE] Not storing password for user ${USER}."
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
if ! [ -f "${FILE}" ]; then
|
||
|
echo "[ERROR] Password file not found"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
PASSWORD="$(<$FILE)"
|
||
|
touch /var/lib/nethserver/secrets/administrator
|
||
|
chmod 600 /var/lib/nethserver/secrets/administrator
|
||
|
echo -n "${PASSWORD}" > /var/lib/nethserver/secrets/administrator
|