Commits

Anonymous committed 75beb80

(hopefully) run entire script per server on ii restart

  • Participants
  • Parent commits 007fcc5

Comments (0)

Files changed (1)

File extras/chat.sh

 while read line; do
 	serv="${line%% *}"
 	nick="${line#* }"
+	commands=
+	while read line; do
+		[ -n "$line" ] || break #stop on empty line
+		commands="$commands;$line"
+	done
 
-	# start ii first, so we don't hang trying to write to the fifo
 	while true; do
+		IFS=";"
+		for line in $commands; do
+			[ -n "$line" ] || continue
+			fifo="${line%% *}"
+			cmd="${line#* }"
+			# wait for the fifo to exist, don't want to make a normal file
+			while ! [ -p "$PREFIX/$serv/$fifo" ]; do sleep 1; done
+			echo "$cmd" > "$PREFIX/$serv/$fifo"
+		done >> "$LOG" 2>&1 & # background so we can start ii
+
 		ii -n "$nick" -s "$serv" -i "$PREFIX" 
 		[ $? -eq 2 ] || break # only restart ii on timeout (not default for ii)
 	done >> "$LOG" 2>&1 &
 
-	while read line; do
-		[ -n "$line" ] || break # stop on empty line
-		fifo="${line%% *}"
-		cmd="${line#* }"
-		echo "$cmd" > "$PREFIX/$serv/$fifo"
-	done
 done < "$SERVERS" >> "$LOG" 2>&1
+
+# vim: set ts=4 sw=4 noexpandtab: