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.

28 lines
888 B

  1. #!/bin/sh
  2. # Cleanup SOCAT services and s6 event folder
  3. # On start and on shutdown in case container has been killed
  4. rm -rf $(find /app/gogs/docker/s6/ -name 'event')
  5. rm -rf /app/gogs/docker/s6/SOCAT_*
  6. # Create VOLUME subfolder
  7. for f in /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/ssh; do
  8. if ! test -d $f; then
  9. mkdir -p $f
  10. fi
  11. done
  12. # Bind linked docker container to localhost socket using socat
  13. env | sed -En 's|(.*)_PORT_([0-9]*)_TCP=tcp://(.*):(.*)|\1_\2 socat -ls TCP4-LISTEN:\2,fork,reuseaddr TCP4:\3:\4|p' | \
  14. while read NAME CMD; do
  15. mkdir -p /app/gogs/docker/s6/SOCAT_$NAME
  16. echo -e "#!/bin/sh\nexec $CMD" > /app/gogs/docker/s6/SOCAT_$NAME/run
  17. chmod +x /app/gogs/docker/s6/SOCAT_$NAME/run
  18. done
  19. # Exec CMD or S6 by default if nothing present
  20. if [ $# -gt 0 ];then
  21. exec "$@"
  22. else
  23. exec /usr/bin/s6-svscan /app/gogs/docker/s6/
  24. fi