Mercurial > index.cgi > dotfiles
comparison .bash_aliases @ 268:48b4f41712dc
Suppress warnings in lsof, change filetype bash -> sh
author | Steve Huston <huston@princeton.edu> |
---|---|
date | Thu, 25 Apr 2024 10:50:06 -0400 |
parents | df0b24d4fabd |
children | 02a3d7c46b2b |
comparison
equal
deleted
inserted
replaced
267:857bf32fbaab | 268:48b4f41712dc |
---|---|
66 fi | 66 fi |
67 | 67 |
68 # Let's check if things exist and we can just use them as-is | 68 # Let's check if things exist and we can just use them as-is |
69 if [ -e $PIDFILE ]; then | 69 if [ -e $PIDFILE ]; then |
70 DOTSHARE_PID=`cat $PIDFILE` | 70 DOTSHARE_PID=`cat $PIDFILE` |
71 DOTSHARE_PORT=`lsof -n -p $DOTSHARE_PID | grep LISTEN | awk '{print $9}' | sed 's/.*://'` | 71 DOTSHARE_PORT=`lsof -w -n -p $DOTSHARE_PID | grep LISTEN | awk '{print $9}' | sed 's/.*://'` |
72 if [ -z $DOTSHARE_PORT ]; then | 72 if [ -z $DOTSHARE_PORT ]; then |
73 echo "Server PIDfile found but couldn't get a port, aborting" | 73 echo "Server PIDfile found but couldn't get a port, aborting" |
74 return 255 | 74 return 255 |
75 fi | 75 fi |
76 echo "Existing server ${DOTSHARE_PID} listening on ${DOTSHARE_PORT}, setting environment" | 76 echo "Existing server ${DOTSHARE_PID} listening on ${DOTSHARE_PORT}, setting environment" |
107 disown %+ | 107 disown %+ |
108 | 108 |
109 # Give it a moment to collect its thoughts... | 109 # Give it a moment to collect its thoughts... |
110 sleep 1 | 110 sleep 1 |
111 DOTSHARE_PID=`cat $PIDFILE` | 111 DOTSHARE_PID=`cat $PIDFILE` |
112 DOTSHARE_PORT=`lsof -n -p $DOTSHARE_PID | grep LISTEN | awk '{print $9}' | sed 's/.*://'` | 112 DOTSHARE_PORT=`lsof -w -n -p $DOTSHARE_PID | grep LISTEN | awk '{print $9}' | sed 's/.*://'` |
113 echo "Server PID $DOTSHARE_PID ready on port $DOTSHARE_PORT" | 113 echo "Server PID $DOTSHARE_PID ready on port $DOTSHARE_PORT" |
114 export DOTSHARE_PID DOTSHARE_PORT | 114 export DOTSHARE_PID DOTSHARE_PORT |
115 } | 115 } |
116 | 116 |
117 # | 117 # |
284 kill `cat $ROOT/.hg/hgserve-PID` | 284 kill `cat $ROOT/.hg/hgserve-PID` |
285 rm $ROOT/.hg/hgserve-PID | 285 rm $ROOT/.hg/hgserve-PID |
286 else | 286 else |
287 if [ -e $ROOT/.hg/hgserve-PID ] ; then | 287 if [ -e $ROOT/.hg/hgserve-PID ] ; then |
288 P=`cat $ROOT/.hg/hgserve-PID` | 288 P=`cat $ROOT/.hg/hgserve-PID` |
289 URL=`lsof -n -p $P | grep LISTEN | awk '{print $9}'` | 289 URL=`lsof -w -n -p $P | grep LISTEN | awk '{print $9}'` |
290 else | 290 else |
291 URL=`hg serve -d -p 0 --pid-file $ROOT/.hg/hgserve-PID | sed 's#.*at http://\(.*\)/ (bound.*#\1#'` | 291 URL=`hg serve -d -p 0 --pid-file $ROOT/.hg/hgserve-PID | sed 's#.*at http://\(.*\)/ (bound.*#\1#'` |
292 fi | 292 fi |
293 if [ -z "$DARWIN" ] ; then | 293 if [ -z "$DARWIN" ] ; then |
294 echo hg serve on http://$URL/ | 294 echo hg serve on http://$URL/ |
340 done | 340 done |
341 echo "</UL></BODY></HTML>" >> $OUTDIR/index.html | 341 echo "</UL></BODY></HTML>" >> $OUTDIR/index.html |
342 echo Files stored in $OUTDIR | 342 echo Files stored in $OUTDIR |
343 } | 343 } |
344 | 344 |
345 # vim: set filetype=bash : | 345 # vim: set filetype=sh : |