2024年10月23日 星期三

Proxmox VE hookscript 範例

#!/bin/bash
# Exmple hook script for PVE guests (hookscript config option)
# You can set this via pct/qm with
# pct set <vmid> -hookscript <volume-id>
# qm set <vmid> -hookscript <volume-id>
# where <volume-id> has to be an executable file in the snippets folder
# of any storage with directories e.g.:
# qm set 100 -hookscript local:snippets/hookscript.sh
# chmod a+x /var/lib/vz/snippets/hookscript.sh
# $1 vmid
# $2 status

[ "$2" = "pre-start"  ]&& { date +"%Y-%m-%d %H:%M:%S $1 pre-start" >>/tmp/d;exit 0; }
[ "$2" = "post-start" ]&& { date +"%Y-%m-%d %H:%M:%S $1 post-start">>/tmp/d;exit 0; }
[ "$2" = "pre-stop"   ]&& { date +"%Y-%m-%d %H:%M:%S $1 pre-stop"  >>/tmp/d;exit 0; }
[ "$2" = "post-stop"  ]&& { date +"%Y-%m-%d %H:%M:%S $1 post-stop" >>/tmp/d;exit 0; }

exit 0


沒有留言: