You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.5 KiB

  1. # deploy.sh in gogits image, replace the configs and run gogs
  2. ## Replace the database password
  3. DB_TYPE=THE_DB_TYPE
  4. DB_PASSWORD=THE_DB_PASSWORD
  5. DB_ALIAS=DB
  6. MEM_TYPE=THE_MEM_TYPE
  7. DB_TYPE_LINE=`awk '$0 ~ str{print NR}' str="DB_TYPE = mysql" $GOPATH/src/github.com/gogits/gogs/conf/app.ini`
  8. DB_PASSWORD_LINE=`awk '$0 ~ str{print NR+1}' str="USER = root" $GOPATH/src/github.com/gogits/gogs/conf/app.ini`
  9. sed -i "${DB_TYPE_LINE}s/.*$/DB_TYPE = $DB_TYPE/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  10. sed -i "${DB_PASSWORD_LINE}s/.*$/PASSWD = $DB_PASSWORD/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  11. if [ $MEM_TYPE != "" ]
  12. then
  13. MEM_HOST_LINE=`awk '$0 ~ str{print NR+6}' str="ADAPTER = memory" $GOPATH/src/github.com/gogits/gogs/conf/app.ini`
  14. _MEM_ADDR=`echo $MEM_PORT | cut -d '/' -f 3 | cut -d ':' -f 1`
  15. _MEM_PORT=`echo $MEM_PORT | cut -d '/' -f 3 | cut -d ':' -f 2`
  16. # take advantage of memory db for adapter and provider
  17. sed -i "s/ADAPTER = memory/ADAPTER = $MEM_TYPE/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  18. # Comment the memory interval since we don't use 'memory' as adapter
  19. sed -i "s/INTERVAL = 60/;INTERVAL = 60/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  20. case $MEM_TYPE in
  21. "redis")
  22. # Modify the adapter host
  23. sed -i "${MEM_HOST_LINE}s/.*/HOST = $_MEM_ADDR:$_MEM_PORT/" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  24. sed -i "s/PROVIDER = file/PROVIDER = $MEM_TYPE/g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  25. # Modify the provider config
  26. sed -i "s#PROVIDER_CONFIG = data/sessions#PROVIDER_CONFIG = $_MEM_ADDR:$_MEM_PORT#g" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  27. ;;
  28. "memcache")
  29. # Modify the adapter host
  30. sed -i "${MEM_HOST_LINE}s/.*/HOST = $_MEM_ADDR:$_MEM_PORT/" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  31. ;;
  32. esac
  33. fi
  34. ## Replace the database address and port
  35. # When using --link in docker run, the database image's info looks like this:
  36. # DB_PORT=tcp://172.17.0.2:3306
  37. # DB_PORT_3306_TCP_PORT=3306
  38. # DB_PORT_3306_TCP_PROTO=tcp
  39. # DB_PORT_3306_TCP_ADDR=172.17.0.2
  40. #sed -i "/HOST = 127.0.0.1:3306/c\HOST = $DB_PORT_3306_TCP_ADDR:$DB_PORT_3306_TCP_PORT" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  41. sed -i "/HOST = 127.0.0.1:3306/c\HOST = `echo $DB_PORT | cut -d '/' -f 3`" $GOPATH/src/github.com/gogits/gogs/conf/app.ini
  42. cd $GOPATH/src/github.com/gogits/gogs/
  43. # The sudo is a must here, or the go within docker container won't get the current user by os.Getenv("USERNAME")
  44. sudo ./gogs web