Browse Source

environment variable EMAIL

main
pvincent 9 months ago
parent
commit
493ddabc88
  1. 18
      lib/install.sh

18
lib/install.sh

@ -28,7 +28,7 @@ function prepare_lxd {
sudo groupadd --force "$NEW_GROUP" sudo groupadd --force "$NEW_GROUP"
sudo usermod --append --groups "$NEW_GROUP" "$(whoami)" sudo usermod --append --groups "$NEW_GROUP" "$(whoami)"
sg "$NEW_GROUP" -c "$0 SESSION_RELOAD_REQUIRED $TARGET $@"
sg "$NEW_GROUP" -c "env EMAIL=$valid_email $0 SESSION_RELOAD_REQUIRED $TARGET"
sg "$NEW_GROUP" -c bash sg "$NEW_GROUP" -c bash
kill -9 "$PPID" kill -9 "$PPID"
# no further processing because exec has been called! # no further processing because exec has been called!
@ -41,7 +41,7 @@ function prepare_lxd {
override_lxd_service override_lxd_service
# test lxdbr0
# test lxdbr0 FIXME: preseed too much repetitions!!!!
if ! lxc network info lxdbr0 &>/dev/null; then if ! lxc network info lxdbr0 &>/dev/null; then
echo "bridge <lxdbr0> down, so initialization will use default preseed..." echo "bridge <lxdbr0> down, so initialization will use default preseed..."
@ -132,6 +132,11 @@ networks:
config: config:
ipv4.address: auto ipv4.address: auto
ipv6.address: none ipv6.address: none
storage_pools:
- config: {}
description: ""
name: default
driver: dir
profiles: profiles:
- config: {} - config: {}
description: "" description: ""
@ -385,6 +390,9 @@ EOF
function ask_for_email { function ask_for_email {
local PREFIX="install:ask_for_email" local PREFIX="install:ask_for_email"
valid_email=$(auto_detect_email) valid_email=$(auto_detect_email)
echo "valid_email=$valid_email" && exit 1
while ! is_email_valid "$valid_email"; do while ! is_email_valid "$valid_email"; do
echo -n "mandatory email: " echo -n "mandatory email: "
read -rei "$valid_email" valid_email read -rei "$valid_email" valid_email
@ -410,13 +418,15 @@ function is_email_valid {
} }
function auto_detect_email { function auto_detect_email {
found_email=""
found_email="${EMAIL:-}"
if ! is_email_valid "$found_email"; then
if [[ -f $HOME/.ssh/authorized_keys ]]; then if [[ -f $HOME/.ssh/authorized_keys ]]; then
while IFS= read -r line; do while IFS= read -r line; do
found_email="$line" found_email="$line"
is_email_valid "$found_email" && break is_email_valid "$found_email" && break
done < <(cut -d ' ' -f3 <"$HOME/.ssh/authorized_keys") done < <(cut -d ' ' -f3 <"$HOME/.ssh/authorized_keys")
fi fi
fi
builtin echo "$found_email" builtin echo "$found_email"
} }
@ -458,7 +468,7 @@ else
# prepare_toolbox # prepare_toolbox
# add_toolbox_sudoers # add_toolbox_sudoers
prepare_nftables prepare_nftables
prepare_lxd $@
prepare_lxd
preload_bookworm_image preload_bookworm_image
miaou_resolver miaou_resolver
miaou_evalfrombashrc miaou_evalfrombashrc

Loading…
Cancel
Save