forked from michael.heier/citadel-core
40 lines
933 B
Bash
Executable File
40 lines
933 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# SPDX-FileCopyrightText: 2021-2022 Citadel and contributors
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
set -euo pipefail
|
|
|
|
CITADEL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)"
|
|
PASSWORD_FILE="${CITADEL_ROOT}/statuses/password"
|
|
|
|
check_root () {
|
|
if [[ $UID != 0 ]]; then
|
|
echo "This script must be run as root"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_citadel_os () {
|
|
[[ -f "/etc/default/citadel" ]] && source "/etc/default/citadel"
|
|
if [[ -z "${CITADEL_OS:-}" ]]; then
|
|
echo "This script must only be run on Citadel OS"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
password="$(cat ${PASSWORD_FILE})"
|
|
echo "false" > "${PASSWORD_FILE}"
|
|
|
|
check_root
|
|
check_citadel_os
|
|
|
|
if [[ "${password}" == "" ]] || [[ "${password}" == "false" ]] || [[ "${password}" == "true" ]]; then
|
|
echo "Password not set in status file: \"${PASSWORD_FILE}\""
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${password}\n${password}" | passwd citadel
|
|
echo "true" > "${PASSWORD_FILE}"
|