HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/doc/tin/tools/tinlock
#! /bin/sh
# wrapper to prevent running multiple instances of tin
# 2000-01-19 <urs@tin.org>

prog=/usr/local/bin/tin

args=${1+"$@"}

name=`basename $prog`
host=`hostname`
pid=$$
lock=$host"	"$pid

if test -d ${TIN_HOMEDIR-"$HOME"} ; then
	lockdir=${TIN_HOMEDIR-"$HOME"}/.tin
	file=tinlock
else
	lockdir=${TMPDIR-/tmp}
	if test -z $USER; then
		if test -z $UID ; then
			UID=`id|sed 's,uid=\([0-9]\+\).*,\1,'`
		fi
	fi
	file=tinlock.${USER-"$UID"}
fi

lockfile=$lockdir/$file

if test -f $lockfile ; then
	echo "Found \"$lockfile\"! Another $name running on:"
	awk '{print $1" with pid: "$2"?"}' < $lockfile
	echo "(q)uit - start (r)ead-only - (d)elete lock and start normal."
	IFS="       " read key
	case $key in
		[dD]*)
			echo "Removing \"$lockfile\" and starting $name normal..."
			rm -f $lockfile || (echo "Can't delete \"$lockfile\"" ; exit 1)
			trap "rm -f $lockfile; exit" 0 1 2 3 15
			(echo $lock > $lockfile && $prog $args && rm -f $lockfile) || echo "Oops!"
			;;
		[rR]*)
			echo "Starting $name in no-write (-X) mode..."
			$prog -X $args
			echo "There might still be copy(s) of $name running on:"
			awk '{print $1" with pid: "$2}' < $lockfile
			echo "If this is not the case remember to remove \"$lockfile\"."
			;;
		*)
			echo "Aborting..."
			exit 1
			;;
	esac
else
	trap "rm -f $lockfile; exit" 0 1 2 3 15
	(echo $lock > $lockfile && $prog $args && rm -f $lockfile) || echo "Oops!"
fi