All pastes #257724 Raw Edit

Unnamed

public shellscript v1 · immutable
#257724 ·published 2006-11-25 18:08 UTC
rendered paste body
#!/bin/bash# proj3.shUSAGE="Usage: $0 [-h] -[ s confdir | c ]"function server {	progname="${0%\.*}"		#deal with the PID file	if [ -e "$progname.pid" ]; then		echo "$progname is already running." >&2		exit 1	else		echo $$ > "$progname.pid"	fi		#bring values from conffile into current context	source $progname.conf		#ok here it's time to trap signals	trap "echo $( pwd ) > $TTY" INT	trap "echo $( pwd ) > $TTY" USR1	trap "" USR2		trap -p > $TTY		while true; do		sleep 1;	done}while getopts "hs:c" opt; do	case $opt in		s) #servertime			if [ -t 0 ]; then				export TTY=$(tty)				exec $0 $@ <&- >&- &			else				server $OPTARG			fi			printf "";;		c) #clienttime			client;;		h|*) echo $USAGE >&2; exit 1;;	esacdoneif [[ -z "$@" ]]; then	echo $USAGE >&2	exit 1fishift $((OPTIND - 1))