Skip to content

Instantly share code, notes, and snippets.

@legionus
Created October 11, 2021 13:52
Show Gist options
  • Save legionus/4d752c77f756e8295d397d4d419e5f60 to your computer and use it in GitHub Desktop.
Save legionus/4d752c77f756e8295d397d4d419e5f60 to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
case "${1:-0}" in
0)
i=1
while :; do
echo TRY $i
i=$(($i+1))
mkdir /tmp/lock
/usr/bin/unshare --kill-child --ipc --mount --net --pid --uts --uts --cgroup --mount-proc --fork --map-root "$0" "1.0" &
while test -d /tmp/lock; do sleep 0.1; done
killall -9 sleep
wait
ps axf
done
;;
1.*.*)
sleep 3 ||:
;;
1.*)
for i in 0 1 2 3 4 5 6 7 8 9; do
/usr/bin/unshare --kill-child --ipc --mount --net --pid --uts --uts --cgroup --mount-proc --fork --map-current-user "$0" "$1.$i" &
done
sleep 1
rmdir /tmp/lock
wait
;;
esac
# vim: tw=200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment