library.sh: Detect DB_PREFIX dynamically if possible

Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
Tobias K 2024-05-04 11:50:31 +02:00
parent a6c4b245ff
commit 8d4fc3b8f9
No known key found for this signature in database
GPG Key ID: 44FD368932E645C1
4 changed files with 8 additions and 9 deletions

View File

@ -21,8 +21,6 @@ set -eE${DBG}
VER="$1"
BIN="${0##*/}"
DB_PREFIX=`php -r 'include("/var/www/nextcloud/config/config.php"); print ( $CONFIG['"'dbtableprefix'"'] );'`
echo DB_PREFIX = $DB_PREFIX
source /usr/local/etc/library.sh

View File

@ -127,11 +127,11 @@ EOF
}
mysql nextcloud <<EOF
replace into oc_appconfig values ( 'theming', 'name' , "NextCloudPi" , 2, null);
replace into oc_appconfig values ( 'theming', 'slogan' , "keep your data close" , 2, null);
replace into oc_appconfig values ( 'theming', 'url' , "https://nextcloudpi.com" , 2, null);
replace into oc_appconfig values ( 'theming', 'logoMime' , "image/svg+xml" , 2, null);
replace into oc_appconfig values ( 'theming', 'backgroundMime', "image/png" , 2, null);
replace into ${DB_PREFIX}appconfig values ( 'theming', 'name' , "NextCloudPi" , 2, null);
replace into ${DB_PREFIX}appconfig values ( 'theming', 'slogan' , "keep your data close" , 2, null);
replace into ${DB_PREFIX}appconfig values ( 'theming', 'url' , "https://nextcloudpi.com" , 2, null);
replace into ${DB_PREFIX}appconfig values ( 'theming', 'logoMime' , "image/svg+xml" , 2, null);
replace into ${DB_PREFIX}appconfig values ( 'theming', 'backgroundMime', "image/png" , 2, null);
EOF
# NCP app

View File

@ -24,7 +24,7 @@ configure()
}
rm -r "$datadir"/appdata_*/preview/* &>/dev/null
mysql nextcloud <<<"delete from oc_filecache where path like \"appdata_%/preview/%\""
mysql nextcloud <<<"delete from ${DB_PREFIX?}filecache where path like \"appdata_%/preview/%\""
ncc files:scan-app-data -n
}

View File

@ -14,6 +14,7 @@ export NCDIR=/var/www/nextcloud
export ncc=/usr/local/bin/ncc
export NCPCFG=${NCPCFG:-etc/ncp.cfg}
export ARCH="$(dpkg --print-architecture)"
export DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG['"'dbtableprefix'"'];' || echo 'oc_')"
[[ "${ARCH}" =~ ^(armhf|arm)$ ]] && ARCH="armv7"
[[ "${ARCH}" == "arm64" ]] && ARCH=aarch64
[[ "${ARCH}" == "amd64" ]] && ARCH=x86_64
@ -568,7 +569,7 @@ function notify_admin()
{
local header="$1"
local msg="$2"
local admins=$(mysql -u root nextcloud -Nse "select uid from oc_group_user where gid='admin';")
local admins=$(mysql -u root nextcloud -Nse "select uid from ${DB_PREFIX}group_user where gid='admin';")
[[ "${admins}" == "" ]] && { echo "admin user not found" >&2; return 0; }
while read -r admin
do