ZABBIXの管理パスワードをシェルから変えてみる

ZABBIX_AUTH=`curl -k -d "{\"auth\":null,\"method\":\"user.login\",\"id\":1,\"params\":{\"user\":\"${ZABBIX_USER}\",\"password\":\"${ZABBIX_PASS}\"},\"jsonrpc\":\"2.0\"}" -H "Content-Type: application/json-rpc" ${ZABBIX_URL}/api_jsonrpc.php | sed -e "s/^.*\"result\":\"\([^\"]*\)\".*$/\1/g"`

get_or_create_password ZABBIX_PASS 1> /dev/null
cat << EOM | curl -k -d @- -H "Content-Type: application/json-rpc" ${ZABBIX_URL}/api_jsonrpc.php 
{
    "jsonrpc": "2.0",
    "method": "user.update",
    "params": {
        "userid": "1",
        "lang": "ja_JP",
        "passwd": "${ZABBIX_PASS}"
    },
    "auth": "${ZABBIX_AUTH}",
    "id": 1
}
EOM

curl -k -d "{\"auth\":\"${ZABBIX_AUTH}\",\"method\":\"user.logout\",\"id\":1,\"params\":[],\"jsonrpc\":\"2.0\"}" -H "Content-Type: application/json-rpc" ${ZABBIX_URL}/api_jsonrpc.php