Want to subscribe to topics you're interested in?
Become a Member

Insight Guide Using Dropbox To Share Server Files

Discussion in 'Centmin Mod Insights' started by eva2000, Dec 31, 2021.

Tags:
Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    53,826
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    4:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+

    Using Dropbox To Share Files



    You can share the Centmin Mod server files like nginx, PHP or instal log files via a Dropbox basic user free account dedicated for Centmin Mod use at Dropbox Personal Plans for Individual Use - Dropbox :) You can sign up for Dropbox account using my referral link so I get an extra 500MB storage quota ;)

    Dropbox allows you to in your settings enable email to Dropbox feature. So Dropbox will provide you a custom email address where you can send files to and they will automatically be uploaded to Dropbox account under Email Attachments folder.

    So once you enable email to Dropbox feature. You can send the files to a provided Dropbox email address. I suggest you compress the file before had to save space and make your free Dropbox accounts 2GB storage space last longer.

    And example is if you want to share a log file at /root/centminlogs/pcre2log.log, you can compress it first
    Code (Text):
    pigz -9k /root/centminlogs/pcre2log.log

    Original uncompressed is 1.7MB and compressed is 86KB!
    Code (Text):
    ls -lah /root/centminlogs/pcre2log.log*
    -rw-r--r-- 1 root root 1.7M Dec 31 01:50 /root/centminlogs/pcre2log.log
    -rw-r--r-- 1 root root  86K Dec 31 01:50 /root/centminlogs/pcre2log.log.gz
    

    Then send the compressed pcre2log.log.gz log via email. You assign to email_to variable your provided Dropbox email YOUR-EMAIL@addtodropbox.com replacing YOUR-EMAIL with your specific email. And then run the 2nd command to email the log as an attachment
    Code (Text):
    email_to='YOUR-EMAIL@addtodropbox.com'
    echo "pcre2log $(date)" | mail -s "pcre2log $(date)" -a /root/centminlogs/pcre2log.log.gz $email_to
    

    If you don't receive the attachment in your Dropbox Email Attachment folder, make sure sending emails from server is working properly as per https://community.centminmod.com/th...ver-email-doesnt-end-up-in-spam-inboxes.6999/.


    The Dropbox Email Attachment folder will then show the sent file which you can select to share and generate a share link.

    dropbox-email-attachments-01.png
    dropbox-email-attachments-02.png
    dropbox-email-attachments-03.png
     
    Last edited: Dec 31, 2021
  2. eva2000

    eva2000 Administrator Staff Member

    53,826
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    4:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Creating a Dropbox send script. You can also create a very simple Dropbox send script called /usr/local/bin/dbsend. Note: You can sign up for Dropbox account using my referral link so I get an extra 500MB storage quota ;)

    Set your DROPBOX_EMAIL_TO to your Dropbox email address in
    persistent config file /etc/centminmod/custom_config.inc.

    Code (Text):
    #!/bin/bash
    ######################################################
    # send files to Dropbox account email defined by
    # DROPBOX_EMAIL_TO variable.
    #
    # You can add it to persistent config file
    # /etc/centminmod/custom_config.inc
    # which will override the variable within the script
    ######################################################
    # variables
    DROPBOX_EMAIL_TO='YOUR-EMAIL@addtodropbox.com'
    ######################################################
    
    
    if [ -f "/etc/centminmod/custom_config.inc" ]; then
      # default is at /etc/centminmod/custom_config.inc
      dos2unix -q "/etc/centminmod/custom_config.inc"
      . "/etc/centminmod/custom_config.inc"
    fi
    
    dbsend() {
      file="$1"
      filename=$(basename $file)
      filename_only="${filename%.*}"
      file_ext="${filename_only##*.}"
      echo "dbsend.sh $filename $(date)" | mail -s "dbsend.sh $filename $(date)" -a "$file" "$DROPBOX_EMAIL_TO"
      err=$?
      if [[ "$err" -eq '0' ]]; then
        echo "sent $file to Dropbox Email Attachments folder"
      else
        echo "error: unable to send to Dropbox Email Attachments folder"
      fi
    }
    
    
    ######################################################
    case "$1" in
      send )
        if [[ -f "$2" ]]; then
          dbsend "$2"
        else
          echo "error: $2 is not a file that exists"
        fi
      ;;
      * )
        echo "$0 send /full/path/to/file"
      ;;
    esac
    

    ensure it's executable
    Code (Text):
    chmod +x /usr/local/bin/dbsend


    Usage examples

    If you don't specify the path to to file, you will get a reminder for the command syntax
    Code (Text):
    dbsend
    /usr/local/bin/dbsend send /full/path/to/file
    

    If the specified file doesn't exist
    Code (Text):
    dbsend send a
    error: a is not a file that exists
    

    Code (Text):
    dbsend send /root/centminlogs/pcre2log.log.gz
    sent /root/centminlogs/pcre2log.log.gz to Dropbox Email Attachments folder
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,826
    12,160
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,712
    Local Time:
    4:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Example of viewing and sharing your logs via Dropbox. Dropbox allows you to natively view compressed .gz logs just by clicking on the compressed .gz log too :D

    dropbox-pcre-logs-opt.gif

    dropbox-pcre-logs-share-opt.gif
     
Thread Status:
Not open for further replies.