Commits

Evan Gates  committed 05a72d1

add torify option and replace find | grep with proper find commands

  • Participants
  • Parent commits 9f60592

Comments (0)

Files changed (1)

File extras/chat.sh

 which pcw > /dev/null 2>&1 && pcw "$PREFIX" >> "$LOG" 2>&1 &
 
 while read line; do
+	if [ "${line%% *}" = "torify" ]; then
+		TORIFY="torify "
+		line="${line##torify }"
+	else
+		unset TORIFY
+	fi
+
 	args="$line"
 	serv="${line%% *}"
-	commands=
+	unset commands
 	while read line; do
 		[ -n "$line" ] || break #stop on empty line
 		commands="$commands;$line"
 	{
 		echo
 		date
-		echo "ii -i $PREFIX -s $args"
+		echo $TORIFY"ii -i $PREFIX -s $args"
 	} >> "$PREFIX/$serv/log" 2>&1
 
 	while true; do
-		find "$PREFIX/$serv" | grep "in$" | xargs rm # clean stale fifos
+		find "$PREFIX/$serv" -type p -name "in" -exec rm {} + # clean stale fifos
 		# compress old stuff, means fewer lines for cw to rewrite for reflows,
 		# and we still get to keep the old stuff, and it's smaller
-		for f in $(find "$PREFIX/$serv" | grep "out$"); do
+		for f in $(find "$PREFIX/$serv" -type f -name "out" -print); do
 			gzip -c "$f" >> "${f}_old.gz"
 			rm "$f"
 		done
 		done >> "$PREFIX/$serv/log" 2>&1 & # background so we can start ii
 
 		IFS="$oIFS"
-		eval ii -i "$PREFIX" -s $args
+		eval $TORIFY ii -i "$PREFIX" -s $args
 		[ $? -eq 2 ] || break # only restart ii on timeout (not default for ii)
 	done >> "$PREFIX/$serv/log" 2>&1 & # instead of locking the main one...