Skip to content

Commit 8d4fc3b

Browse files
committed
library.sh: Detect DB_PREFIX dynamically if possible
Signed-off-by: Tobias K <[email protected]>
1 parent a6c4b24 commit 8d4fc3b

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

bin/ncp-update-nc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ set -eE${DBG}
2121

2222
VER="$1"
2323
BIN="${0##*/}"
24-
DB_PREFIX=`php -r 'include("/var/www/nextcloud/config/config.php"); print ( $CONFIG['"'dbtableprefix'"'] );'`
25-
echo DB_PREFIX = $DB_PREFIX
2624

2725
source /usr/local/etc/library.sh
2826

bin/ncp/CONFIG/nc-init.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ EOF
127127
}
128128

129129
mysql nextcloud <<EOF
130-
replace into oc_appconfig values ( 'theming', 'name' , "NextCloudPi" , 2, null);
131-
replace into oc_appconfig values ( 'theming', 'slogan' , "keep your data close" , 2, null);
132-
replace into oc_appconfig values ( 'theming', 'url' , "https://nextcloudpi.com" , 2, null);
133-
replace into oc_appconfig values ( 'theming', 'logoMime' , "image/svg+xml" , 2, null);
134-
replace into oc_appconfig values ( 'theming', 'backgroundMime', "image/png" , 2, null);
130+
replace into ${DB_PREFIX}appconfig values ( 'theming', 'name' , "NextCloudPi" , 2, null);
131+
replace into ${DB_PREFIX}appconfig values ( 'theming', 'slogan' , "keep your data close" , 2, null);
132+
replace into ${DB_PREFIX}appconfig values ( 'theming', 'url' , "https://nextcloudpi.com" , 2, null);
133+
replace into ${DB_PREFIX}appconfig values ( 'theming', 'logoMime' , "image/svg+xml" , 2, null);
134+
replace into ${DB_PREFIX}appconfig values ( 'theming', 'backgroundMime', "image/png" , 2, null);
135135
EOF
136136

137137
# NCP app

bin/ncp/TOOLS/nc-previews.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ configure()
2424
}
2525

2626
rm -r "$datadir"/appdata_*/preview/* &>/dev/null
27-
mysql nextcloud <<<"delete from oc_filecache where path like \"appdata_%/preview/%\""
27+
mysql nextcloud <<<"delete from ${DB_PREFIX?}filecache where path like \"appdata_%/preview/%\""
2828
ncc files:scan-app-data -n
2929
}
3030

etc/library.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export NCDIR=/var/www/nextcloud
1414
export ncc=/usr/local/bin/ncc
1515
export NCPCFG=${NCPCFG:-etc/ncp.cfg}
1616
export ARCH="$(dpkg --print-architecture)"
17+
export DB_PREFIX="$(php -r 'include("/var/www/nextcloud/config/config.php"); echo $CONFIG['"'dbtableprefix'"'];' || echo 'oc_')"
1718
[[ "${ARCH}" =~ ^(armhf|arm)$ ]] && ARCH="armv7"
1819
[[ "${ARCH}" == "arm64" ]] && ARCH=aarch64
1920
[[ "${ARCH}" == "amd64" ]] && ARCH=x86_64
@@ -568,7 +569,7 @@ function notify_admin()
568569
{
569570
local header="$1"
570571
local msg="$2"
571-
local admins=$(mysql -u root nextcloud -Nse "select uid from oc_group_user where gid='admin';")
572+
local admins=$(mysql -u root nextcloud -Nse "select uid from ${DB_PREFIX}group_user where gid='admin';")
572573
[[ "${admins}" == "" ]] && { echo "admin user not found" >&2; return 0; }
573574
while read -r admin
574575
do

0 commit comments

Comments
 (0)