{"body":"#!/bin/sh -eu\nset -o pipefail\n\nmain() {\n\tacquire_lock\n\tdo_stuff\n}\n\nacquire_lock() {\n\tlock=\"/tmp/lock\"\n\t# open lockfile which will be released when script exits\n\texec 9>\"${lock}\"\n\tif ! lockf -s -t 5 9; then\n\t\techo \"failed to acquire lock\"\n\t\texit 1\n\tfi\n}\n\ndo_stuff() {\n\techo -n \"doing...\"\n\tsleep 10\n\techo \"stuff\"\n}\n\nmain","name":"stuff.sh","extension":"sh","url":"https://www.irccloud.com/pastebin/9m8mK5jb/stuff.sh","modified":1774645275,"id":"9m8mK5jb","size":318,"lines":25,"own_paste":false,"theme":"","date":1774645275}