sample
o=${1^^}
ocid="ocid1.instance.oc1.ap-tokyo-1.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
function get_status(){
s=`oci compute instance get --instance-id ${ocid}| jq -r '.data."lifecycle-state" '`
echo $s
}
function start_instance(){
oci compute instance action --action start --instance-id ${ocid}
}
function stop_instance(){
oci compute instance action --action stop --instance-id ${ocid}
}
if [ ${o} == "STATUS" ]; then
get_status
elif [ ${o} == "START" ]; then
start_instance
elif [ ${o} == "STOP" ]; then
stop_instance
else
echo "Usage: $0 [STATUS|START|STOP]"
fi
参考
action — OCI CLI Command Reference 3.10.5 documentation