From 3a5c3c9759397c19f6f5f986ffe295c5a1185ec2 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 31 May 2024 15:15:52 +0000 Subject: [PATCH] Added nextcloud installapp and uninstallapp configuration --- lib/nextcloud.sh | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/nextcloud.sh b/lib/nextcloud.sh index 456aa0f..4edaf55 100644 --- a/lib/nextcloud.sh +++ b/lib/nextcloud.sh @@ -16,7 +16,7 @@ config_nextcloud() { mkdir -p /federated/apps/nextcloud/data/var/www/data &> /dev/null mkdir -p /federated/apps/nextcloud/data/usr/local/etc/php/conf.d &> /dev/null fi - get_externalip + get_appvars cat > /federated/apps/nextcloud/docker-compose.yml < /federated/apps/nextcloud/.postgresql.secret echo "$ADMINPASS" > /federated/apps/nextcloud/.nextcloud.secret @@ -208,11 +207,11 @@ PATH=/var/www/html:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/sbin:/bin /var/www/html/occ app:enable user_ldap /var/www/html/occ ldap:create-empty-config /var/www/html/occ ldap:set-config s01 ldapHost 'ldaps://ldap.$DOMAIN' -/var/www/html/occ ldap:set-config s01 ldapAgentName cn=admin,dc=federatedcomputer,dc=cloud +/var/www/html/occ ldap:set-config s01 ldapAgentName cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST /var/www/html/occ ldap:set-config s01 ldapAgentPassword $LDAP_SECRET -/var/www/html/occ ldap:set-config s01 ldapBase ou=people,dc=federatedcomputer,dc=cloud -/var/www/html/occ ldap:set-config s01 ldapBaseGroups ou=groups,dc=federatedcomputer,dc=cloud -/var/www/html/occ ldap:set-config s01 ldapBaseUsers ou=people,dc=federatedcomputer,dc=cloud +/var/www/html/occ ldap:set-config s01 ldapBase ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST +/var/www/html/occ ldap:set-config s01 ldapBaseGroups ou=groups,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST +/var/www/html/occ ldap:set-config s01 ldapBaseUsers ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST /var/www/html/occ ldap:set-config s01 ldapEmailAttribute mail /var/www/html/occ ldap:set-config s01 ldapGidNumber gidNumber /var/www/html/occ ldap:set-config s01 ldapGroupDisplayName cn @@ -274,7 +273,6 @@ chmod +x /federated/apps/nextcloud/data/config.sh echo -ne "done." } - start_nextcloud() { # Start service with command to make sure it's up before proceeding start_service "nextcloud" "nc -z 172.99.0.18 80 &> /dev/null" "60" @@ -309,3 +307,21 @@ start_nextcloud() { echo -ne "done." } +uninstall_nextcloud() { + echo -ne "* Uninstalling nextcloud container.." + spin & + SPINPID=$! + + # First stop the service + cd /federated/apps/nextcloud && docker-compose -f docker-compose.yml -p nextcloud down &> /dev/null + + # Delete database and user in postgresql + docker exec postgresql psql -U postgres -c "DROP DATABASE nextcloud" &> /dev/null + docker exec postgresql psql -U postgres -c "DROP USER nextcloud" &> /dev/null + + # Delete the app directory + rm -rf /federated/apps/nextcloud + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +}