create_http_server.sh 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. if [ $# -lt 3 ]
  3. then
  4. echo "<Usage: $0 App Server Servant>"
  5. exit 0
  6. fi
  7. APP=$1
  8. SERVER=$2
  9. SERVANT=$3
  10. TARSPATH=$4
  11. if [ "$TARSPATH" == "" ]; then
  12. TARSPATH=/usr/local/tars/
  13. fi
  14. if [ "$SERVER" == "$SERVANT" ]
  15. then
  16. echo "Error!(ServerName == ServantName)"
  17. exit -1
  18. fi
  19. if [ ! -d $APP/$SERVER ]
  20. then
  21. echo "[mkdir: $APP/$SERVER]"
  22. mkdir -p $APP/$SERVER
  23. fi
  24. echo "[create server: $APP.$SERVER ...]"
  25. DEMO_PATH=${TARSPATH}/cpp/script/http_demo
  26. cp $DEMO_PATH/* $APP/$SERVER/
  27. cd $APP/$SERVER/
  28. SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp makefile"
  29. for FILE in $SRC_FILE
  30. do
  31. cat $FILE | sed "s/DemoServer/$SERVER/g" > $FILE.tmp
  32. mv $FILE.tmp $FILE
  33. cat $FILE | sed "s/DemoApp/$APP/g" > $FILE.tmp
  34. mv $FILE.tmp $FILE
  35. cat $FILE | sed "s/DemoServant/$SERVANT/g" > $FILE.tmp
  36. mv $FILE.tmp $FILE
  37. done
  38. rename "DemoServer" "$SERVER" $SRC_FILE
  39. rename "DemoServant" "$SERVANT" $SRC_FILE
  40. cd ../../
  41. echo "[done.]"