Setelah boot dan konek ke network, Raspberry Pi akan otomatis kirim notifikasi IP address ke Google Chat via webhook. Script berjalan sekali lalu menghapus dirinya sendiri. Jangan lupa masukkan WEBHOOK url dari Google Chat ke dalam script!
- Debian GNU/Linux 13 (Trixie)
- SD card yang bisa dibaca dari Mac/Windows
- Google Chat webhook URL
Buat file ini di root boot partition SD card (/Volumes/bootfs/ di Mac):
#!/bin/bash
WEBHOOK=""
# Tunggu sampai dapat IP (max ~60 detik)
for i in $(seq 1 12); do
IP=$(hostname -I | awk '{print $1}')
if [ -n "$IP" ]; then
break
fi
sleep 5
done
HOSTNAME=$(hostname)
curl -s -X POST "$WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"text\": \"🍓 *Raspberry Pi Online!*\nHostname: \`$HOSTNAME\`\nIP Address: \`$IP\`\"}"
# Cleanup: hapus entry dari cmdline.txt dan hapus script ini
mount -o remount,rw /boot
sed -i 's/ systemd.run=\/boot\/notify-ip.sh//' /boot/cmdline.txt
rm -- "$0"Buka cmdline.txt di boot partition, tambahkan systemd.run=/boot/firmware/notify-ip.sh di akhir baris (jangan buat baris baru).
Contoh sebelum:
console=serial0,115200 console=tty1 root=PARTUUID=ffc763c1-02 rootfstype=ext4 fsck.repair=yes rootwait
Contoh sesudah:
console=serial0,115200 console=tty1 root=PARTUUID=ffc763c1-02 rootfstype=ext4 fsck.repair=yes rootwait systemd.run=/boot/firmware/notify-ip.sh
Kalau belum, buat file kosong bernama ssh di boot partition:
touch /Volumes/bootfs/sshPasang SD card dan nyalakan. Dalam beberapa detik setelah konek ke network, notifikasi akan masuk ke Google Chat berisi hostname dan IP address.
Setelah berhasil, script dan entry di cmdline.txt akan terhapus otomatis.
Kalau notifikasi tidak masuk, cek via SSH:
# Cek apakah systemd.run terpanggil
sudo journalctl -b | grep systemd.run
# Coba jalanin script manual
sudo bash /boot/notify-ip.sh- Path boot partition:
/boot/(untuk Debian Trixie). Kalau pakai Raspberry Pi OS Bookworm, ganti semua/boot/menjadi/boot/firmware/. cmdline.txtharus satu baris, tanpa newline — ini penting, kalau ada baris baru systemd tidak akan baca parameter dengan benar.