Skip to content

Commit

Permalink
Merge pull request #112 from stephdl/NC21Fix
Browse files Browse the repository at this point in the history
Fix for the nextcloud 21 migration NethServer/dev#6506
  • Loading branch information
stephdl authored Jun 9, 2021
2 parents 60d128a + 42a09fd commit 8484a75
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions root/etc/e-smith/events/actions/nethserver-nextcloud-conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ function OCC

exitOnError () {
echo $1
OCC "app:enable accessibility"
OCC "maintenance:mode --off"
exit 1
}

databaseTest () {
out=$(mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock -BN -e "select count(*) from information_schema.tables where table_type = 'BASE TABLE' and table_schema = 'nextcloud'")
if [[ $((out)) -gt "0" ]]; then
return 1
else
return 0
fi
}

password=`perl -e "use NethServer::Password; print NethServer::Password::store('nextcloud');"`

systemctl is-active --quiet rh-mariadb105-mariadb@nextcloud
Expand All @@ -40,6 +50,10 @@ fi
if [[ -n $database ]]; then
# we still use mariadb55, this is wrong we need rh-mariadb105
OCC "maintenance:mode --on"
# accessibility takes a lot of PHP ressources but is a mandatory
# else white NC dashboard (nextcloud/server#25742)
OCC "app:disable accessibility"

tmp_sql=`mktemp`
trap "rm -f $tmp_sql" EXIT

Expand Down Expand Up @@ -69,7 +83,9 @@ if [[ -n $database ]]; then
fi

# rh-mariadb105 is created,migrated,updated we can remove mariadb55 and use the socket in nextcloud for the new database
if [[ -d '/var/opt/rh/rh-mariadb105/lib/mysql-nextcloud/' ]]; then
# we test if the nextcloud database from SCL is not blank or wrong

if ! databaseTest ; then
OCC config:system:set dbhost --value="localhost:/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" --type="string"
/usr/bin/mysql -e "drop database nextcloud;"

Expand All @@ -80,6 +96,8 @@ if [[ -n $database ]]; then
#Enabling MySQL 4-byte support
OCC "config:system:set mysql.utf8mb4 --type boolean --value='true'"
OCC "maintenance:repair"
# Enable back accessibility
OCC "app:enable accessibility"
fi
else
# initialize grants mysql nextcloud database
Expand All @@ -95,8 +113,9 @@ if [ -f /var/www/html/nextcloud/config/config.php ]; then
rm -rf /var/www/html/nextcloud/
fi

res=`mysql --socket=/run/rh-mariadb105-mariadb/nextcloud-mysql.sock -e "select count(*) from information_schema.tables where table_type = 'BASE TABLE' and table_schema = 'nextcloud'" | tail -n1`;
if [[ $res == '0' ]]; then
# we test if the nextcloud database from SCL is not initialized or workable

if databaseTest ; then
OCC "maintenance:install --database mysql --database-name nextcloud --database-user nextcloud --database-pass $password --database-host=localhost:/run/rh-mariadb105-mariadb/nextcloud-mysql.sock --admin-user admin --admin-pass Nethesis,1234 --data-dir /var/lib/nethserver/nextcloud/"

OCC "app:enable user_ldap"
Expand Down

0 comments on commit 8484a75

Please sign in to comment.