#!/bin/ash

#find /root -type f > /root/files
#for dir in $(ls /); do
#	# we ignore root because we use it to prime the file above
#	if [[ "$dir" != "proc" ]] && \
#		[[ "$dir" != "dev" ]] && \
#		[[ "$dir" != "sys" ]] && \
#		[[ "$dir" != "run" ]] && \
#		[[ "$dir" != "tmp" ]] && \
#		[[ "$dir" != "root" ]]; then
#		find /$dir -type f >> /root/files
#	fi
#done
#exit

sleep 12

find / -type f > /root/files

sleep 3

file=$(shuf -n 1 /root/files)

echo "$(date) deleting $file" | tee -a /root/did

curl -X POST -H "x-api-key: REDACTED" -H "Content-Type: application/json" \
	"https://feeling.nyble.dev/amble.quest/memoryleak" \
	-d "{\"status\": \"Deleting \`$file\`. Did I need that?\", \"visibility\": \"unlisted\", \"content_type\": \"text/markdown\"}"

rm -rf $file
sleep 5
poweroff