From 06005e12e9d2f333d6b577a7ace45680c3805ebf Mon Sep 17 00:00:00 2001 From: nachoparker Date: Mon, 9 Sep 2019 21:00:34 -0600 Subject: nc-datadir: avoid using the symlink Signed-off-by: nachoparker --- bin/ncp/CONFIG/nc-datadir.sh | 19 +++++++++++-------- ncp-web/wizard/JS/wizard.js | 34 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh index 8f087c54..667b7d37 100644 --- a/bin/ncp/CONFIG/nc-datadir.sh +++ b/bin/ncp/CONFIG/nc-datadir.sh @@ -15,9 +15,9 @@ is_active() [[ "$SRCDIR" != "/var/www/nextcloud/data" ]] } -install() -{ - apt-get update +install() +{ + apt-get update apt-get install -y --no-install-recommends btrfs-tools } @@ -28,7 +28,7 @@ configure() ## CHECKS local SRCDIR SRCDIR=$( cd /var/www/nextcloud; sudo -u www-data php occ config:system:get datadirectory ) || { - echo -e "Error reading data directory. Is NextCloud running and configured?"; + echo -e "Error reading data directory. Is NextCloud running and configured?"; return 1; } [ -d "$SRCDIR" ] || { echo -e "data directory $SRCDIR not found"; return 1; } @@ -57,7 +57,7 @@ configure() # backup possibly existing datadir [ -d $DATADIR ] && { - local BKP="${DATADIR}-$( date "+%m-%d-%y" )" + local BKP="${DATADIR}-$( date "+%m-%d-%y" )" echo "INFO: $DATADIR is not empty. Creating backup $BKP" mv "$DATADIR" "$BKP" } @@ -69,17 +69,20 @@ configure() echo "moving data directory from $SRCDIR to $DATADIR..." + # resolve symlinks and use the real path + DATADIR=$(cd "$DATADIR" && pwd -P) + # use subvolumes, if BTRFS [[ "$( stat -fc%T "$BASEDIR" )" == "btrfs" ]] && { echo "BTRFS filesystem detected" - btrfs subvolume create "$DATADIR" || return 1 + btrfs subvolume create "$DATADIR" || return 1 } cp --reflink=auto -raT "$SRCDIR" "$DATADIR" || return 1 chown www-data:www-data "$DATADIR" - + # tmp upload dir - mkdir -p "$DATADIR/tmp" + mkdir -p "$DATADIR/tmp" chown www-data:www-data "$DATADIR/tmp" sudo -u www-data php occ config:system:set tempdirectory --value "$DATADIR/tmp" sed -i "s|^;\?upload_tmp_dir =.*$|uploadtmp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/cli/php.ini diff --git a/ncp-web/wizard/JS/wizard.js b/ncp-web/wizard/JS/wizard.js index 8f0c4bbe..4b8551c8 100644 --- a/ncp-web/wizard/JS/wizard.js +++ b/ncp-web/wizard/JS/wizard.js @@ -12,7 +12,7 @@ $(document).ready(function(){ $('#notifications').prepend( '
' + txt + '
' ); } - + function logOutput( txt ) { var textarea = $('#output-box'); @@ -37,11 +37,11 @@ $(document).ready(function(){ addNotification( action, 'gray-bg' ) ; $.post('../ncp-launcher.php', - { action:'launch', + { action:'launch', ref: action, config: JSON.stringify( args ), csrf_token: document.getElementById( 'csrf-token' ).value - } + } ).fail( errorMsg ).done( callback ); } @@ -89,8 +89,8 @@ $(document).ready(function(){ // Show error on failed AJAX call function errorMsg( data ) - { - alert('There was an error with the request'); + { + alert('There was an error with the request'); } function post_ddns_hook( data ) @@ -117,13 +117,13 @@ $(document).ready(function(){ if (!!window.EventSource) var source = new EventSource('../ncp-output.php'); else - $('#config-box-title').val( "Browser not supported" ); + $('#config-box-title').val( "Browser not supported" ); - source.addEventListener('message', function(e) + source.addEventListener('message', function(e) { - if ( e.origin != 'https://' + window.location.hostname + ':4443') + if ( e.origin != 'https://' + window.location.hostname + ':4443') { - $('#output-box').val( "Invalid origin" ); + $('#output-box').val( "Invalid origin" ); return; } @@ -142,7 +142,7 @@ $(document).ready(function(){ }}); // This is required or the tabs aren't styled - $('#rootwizard').bootstrapWizard({'tabClass': 'nav nav-pills'}); + $('#rootwizard').bootstrapWizard({'tabClass': 'nav nav-pills'}); // Enable Automount step $('#enable-automount').on('click', function() { @@ -158,8 +158,8 @@ $(document).ready(function(){ // Enable format-usb step $('#plugUSB').on('click', function() { launch_action( 'nc-automount', - {"ACTIVE":"yes"}, - function ( data ){ + {"ACTIVE":"yes"}, + function ( data ){ nextOnSuccess( data, function(){ show_with_animation( 'format-usb' ); } ); } ); @@ -168,7 +168,7 @@ $(document).ready(function(){ // Enable nextcloud-data step $('#format-USB').on('click', function(){ launch_action( 'nc-format-USB', - {"LABEL":"myCloudDrive"}, + {"LABEL":"myCloudDrive"}, function ( data ){ nextOnSuccess( data, function(){ show_with_animation( 'nc-datadir-pane' ); } ); } @@ -189,7 +189,7 @@ $(document).ready(function(){ $('#enable-external').on('click', function(){ if ( !in_docker ) launch_action( 'fail2ban', - { "ACTIVE":"yes" }, + { "ACTIVE":"yes" }, function ( data ){ nextOnSuccess( data, function(){ show_with_animation( 'forward-ports-pane' ) } ); } @@ -213,7 +213,7 @@ $(document).ready(function(){ $('#port-forward-run').on('click', function(){ // Run Port Forwarding and Test Port launch_action( 'nc-forward-ports', - {"HTTPSPORT":"443","HTTPPORT":"80"}, + {"HTTPSPORT":"443","HTTPPORT":"80"}, function ( data ){ nextOnSuccess( data, function(){ show_with_animation( 'ddns-choose' ) } ); } @@ -247,7 +247,7 @@ $(document).ready(function(){ // Enable FreeDNS step $('#ddns-enable-freedns').on('click', function(){ - launch_action( 'freeDNS', + launch_action( 'freeDNS', { "ACTIVE":"yes", "DOMAIN": $("#ddns-domain" ).val(), @@ -269,7 +269,7 @@ $(document).ready(function(){ // Enable noip step $('#ddns-enable-noip').on('click', function(){ - launch_action( 'no-ip', + launch_action( 'no-ip', { "ACTIVE":"yes", "DOMAIN": $("#ddns-domain" ).val(), -- cgit v1.2.3