diff -Nur --no-dereference smeserver-nextcloud-1.2.0.old/createlinks smeserver-nextcloud-1.2.0/createlinks --- smeserver-nextcloud-1.2.0.old/createlinks 2022-07-07 21:44:09.038000000 -0400 +++ smeserver-nextcloud-1.2.0/createlinks 2022-07-07 21:45:43.035000000 -0400 @@ -47,6 +47,6 @@ httpd-e-smith sigusr1 php74-php-fpm reload-or-restart )); -event_link("nextcloud-conf", $event, "20"); -event_link("nextcloud-occ-conf", $event, "30"); +event_link("nextcloud-conf", $event, "91"); +event_link("nextcloud-occ-conf", $event, "92"); diff -Nur --no-dereference smeserver-nextcloud-1.2.0.old/root/etc/e-smith/events/actions/nextcloud-conf smeserver-nextcloud-1.2.0/root/etc/e-smith/events/actions/nextcloud-conf --- smeserver-nextcloud-1.2.0.old/root/etc/e-smith/events/actions/nextcloud-conf 2022-07-07 21:44:09.038000000 -0400 +++ smeserver-nextcloud-1.2.0/root/etc/e-smith/events/actions/nextcloud-conf 2022-07-07 23:08:20.777000000 -0400 @@ -8,17 +8,30 @@ TERM=dumb /usr/bin/occ $params } + # important configuration variables password=`/sbin/e-smith/db configuration getprop nextcloud DbPassword || echo "missing"` dbname=`/sbin/e-smith/db configuration getprop nextcloud DbName || echo "nextcloud"` dbuser=`/sbin/e-smith/db configuration getprop nextcloud DbUser || echo "nextcloud"` adminuser=`/sbin/e-smith/db configuration getprop nextcloud AdminUser || echo "admin"` adminpass=`/sbin/e-smith/db configuration getprop nextcloud AdminPassword ||/sbin/e-smith/db configuration getprop sysconfig SystemID || echo "password;109"` +#occ config:system:get dbhost +host="localhost" +socket="--socket=/var/lib/mysql/mysql.sock" +# need to check what db we are supposed to use. starting NC 21 mariadb >= 102 is needed core is 55 +# are we fresh install or update ? +installed=$(/usr/bin/occ status --output json |jq -r '.installed') +# what version +majversion=$(/usr/bin/occ status --output json |jq -r '.version'|cut -d'.' -f1) +# is there a nextcloud db in core mariadb +if [ "$installed" != "true" ]; then host="localhost:/var/lib/mysql/mariadb105.sock"; socket="--socket=/var/lib/mysql/mariadb105.sock"; fi +if [ "$installed" == "true" ]; then host=$(occ config:system:get dbhost); socket="--socket=$(echo $host|awk -F'[:]' '{print $2}')" ; fi +if [ "$socket" == "--socket=" ]; then socket=""; fi # initialize grants mysql nextcloud database -/usr/bin/mysql --defaults-file=/root/.my.cnf -e "CREATE DATABASE IF NOT EXISTS $dbname;" -/usr/bin/mysql --defaults-file=/root/.my.cnf -e "grant all on $dbname.* to '$dbuser'@'localhost' identified by '$password';" -/usr/bin/mysql --defaults-file=/root/.my.cnf -e "FLUSH PRIVILEGES" +/usr/bin/mysql --defaults-file=/root/.my.cnf $socket -e "CREATE DATABASE IF NOT EXISTS $dbname;" +/usr/bin/mysql --defaults-file=/root/.my.cnf $socket -e "grant all on $dbname.* to '$dbuser'@'localhost' identified by '$password';" +/usr/bin/mysql --defaults-file=/root/.my.cnf $socket -e "FLUSH PRIVILEGES" # check if we are migrating from release 10 to 11 if [ -f /var/www/html/nextcloud/config/config.php ]; then @@ -26,10 +39,10 @@ rm -rf /var/www/html/nextcloud/ fi -res=`/usr/bin/mysql --defaults-file=/root/.my.cnf -e "select count(*) from information_schema.tables where table_type = 'BASE TABLE' and table_schema = '$dbname'" | tail -n1`; +res=`/usr/bin/mysql --defaults-file=/root/.my.cnf $socket -e "select count(*) from information_schema.tables where table_type = 'BASE TABLE' and table_schema = '$dbname'" | tail -n1`; if [[ $res == '0' ]]; then - OCC "maintenance:install --database mysql --database-name $dbname --database-user $dbuser --database-pass $password --admin-user $adminuser --admin-pass $adminpass --data-dir /home/e-smith/files/nextcloud/data/" + OCC "maintenance:install --database mysql --database-host $host --database-name $dbname --database-user $dbuser --database-pass $password --admin-user $adminuser --admin-pass $adminpass --data-dir /home/e-smith/files/nextcloud/data/" OCC "app:enable user_ldap" OCC "ldap:create-empty-config" # create config with empty id