Browse Source

Create change-password trigger (#429)

Co-authored-by: Luke Childs <lukechilds123@gmail.com>
tor-0.4.4.7
Aaron Dewes 4 years ago
committed by GitHub
parent
commit
8416b3feb7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      events/triggers/change-password
  2. 4
      karen
  3. 35
      scripts/umbrel-os/change-password
  4. 1
      statuses/password

5
events/triggers/change-password

@ -0,0 +1,5 @@
#!/usr/bin/env bash
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)"
"${UMBREL_ROOT}/scripts/umbrel-os/change-password"

4
karen

@ -63,6 +63,10 @@ fswatch -0 --event=PlatformSpecific $signal_dir | while read -d "" event; do
args="${signal#$app_prefix}"
fi
if [[ "$signal" == "passwd-changed" ]]; then
args="$root_dir/../statuses/password-updated"
fi
if test -x "$trigger"; then
echo "karen is getting triggered!"
"$trigger" $args &

35
scripts/umbrel-os/change-password

@ -0,0 +1,35 @@
#!/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}"

1
statuses/password

@ -0,0 +1 @@
false
Loading…
Cancel
Save