Start.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. admin=root
  3. Passwordadmind=
  4. ContainerName=Nextcloud
  5. Path="/mnt/bigpart/Docker_files/"$ContainerName
  6. echo "Stop conteners"
  7. docker stop $ContainerName-nginx $ContainerName $ContainerName-postgresql
  8. docker rm $ContainerName-nginx $ContainerName $ContainerName-postgresql
  9. #echo "Starting $Path/tmpfs_backup.sh"
  10. #sh $Path/tmpfs_backup.sh
  11. # --cpuset-cpus="1"\
  12. # --memory 256M\
  13. # --memory-swap 256M\
  14. echo "__________________________________________________________________________________________________________"
  15. docker run -d \
  16. --name $ContainerName-postgresql \
  17. -e POSTGRES_PASSWORD=myseceret \
  18. -v $Path/init_user-db.sh:/docker-entrypoint-initdb.d/init_user-db.sh \
  19. -v $Path/root/postgresql:/var/lib/postgresql/data \
  20. postgres:10
  21. #--restart=always
  22. echo "__________________________________________________________________________________________________________"
  23. # --link Collabora \
  24. docker run -d \
  25. --name $ContainerName \
  26. --link ldap-service:ldap-host \
  27. --link $ContainerName-postgresql:postgres \
  28. -v $Path/root/nextcloud:/var/www/html \
  29. -v $Path/ext-storige.json:/ext-storige.json \
  30. -e POSTGRES_PASSWORD= \
  31. -e POSTGRES_DB=nextcloud \
  32. -e POSTGRES_USER=nextcloud \
  33. -e POSTGRES_HOST=postgres \
  34. -e NEXTCLOUD_ADMIN_USER=$admin \
  35. -e NEXTCLOUD_ADMIN_PASSWORD=$Passwordadmind \
  36. --volume /xxx/NC12:/mnt/NFSUsers \
  37. --volume /xxx/Media:/mnt/LocMedia \
  38. nextcloud:fpm
  39. docker logs $ContainerName
  40. #--volume /mnt/bigpart/Media/Podcast:/mnt/Podcast \
  41. echo "----------------------------------------------------------------------------------------------------------"
  42. docker run -d \
  43. --name $ContainerName-nginx \
  44. --link $ContainerName:app\
  45. -p 84:80 \
  46. -v $Path/root/nextcloud:/var/www/html:ro \
  47. -v $Path/nginx.conf:/etc/nginx/nginx.conf \
  48. -e "VIRTUAL_HOST=nextcloud.openhoofd.nl" \
  49. -e "LETSENCRYPT_HOST=nextcloud.openhoofd.nl" \
  50. -e "LETSENCRYPT_EMAIL=thierry14@zeelandnet.nl" \
  51. nginx
  52. echo "----------------------------------------------------------------------------------------------------------"
  53. docker logs $ContainerName-postgresql
  54. docker logs $ContainerName
  55. docker logs $ContainerName-nginx
  56. echo "----------------------------------------------------------------------------------------------------------"
  57. if [ "$1" = 1 ]
  58. then
  59. #<<install
  60. echo "wait for nextcloud to fully started (top_docker)"
  61. echo "open browser and login to complite full install"
  62. read -t 120 -p "Press enter to continue (sleeps for 120 seconds)"
  63. curl --retry 10 --retry-delay 10 -s -k 127.0.0.1:84 > /dev/null
  64. echo "sleep 60 to do first instal"
  65. sleep 60
  66. echo "*----Installing apps"
  67. docker exec --user www-data $ContainerName php occ app:enable files_external
  68. docker exec --user www-data $ContainerName php occ app:enable user_ldap
  69. echo "*----Configer trusted_domains"
  70. #docker exec --user www-data $ContainerName php occ config:system:get trusted_domains
  71. docker exec --user www-data $ContainerName php occ config:system:set trusted_domains 0 --value=nextcloud.openhoofd.nl
  72. docker exec --user www-data $ContainerName php occ config:system:set trusted_domains 1 --value=10.0.0.1:84
  73. echo "*----Configer external_storige"
  74. #docker exec --user www-data Nextcloud_new php occ files_external:export >> /ext-storige.json
  75. docker exec --user www-data $ContainerName php occ files_external:import /ext-storige.json
  76. echo "*----Configer Ldap settings"
  77. docker exec --user www-data $ContainerName php occ ldap:create-empty-config
  78. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapHost ldap-host
  79. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapPort 389
  80. docker exec --user www-data $ContainerName php occ ldap:set-config s01 homeFolderNamingRule attr:homeDirectory
  81. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapAgentName cn=admin,dc=openhoofd,dc=loc
  82. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapAgentPassword
  83. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapBase dc=openhoofd,dc=loc
  84. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapBaseGroups ou=groups,dc=openhoofd,dc=loc
  85. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapBaseUsers ou=NextCloud,ou=users,dc=openhoofd,dc=loc
  86. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapExpertUUIDUserAttr givenName
  87. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGidNumber ldapGidNumber
  88. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGroupFilter "(&(|(objectclass=top)))"
  89. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGroupFilterObjectclass top
  90. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGroupMemberAssocAttr memberUid
  91. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapLoginFilter "(&(|(objectclass=posixAccount))(|(uid=%uid)(|(givenName=%uid)(objectClass=%uid))))"
  92. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapLoginFilterAttributes "givenName;objectClass "
  93. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapUserDisplayName givenName
  94. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapUserFilter "(|(objectclass=posixAccount))"
  95. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapUserFilterObjectclass posixAccount
  96. docker exec --user www-data $ContainerName php occ ldap:set-config s01 hasMemberOfFilterSupport 0
  97. docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapConfigurationActive 1
  98. docker exec --user www-data $ContainerName php occ ldap:test-config s01
  99. echo "*----file:scan --all & remove firstrun no needed files"
  100. docker exec --user www-data $ContainerName php occ files:scan --all
  101. rm -r $Path/root/nextcloud/core/skeleton/Documents
  102. rm -r $Path/root/nextcloud/core/skeleton/Photos
  103. rm -r $Path/root/nextcloud/core/skeleton/Nextcloud.mp4
  104. #install
  105. else
  106. echo "nextcloud shoud be installed alredy"
  107. fi
  108. echo "DONE! :-D"