Skip to content

anothermimich/Bash-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash scripts

Rclone Google Drive Backup

As Google insist on not releasing a Drive client for linux, we have to search for alternative ways to use Google Drive. Rclone has a mount command that is usefull for light use, this scripts complement it by keeping folders that are under heavy use locally for fast access. See the crontab section bellow for the mount command. As of this moment the bisync function have some quirks that i can't deal with, so the implemented bellow version use 'sync' and manual pull and push.

Before attempting to use this script you need to configure and read the documentation of rclone. I strongly suggest that you also try the scripts with a test folder or use --dry-run.

Implementation

Some of the flags used don't work in older version of rclone, so update it

sudo -v ; curl https://rclone.org/install.sh | sudo bash

Create the local folders and an RCLONE_TEST file inside of it

mkdir folder-name
cd folder-name/
touch RCLONE_TEST

Edit the rclone_variables.sh to refers to your envisioned folder or folders.

REMOTE_DIR=('remote-name:/folder-name'  'remote-name:/folder-name')
LOCAL_DIR=('folder-name' 'folder-name')

Move the scripts, I'm using /home/lu/Codes/Bash-scripts/rclone-gdrive

Make the scripts executable

chmod +x /home/lu/Codes/Bash-scripts/rclone-gdrive/rclone_*.sh

Run the rclone_pull_run.sh on the terminal to get data from the remote folder

./home/lu/Codes/Bash-scripts/rclone-gdrive/rclone_pull_run.sh

If the result is

  • Sync done: You can proceed with the implementation.
  • Sync failed: Ops, you need to troubleshoot. Check the log file at $HOME/.config/rclone/rclone.log.
  • Sintax dir error: Check the rclone_variables.sh for errors. The REMOTE_DIR and LOCAL_DIR must match in order and ammount of entries.

After this you can create and alias for the rclone_pull_run.sh and rclone_push_run.sh or edit crontab to execute them with the wanted time interval.

Crontab implementation

crontab -e

Lines to be added

*/240 * * * * cd /home/lu/Codes/Bash-scripts/rclone-gdrive/ && ./rclone_pull_run.sh >/dev/null 2&1

If you want to mount a drive as well add the line bellow with updated locations, note that --vfs-cache-mode full don't work well in FAT/exFAT file systems.

@reboot sleep 60 && rclone mount g_drive:/ /home/user/Drive/ --vfs-cache-mode full --vfs-cache-max-age=72h --dir-cache-time=72h --vfs-cache-max-size 1G >/dev/null 2&1

Alias implementation

vim ~/.bash_aliases

Lines to be added

alias gdrive-pull="bash /home/lu/Codes/Bash-scripts/rclone-gdrive/rclone_pull_run.sh"
alias gdrive-push="bash /home/lu/Codes/Bash-scripts/rclone-gdrive/rclone_push_run.sh"

To get files from the remote folder you can run

gdrive-pull

To get files to the remote folder run

gdrive-push

Chunk-size1

A 64M chunk-size is used for performance purposes. Google recommends as large a chunk size as possible. Rclone will use the following amount of RAM at run-time (8MB chunks by default; not high enough)...

RAM = (chunk-size * num-transfers)

So our command will use larger chunk sizes (more RAM)...

RAM = 0.5 GB = (64MB * 8 transfers)

For more details... rclone/rclone#397

1 This explanation was written by Markus Craig

Credits

Based on markuscraig/sync_gdrive.py and on Faris Khasawneh scripts

Ç config

In some ABNT2 keyboards the Ç don't work out of the box. So you need to edit /etc/environment

sudo vim /etc/environment

At the end of the archive add

GTK_IM_MODULE=cedilla

Restart the computer

systemctl reboot

MD5 Web

Configure ssmtp and mailutils. Then create the file md5-web-mail.sh and add the mail variables in there

MAIL=('user@mail.com' 'other@mail.com')

Update the variables; cd into the script folder; run the check up script; update the crontab to include the followwing line

*/5 * * * * cd /home/lu/Codes/Bash-scripts/md5-web/ && ./md5-web-chek-up.sh >/dev/null 2&1

Zotero Etheral

Custom filter for pdf read

    canvas{filter: brightness(0.89) grayscale(0.15) invert(0.95) hue-rotate(180deg) !important; }

OCRmyPDF

Use PDF Arranger to adjust the pdf pages and crop. Then install OCRmyPDF and use the following command to ocr it. Make sure to navigate to the folder or to include the corrent path to the input and output file.

ocrmypdf --deskew -l por input.pdf output.pdf

Wacom Tablet

Scroll

First list the devices using

xsetwacom --list devices

To enable scroll/pan using the lower button in wacon pen (Button 2)

xsetwacom --set "Wacom One by Wacom S Pen stylus" Button 2 "pan"

To increase the sensitivity decrease the value of "PanScrollThreshold" (the default value was 1300)

xsetwacom --set "Wacom One by Wacom S Pen stylus" "PanScrollThreshold" 200

Invert

To invert the tablet horizontally change the "Rotate" parameter to half

xsetwacom --set "Wacom One by Wacom S Pen stylus" "Rotate" half

Script

Go to wacom-x11 folder for that.

Imagemagick PDF Contrast

convert -density 300 input.pdf -normalize -sharpen 0x2 -compress jpeg -quality 70 -colorspace gray -contrast -contrast -contrast output.pdf

Issuu download

Use the script inside the folder Issuu

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages