change password Core

This commit is contained in:
2026-10-30 06:48:02 -06:00
parent a3a980579c
commit 14d2bd4cd5
4 changed files with 161 additions and 7 deletions
+67
View File
@@ -348,6 +348,69 @@ setup_core() {
return $STATUS
}
# Check an app password this computer keeps for the Core
app_password_works() {
local title="$1" app_password="$2"
[ -n "$app_password" ] || return 0
case "$(nextcloud_sign_in "$app_password"; echo $?)" in
0) echo " $title: working" ;;
2) echo -e " \e[31m$title: Nextcloud doesn't accept its app password.\e[0m"
echo " It may have been revoked in Nextcloud under Settings > Security."
return 1 ;;
*) echo " $title: couldn't reach Nextcloud to check" ;;
esac
}
# After your Core password changes, e.g. in Superpanel. Email keeps your Core
# password, so it gets the new one. Nextcloud, files and backups use app
# passwords, which stay the same; Nextcloud turns them off until you sign in
# with the new password, and checking the password here does that.
change_password() {
local tries reached=1
load_core "$1"
STATUS=0
for tries in 1 2 3; do
read -rsp "Your new Core password: " PASSWORD
echo
nextcloud_sign_in
case $? in
0) break ;;
2) echo "Nextcloud says that password is wrong."; PASSWORD="" ;;
*) echo "Couldn't reach Nextcloud at $NEXTCLOUD; trying the password for email anyway."
reached=0; break ;;
esac
done
[ -n "$PASSWORD" ] || return 1
echo
if email_done; then
jq -n --arg password "$PASSWORD" '{"imap-password": $password, "smtp-password": $password}' \
| "$GOA_ACCOUNT" update imap_smtp "$CORE_EMAIL" 2> /dev/null
case $? in
0) echo " Email: has your new password" ;;
3) echo -e " \e[31mEmail: saved your new password, but the mail server didn't accept it.\e[0m"
STATUS=1 ;;
*) echo -e " \e[31mEmail: couldn't save your new password.\e[0m"; STATUS=1 ;;
esac
fi
unset PASSWORD
[ $reached = 1 ] || return 1
if nextcloud_done; then
if "$GOA_ACCOUNT" check owncloud "$CORE_USER@nextcloud.$CORE_DOMAIN" 2> /dev/null; then
echo " Nextcloud in Online Accounts: working"
else
echo -e " \e[31mNextcloud in Online Accounts: can't sign in.\e[0m"
echo " Remove it in Settings > Online Accounts, then run: configure core"
STATUS=1
fi
fi
files_done && { app_password_works "Files at $MOUNT" "$(files_app_password)" || STATUS=1; }
app_password_works "Backups" \
"$(secret-tool lookup coredesktop backup item nextcloud url "$WEBDAV" 2> /dev/null)" || STATUS=1
return $STATUS
}
# Tailscale and Backup point at one Core, which can't be removed while they do
tailscale_on() {
[ "$(source "$TAILSCALE_CONF" 2> /dev/null && echo "$TAILSCALE_DOMAIN")" = "$1" ] \
@@ -473,6 +536,7 @@ run_configure() {
echo " Choose a number to finish or change its setup, or:"
echo " a) Add a Core"
[ ${#DOMAINS[@]} -gt 1 ] && echo " m) Make another Core the main one"
echo " p) Your Core password changed"
echo " r) Remove a Core"
echo " q) Leave it as it is"
echo
@@ -485,6 +549,9 @@ run_configure() {
[ ${#DOMAINS[@]} -gt 1 ] || return 0
pick_core "Which should be the main one?" "$MAIN_DOMAIN" || { echo "Choose a number from the list."; return 1; }
make_main "$PICKED" && main_changed ;;
p|P)
pick_core "Which Core's password changed?" || { echo "Choose a number from the list."; return 1; }
change_password "$PICKED" ;;
r|R)
pick_core "Which Core should be removed?" || { echo "Choose a number from the list."; return 1; }
remove_core "$PICKED" ;;