|
|
@ -47,13 +47,38 @@ function prepare_lxd { |
|
|
|
|
|
|
|
echo "bridge <lxdbr0> down, so initialization will use default preseed..." |
|
|
|
|
|
|
|
empty_block_partition='' |
|
|
|
if lsblk -o NAME,FSTYPE,GROUP --noheadings -p | grep -E ^.─ | grep disk; then |
|
|
|
# FIXME: when nesting no DISK type partition found! |
|
|
|
if [[ $(printenv container) == 'lxc' ]]; then |
|
|
|
echo "nested configuration applying..." |
|
|
|
cat <<EOF | lxd init --preseed |
|
|
|
config: {} |
|
|
|
networks: |
|
|
|
- name: lxdbr0 |
|
|
|
type: bridge |
|
|
|
config: |
|
|
|
ipv4.address: auto |
|
|
|
ipv6.address: none |
|
|
|
profiles: |
|
|
|
- config: |
|
|
|
security.privileged: "true" |
|
|
|
description: "" |
|
|
|
devices: |
|
|
|
eth0: |
|
|
|
name: eth0 |
|
|
|
nictype: bridged |
|
|
|
parent: lxdbr0 |
|
|
|
type: nic |
|
|
|
root: |
|
|
|
path: / |
|
|
|
pool: default |
|
|
|
type: disk |
|
|
|
name: default |
|
|
|
projects: [] |
|
|
|
cluster: null |
|
|
|
EOF |
|
|
|
else |
|
|
|
empty_block_partition=$(lsblk -o NAME,FSTYPE,GROUP --noheadings -p | grep -E ^.─ | grep disk | awk '{if($3=="") print $1}' | cut -d'/' -f3) |
|
|
|
fi |
|
|
|
if [[ -n "$empty_block_partition" ]]; then |
|
|
|
echo "use empty block partition /dev/$empty_block_partition" |
|
|
|
echo "use empty block partition /dev/$empty_block_partition for speed and optimization" |
|
|
|
cat <<EOF | sudo lxd init --preseed |
|
|
|
config: {} |
|
|
|
networks: |
|
|
@ -88,7 +113,7 @@ cluster: null |
|
|
|
EOF |
|
|
|
echo OK |
|
|
|
else |
|
|
|
echo "use dir partition" |
|
|
|
echo "use dir partition for development purpose" |
|
|
|
cat <<EOF | lxd init --preseed |
|
|
|
config: {} |
|
|
|
networks: |
|
|
@ -99,12 +124,13 @@ networks: |
|
|
|
ipv6.address: none |
|
|
|
EOF |
|
|
|
fi |
|
|
|
fi |
|
|
|
else |
|
|
|
echo "bridge <lxdbr0> found implies it has been already initialized!" |
|
|
|
fi |
|
|
|
|
|
|
|
set_alias 'sameuser' "exec @ARG1@ -- su --whitelist-environment container_hostname - $(whoami)" |
|
|
|
set_alias 'login' 'exec @ARGS@ --mode interactive -- /bin/bash -c $@${user:-root} - exec su --whitelist-environment container_hostname - ' |
|
|
|
set_alias 'sameuser' "exec @ARG1@ -- su --whitelist-environment container,container_hostname - $(whoami)" |
|
|
|
set_alias 'login' 'exec @ARGS@ --mode interactive -- /bin/bash -c $@${user:-root} - exec su --whitelist-environment container,container_hostname - ' |
|
|
|
set_alias 'll' 'list -c ns4mDN' |
|
|
|
|
|
|
|
# test environment container hostname |
|
|
@ -194,8 +220,7 @@ function check_credential { |
|
|
|
|
|
|
|
check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.username' && |
|
|
|
check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.shadow' && |
|
|
|
check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.email' && |
|
|
|
check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.password' |
|
|
|
check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.email' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|