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" "$@"
40 info
"penser à faire : vm_hosted git_reset"
44 "$tool"/vm_ssh
$vm_fqdn "$@"
47 mosh
--ssh="$tool/vm_ssh $*" $vm_fqdn
49 rule__ssh_known_hosts_update
() {
51 -o StrictHostKeyChecking
=no \
53 -o HashKnownHosts
=no \
56 rule_key_disk_send
() {
57 gpg
--decrypt var
/sec
/luks
/$vm_fqdn.key.gpg |
58 "$tool"/vm_ssh root@
$vm_fqdn "$@" \
60 -o HostKeyAlias
=init.
$vm_fqdn \
61 tee /lib
/cryptsetup
/passfifo \
>/dev
/null
63 rule_key_disk_backup
() {
64 for part
in root var home
69 cryptsetup luksHeaderBackup \
70 /dev/$vm_lvm_vg/${vm_lvm_lv}_${part} \
71 --header-backup-file "$tmp" \
75 gpg
--encrypt --recipient $USER@ \
76 -o var
/sec
/luks
/${vm_lvm_lv}_
${part}.luks.gpg
85 assert
'test ! "$(hostname --fqdn)" = "$vm_fqdn"' vm_fqdn
86 assert
'test ! "$(hostname --fqdn)" = "$vm_host"' vm_host