Browse Source

Upload files to ''

Thierry Reijnhout 4 months ago
parent
commit
ad3cf4449b
5 changed files with 201 additions and 0 deletions
  1. 122 0
      Start.sh
  2. 9 0
      Stop.sh
  3. 22 0
      Update.sh
  4. 10 0
      init_user-db.sh
  5. 38 0
      tmpfs_backup.sh

+ 122 - 0
Start.sh

@@ -0,0 +1,122 @@
+#!/bin/bash
+admin=root
+Passwordadmind=
+ContainerName=Nextcloud
+Path="/mnt/bigpart/Docker_files/"$ContainerName
+
+echo "Stop conteners"
+ docker stop $ContainerName-nginx $ContainerName $ContainerName-postgresql
+ docker rm   $ContainerName-nginx $ContainerName $ContainerName-postgresql  
+#echo "Starting $Path/tmpfs_backup.sh"
+#sh $Path/tmpfs_backup.sh
+
+# --cpuset-cpus="1"\
+ # --memory 256M\
+ # --memory-swap 256M\
+
+ echo "__________________________________________________________________________________________________________"
+
+ docker run -d \
+  --name $ContainerName-postgresql \
+  -e POSTGRES_PASSWORD=myseceret \
+  -v $Path/init_user-db.sh:/docker-entrypoint-initdb.d/init_user-db.sh \
+  -v $Path/root/postgresql:/var/lib/postgresql/data \
+   postgres:10
+   
+   #--restart=always 
+   
+ echo "__________________________________________________________________________________________________________"
+
+#  --link Collabora \
+ docker run -d \
+  --name $ContainerName \
+  --link ldap-service:ldap-host \
+  --link $ContainerName-postgresql:postgres  \
+   -v $Path/root/nextcloud:/var/www/html \
+   -v $Path/ext-storige.json:/ext-storige.json \
+  -e POSTGRES_PASSWORD= \
+  -e POSTGRES_DB=nextcloud \
+  -e POSTGRES_USER=nextcloud \
+  -e POSTGRES_HOST=postgres \
+  -e NEXTCLOUD_ADMIN_USER=$admin \
+  -e NEXTCLOUD_ADMIN_PASSWORD=$Passwordadmind \
+  --volume /xxx/NC12:/mnt/NFSUsers \
+  --volume /xxx/Media:/mnt/LocMedia \
+  nextcloud:fpm
+    docker logs $ContainerName
+  #--volume /mnt/bigpart/Media/Podcast:/mnt/Podcast \ 
+ echo "----------------------------------------------------------------------------------------------------------" 
+
+ docker run -d \
+  --name $ContainerName-nginx \
+  --link $ContainerName:app\
+  -p 84:80 \
+  -v $Path/root/nextcloud:/var/www/html:ro \
+  -v $Path/nginx.conf:/etc/nginx/nginx.conf \
+   -e "VIRTUAL_HOST=nextcloud.openhoofd.nl" \
+   -e "LETSENCRYPT_HOST=nextcloud.openhoofd.nl" \
+   -e "LETSENCRYPT_EMAIL=thierry14@zeelandnet.nl" \
+ nginx
+
+ echo "----------------------------------------------------------------------------------------------------------" 
+
+   docker logs $ContainerName-postgresql
+   docker logs $ContainerName
+   docker logs $ContainerName-nginx
+
+echo "----------------------------------------------------------------------------------------------------------"    
+
+
+if [ "$1" = 1 ]
+ then
+#<<install  
+ echo "wait for nextcloud to fully started (top_docker)"
+ echo "open browser and login to complite full install"
+ read -t 120 -p "Press enter to continue (sleeps for 120 seconds)"
+ curl --retry 10 --retry-delay 10 -s -k 127.0.0.1:84 > /dev/null
+   echo "sleep 60 to do first instal"
+   sleep 60
+ 
+echo "*----Installing apps"
+  docker exec --user www-data $ContainerName php occ app:enable files_external
+  docker exec --user www-data $ContainerName php occ app:enable user_ldap
+echo "*----Configer trusted_domains"
+ #docker exec --user www-data $ContainerName php occ config:system:get trusted_domains
+  docker exec --user www-data $ContainerName php occ config:system:set trusted_domains 0 --value=nextcloud.openhoofd.nl
+  docker exec --user www-data $ContainerName php occ config:system:set trusted_domains 1 --value=10.0.0.1:84
+  echo "*----Configer external_storige"
+ #docker exec --user www-data Nextcloud_new php occ files_external:export >> /ext-storige.json
+  docker exec --user www-data $ContainerName php occ files_external:import /ext-storige.json
+echo "*----Configer Ldap settings"
+  docker exec --user www-data $ContainerName php occ ldap:create-empty-config
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapHost ldap-host
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapPort 389
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 homeFolderNamingRule attr:homeDirectory
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapAgentName cn=admin,dc=openhoofd,dc=loc
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapAgentPassword 
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapBase dc=openhoofd,dc=loc
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapBaseGroups ou=groups,dc=openhoofd,dc=loc
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapBaseUsers ou=NextCloud,ou=users,dc=openhoofd,dc=loc
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapExpertUUIDUserAttr givenName
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGidNumber ldapGidNumber
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGroupFilter "(&(|(objectclass=top)))" 
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGroupFilterObjectclass top
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapGroupMemberAssocAttr memberUid
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapLoginFilter "(&(|(objectclass=posixAccount))(|(uid=%uid)(|(givenName=%uid)(objectClass=%uid))))"
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapLoginFilterAttributes "givenName;objectClass "
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapUserDisplayName givenName
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapUserFilter "(|(objectclass=posixAccount))"
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapUserFilterObjectclass posixAccount
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 hasMemberOfFilterSupport 0  
+  docker exec --user www-data $ContainerName php occ ldap:set-config s01 ldapConfigurationActive 1
+  docker exec --user www-data $ContainerName php occ ldap:test-config s01 
+echo "*----file:scan --all & remove firstrun no needed files"
+  docker exec --user www-data $ContainerName php occ files:scan --all
+rm -r $Path/root/nextcloud/core/skeleton/Documents
+rm -r $Path/root/nextcloud/core/skeleton/Photos
+rm -r $Path/root/nextcloud/core/skeleton/Nextcloud.mp4
+#install
+ else
+  echo "nextcloud shoud be installed alredy"
+fi  
+echo "DONE! :-D"

