Skip to content

Commit 06005e1

Browse files
committed
nc-datadir: avoid using the symlink
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent a875faa commit 06005e1

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

bin/ncp/CONFIG/nc-datadir.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ is_active()
1515
[[ "$SRCDIR" != "/var/www/nextcloud/data" ]]
1616
}
1717

18-
install()
19-
{
20-
apt-get update
18+
install()
19+
{
20+
apt-get update
2121
apt-get install -y --no-install-recommends btrfs-tools
2222
}
2323

@@ -28,7 +28,7 @@ configure()
2828
## CHECKS
2929
local SRCDIR
3030
SRCDIR=$( cd /var/www/nextcloud; sudo -u www-data php occ config:system:get datadirectory ) || {
31-
echo -e "Error reading data directory. Is NextCloud running and configured?";
31+
echo -e "Error reading data directory. Is NextCloud running and configured?";
3232
return 1;
3333
}
3434
[ -d "$SRCDIR" ] || { echo -e "data directory $SRCDIR not found"; return 1; }
@@ -57,7 +57,7 @@ configure()
5757

5858
# backup possibly existing datadir
5959
[ -d $DATADIR ] && {
60-
local BKP="${DATADIR}-$( date "+%m-%d-%y" )"
60+
local BKP="${DATADIR}-$( date "+%m-%d-%y" )"
6161
echo "INFO: $DATADIR is not empty. Creating backup $BKP"
6262
mv "$DATADIR" "$BKP"
6363
}
@@ -69,17 +69,20 @@ configure()
6969

7070
echo "moving data directory from $SRCDIR to $DATADIR..."
7171

72+
# resolve symlinks and use the real path
73+
DATADIR=$(cd "$DATADIR" && pwd -P)
74+
7275
# use subvolumes, if BTRFS
7376
[[ "$( stat -fc%T "$BASEDIR" )" == "btrfs" ]] && {
7477
echo "BTRFS filesystem detected"
75-
btrfs subvolume create "$DATADIR" || return 1
78+
btrfs subvolume create "$DATADIR" || return 1
7679
}
7780

7881
cp --reflink=auto -raT "$SRCDIR" "$DATADIR" || return 1
7982
chown www-data:www-data "$DATADIR"
80-
83+
8184
# tmp upload dir
82-
mkdir -p "$DATADIR/tmp"
85+
mkdir -p "$DATADIR/tmp"
8386
chown www-data:www-data "$DATADIR/tmp"
8487
sudo -u www-data php occ config:system:set tempdirectory --value "$DATADIR/tmp"
8588
sed -i "s|^;\?upload_tmp_dir =.*$|uploadtmp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/cli/php.ini

ncp-web/wizard/JS/wizard.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $(document).ready(function(){
1212

1313
$('#notifications').prepend( '<div class="notification ' + tclass + '">' + txt + '</div>' );
1414
}
15-
15+
1616
function logOutput( txt )
1717
{
1818
var textarea = $('#output-box');
@@ -37,11 +37,11 @@ $(document).ready(function(){
3737
addNotification( action, 'gray-bg' ) ;
3838

3939
$.post('../ncp-launcher.php',
40-
{ action:'launch',
40+
{ action:'launch',
4141
ref: action,
4242
config: JSON.stringify( args ),
4343
csrf_token: document.getElementById( 'csrf-token' ).value
44-
}
44+
}
4545
).fail( errorMsg ).done( callback );
4646
}
4747

@@ -89,8 +89,8 @@ $(document).ready(function(){
8989

9090
// Show error on failed AJAX call
9191
function errorMsg( data )
92-
{
93-
alert('There was an error with the request');
92+
{
93+
alert('There was an error with the request');
9494
}
9595

9696
function post_ddns_hook( data )
@@ -117,13 +117,13 @@ $(document).ready(function(){
117117
if (!!window.EventSource)
118118
var source = new EventSource('../ncp-output.php');
119119
else
120-
$('#config-box-title').val( "Browser not supported" );
120+
$('#config-box-title').val( "Browser not supported" );
121121

122-
source.addEventListener('message', function(e)
122+
source.addEventListener('message', function(e)
123123
{
124-
if ( e.origin != 'https://' + window.location.hostname + ':4443')
124+
if ( e.origin != 'https://' + window.location.hostname + ':4443')
125125
{
126-
$('#output-box').val( "Invalid origin" );
126+
$('#output-box').val( "Invalid origin" );
127127
return;
128128
}
129129

@@ -142,7 +142,7 @@ $(document).ready(function(){
142142
}});
143143

144144
// This is required or the tabs aren't styled
145-
$('#rootwizard').bootstrapWizard({'tabClass': 'nav nav-pills'});
145+
$('#rootwizard').bootstrapWizard({'tabClass': 'nav nav-pills'});
146146

147147
// Enable Automount step
148148
$('#enable-automount').on('click', function() {
@@ -158,8 +158,8 @@ $(document).ready(function(){
158158
// Enable format-usb step
159159
$('#plugUSB').on('click', function() {
160160
launch_action( 'nc-automount',
161-
{"ACTIVE":"yes"},
162-
function ( data ){
161+
{"ACTIVE":"yes"},
162+
function ( data ){
163163
nextOnSuccess( data, function(){ show_with_animation( 'format-usb' ); } );
164164
}
165165
);
@@ -168,7 +168,7 @@ $(document).ready(function(){
168168
// Enable nextcloud-data step
169169
$('#format-USB').on('click', function(){
170170
launch_action( 'nc-format-USB',
171-
{"LABEL":"myCloudDrive"},
171+
{"LABEL":"myCloudDrive"},
172172
function ( data ){
173173
nextOnSuccess( data, function(){ show_with_animation( 'nc-datadir-pane' ); } );
174174
}
@@ -189,7 +189,7 @@ $(document).ready(function(){
189189
$('#enable-external').on('click', function(){
190190
if ( !in_docker )
191191
launch_action( 'fail2ban',
192-
{ "ACTIVE":"yes" },
192+
{ "ACTIVE":"yes" },
193193
function ( data ){
194194
nextOnSuccess( data, function(){ show_with_animation( 'forward-ports-pane' ) } );
195195
}
@@ -213,7 +213,7 @@ $(document).ready(function(){
213213
$('#port-forward-run').on('click', function(){
214214
// Run Port Forwarding and Test Port
215215
launch_action( 'nc-forward-ports',
216-
{"HTTPSPORT":"443","HTTPPORT":"80"},
216+
{"HTTPSPORT":"443","HTTPPORT":"80"},
217217
function ( data ){
218218
nextOnSuccess( data, function(){ show_with_animation( 'ddns-choose' ) } );
219219
}
@@ -247,7 +247,7 @@ $(document).ready(function(){
247247

248248
// Enable FreeDNS step
249249
$('#ddns-enable-freedns').on('click', function(){
250-
launch_action( 'freeDNS',
250+
launch_action( 'freeDNS',
251251
{
252252
"ACTIVE":"yes",
253253
"DOMAIN": $("#ddns-domain" ).val(),
@@ -269,7 +269,7 @@ $(document).ready(function(){
269269

270270
// Enable noip step
271271
$('#ddns-enable-noip').on('click', function(){
272-
launch_action( 'no-ip',
272+
launch_action( 'no-ip',
273273
{
274274
"ACTIVE":"yes",
275275
"DOMAIN": $("#ddns-domain" ).val(),

0 commit comments

Comments
 (0)