2 set -e -f ${DRY_RUN:+-n} -u
4 .
"$tool"/lib
/functions.sh
7 rule_help
() { # SYNTAX: [--hidden]
8 local hidden
; [ ${1:+set} ] || hidden
=set
11 ce script regroupe des règles pour administrer la VM ($vm_fqdn)
12 _depuis_ une machine distante ;
13 il sert à la fois d'outil (aisément bidouillable)
14 et de documentation (préçise).
15 Voir \`$tool/vm_host' pour les règles côté machine hôte ($vm_host).
16 Voir \`$tool/vm_hosted' pour les règles côté VM hébergée ($vm_fqdn).
17 SYNTAX: $0 \$RULE \${RULE}_SYNTAX
19 $(sed -ne "s/^rule_\(${hidden:+[^_]}[^ ]*\) () {\( *#.*\|\)/ \1\2/p" "$tool"/etc/vm.sh "$0")
21 TRACE # affiche les commandes avant leur exécution
22 $(sed -ne 's/^readonly \([^ ][^ =]*\).*}\( *#.*\|\)$/\t$\1\2/p' "$tool"/etc/vm.sh "$0")
26 rule_git_config
() { # DESCRIPTION: configure le .git local pour bien pousser
29 git remote
rm host || true
30 git remote add
host $vm_host:tool
/vm
31 git config
--replace remote.
host.push HEAD
:refs
/remotes
/master
32 git remote
rm hosted || true
33 git remote add hosted root@
$vm_fqdn:tool
/vm
34 git config
--replace remote.hosted.push HEAD
:refs
/remotes
/master
37 rule_git_push
() { # SYNTAX: {host|hosted} $git_push_options
38 local remote
=${1#remote=}; shift
39 GIT_SSH
=.
/vm_ssh git push
-v "$remote" "$@"
43 "$tool"/vm_ssh
$vm_fqdn "$@"
46 mosh
--ssh="$tool/vm_ssh $*" $vm_fqdn
48 rule__ssh_known_hosts_update
() {
50 -o StrictHostKeyChecking
=no \
52 -o HashKnownHosts
=no \
55 rule_key_disk_send
() {
56 gpg
--decrypt var
/sec
/luks
/$vm_fqdn.key.gpg |
57 "$tool"/vm_ssh root@
$vm_fqdn "$@" \
59 -o HostKeyAlias
=init.
$vm_fqdn \
60 tee /lib
/cryptsetup
/passfifo \
>/dev
/null
62 rule_key_disk_backup
() {
63 for part
in root var home
68 cryptsetup luksHeaderBackup \
69 /dev/$vm_lvm_vg/${vm_lvm_lv}_${part} \
70 --header-backup-file "$tmp" \
74 gpg
--encrypt --recipient $USER@ \
75 -o var
/sec
/luks
/${vm_lvm_lv}_
${part}.luks.gpg
84 assert
'test ! "$(hostname --fqdn)" = "$vm_fqdn"' vm_fqdn
85 assert
'test ! "$(hostname --fqdn)" = "$vm_host"' vm_host