You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
816 B

#!/usr/bin/env bash
set -euo pipefail
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)"
PASSWORD_FILE="${UMBREL_ROOT}/statuses/password"
check_root () {
if [[ $UID != 0 ]]; then
echo "This script must be run as root"
exit 1
fi
}
check_umbrel_os () {
[[ -f "/etc/default/umbrel" ]] && source "/etc/default/umbrel"
if [[ -z "${UMBREL_OS:-}" ]]; then
echo "This script must only be run on Umbrel OS"
exit 1
fi
}
password="$(cat ${PASSWORD_FILE})"
echo "false" > "${PASSWORD_FILE}"
check_root
check_umbrel_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 umbrel
echo "true" > "${PASSWORD_FILE}"