+ 9 - 0
Stop.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+ContainerName=Nextcloud
+Path="/mnt/bigpart/Docker_files/"$ContainerName
+
+echo "Stop conteners"
+ docker stop $ContainerName-nginx $ContainerName $ContainerName-postgresql
+ docker rm   $ContainerName-nginx $ContainerName $ContainerName-postgresql  
+echo "Starting $Path/tmpfs_backup.sh"
+sh $Path/tmpfs_backup.sh

+ 22 - 0
Update.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+admin=root
+Passwordadmind=
+ContainerName=Nextcloud
+Path="/mnt/bigpart/Docker_files/"$ContainerName
+
+sh $Path/Stop.sh
+sh $Path/tmpfs_backup.sh
+
+docker pull nextcloud:fpm
+docker pull nginx # (stable-alpine error on config.ini (current version 1.15.8)
+docker pull postgres:10  # (nextcloud diddent support 11 at thist time 3-2-19)
+
+
+
+echo "restart and hope update go fine"
+sh $Path/Start.sh
+
+
+ echo "----------------------------------------------------------------------------------------------------------" 
+   echo "wait for nextcloud to fully started (and updating)"
+   echo "open browser and login to complite update"

+ 10 - 0
init_user-db.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+set -e
+
+psql -v ON_ERROR_STOP=1 --username postgres <<-EOSQL
+ CREATE USER nextcloud WITH PASSWORD 'xxxx';
+ CREATE DATABASE nextcloud TEMPLATE template0 ENCODING 'UNICODE';
+ ALTER DATABASE nextcloud OWNER TO nextcloud;
+ GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
+EOSQL
+ 

+ 38 - 0
tmpfs_backup.sh

@@ -0,0 +1,38 @@
+#!/bin/bash
+
+ContainerName=Nextcloud
+Path="/mnt/bigpart/Docker_files/"$ContainerName
+time1=$(date +"%s")
+logfile=$Path/Nextcloud.log
+OLDBACKUP=`date -d "3 days ago" +"%Y%m%d"`
+TODAY=`date +"%Y%m%d"`
+
+   cd $Path/root
+
+echo "Backup tmpfs, Restore tmpfs"
+#if grep -qs $Path'/root' /proc/mounts; then
+    echo "Nextcloud tmpfs is mounted.">> $logfile
+    echo "Nextcloud tmpfs is mounted. making a backup"
+   cd $Path/root
+   tar -c --use-compress-program=pigz -f $Path/$TODAY-Backup.tar.bz2 *
+     time2=$(date +"%s")
+     diff=$(($time2-$time1))
+      echo "backup finished @ `date`" >> $logfile
+      echo "$(($diff / 60)) minutes and $(($diff % 60)) seconds elapsed." >> $logfile
+#    rm -R $Path/$OLDBACKUP-Backup.tar.bz2    
+#else
+#    echo "Nextcloud tmpfs is NOT MOUNTED.!!!!!!!" >> $logfile
+#    echo "Nextcloud tmpfs is NOT MOUNTED.!!!!!!!"
+#    #rm -r $Path/root
+#    mkdir -p $Path/root
+#    #mount -t tmpfs -o size=1024M tmpfs $Path/root >> $logfile
+#     for i in "`ls -tr1 $Path/*bz2| tail -1`"
+#     do 
+#      echo "recover and start from backup: ${i}"
+#     # tar -x --use-compress-program=pigz -f ${i} --directory $Path/root
+#     done
+#    echo "Restore finished @ `date`" >> $logfile
+#    echo "Nextcloud tmpfs shoud be made. resinked backup"
+#fi
+echo "-------------------------------------------------------------------------------------------------------------------------------------------------------" >> $logfile
+