仰望星辰工作室

miaopanel

miaopanel/ scripts/check-audit.sh 857 B · 17 行 原始文件
1#!/usr/bin/env bash
2# Read-only: recent audit entries around site deletion.
3set -uo pipefail
4ENTRY="${1:-ipdduiyy}"
5BASE="http://127.0.0.1:8888/$ENTRY"
6PASS=$(awk -F': ' '/^password:/{print $2}' /www/server/panel/data/initial_password.txt)
7
8curl -s -c /tmp/ck.txt -H 'Content-Type: application/json' -H 'Origin: http://127.0.0.1:8888' \
9 -d "{\"username\":\"admin\",\"password\":\"$PASS\"}" "$BASE/api/v1/auth/login" >/dev/null
10curl -s -b /tmp/ck.txt "$BASE/api/v1/system/audit?limit=60" | python3 -c "
11import json, sys, datetime
12rows = json.load(sys.stdin)['data']
13for r in rows:
14 if r['module'] == 'site' or r['action'] in ('delete','create'):
15 ts = datetime.datetime.fromtimestamp(r['created_at']).strftime('%m-%d %H:%M:%S')
16 print('%s %-15s %-9s %-8s %-14s %s' % (ts, r['username'], r['module'], r['action'], r['target'], r['ip']))
17"