diff --git a/.config/dolphinrc b/.config/dolphinrc index 3cf6dc2..90cbe7c 100644 --- a/.config/dolphinrc +++ b/.config/dolphinrc @@ -14,7 +14,7 @@ DefaultProfile= [DetailsMode] FontWeight=50 -PreviewSize=32 +PreviewSize=48 [DownloadDialog Settings] Height 768=502 @@ -43,7 +43,7 @@ Width 1366=446 [MainWindow] Height 768=703 MenuBar=Disabled -State=AAAA/wAAAAD9AAAAAwAAAAAAAAERAAACnfwCAAAAAvsAAAAUAHAAbABhAGMAZQBzAEQAbwBjAGsBAAAAIgAAAU4AAAByAQAAA/sAAAAWAGYAbwBsAGQAZQByAHMARABvAGMAawEAAAFxAAABTgAAAHIBAAADAAAAAQAAALAAAAKd/AIAAAAB+wAAABAAaQBuAGYAbwBEAG8AYwBrAAAAACIAAAKdAAAAIgEAAAMAAAADAAAFVgAAAL/8AQAAAAH7AAAAGAB0AGUAcgBtAGkAbgBhAGwARABvAGMAawAAAAAAAAAFVgAAAEQBAAADAAAERAAAAp0AAAAEAAAABAAAAAgAAAAI/AAAAAEAAAACAAAAAQAAABYAbQBhAGkAbgBUAG8AbwBsAEIAYQByAQAAAAD/////AAAAAAAAAAA= +State=AAAA/wAAAAD9AAAAAwAAAAAAAAERAAAB3fwCAAAAAvsAAAAUAHAAbABhAGMAZQBzAEQAbwBjAGsBAAAAIgAAAO4AAAByAQAAA/sAAAAWAGYAbwBsAGQAZQByAHMARABvAGMAawEAAAERAAAA7gAAAHIBAAADAAAAAQAAALAAAAKd/AIAAAAB+wAAABAAaQBuAGYAbwBEAG8AYwBrAAAAACIAAAKdAAAAIgEAAAMAAAADAAAFVgAAAL/8AQAAAAH7AAAAGAB0AGUAcgBtAGkAbgBhAGwARABvAGMAawEAAAAAAAAFVgAAAEQBAAADAAAERAAAAd0AAAAEAAAABAAAAAgAAAAI/AAAAAEAAAACAAAAAQAAABYAbQBhAGkAbgBUAG8AbwBsAEIAYQByAQAAAAD/////AAAAAAAAAAA= ToolBarsMovable=Disabled Width 1366=1366 Window-Maximized 768x1366=true diff --git a/Bash Boilerplate/template.sh b/Bash Boilerplate/template.sh new file mode 100644 index 0000000..d542935 --- /dev/null +++ b/Bash Boilerplate/template.sh @@ -0,0 +1,173 @@ +#!/usr/bin/env bash +#================================================================ +# HEADER +#================================================================ +# SYNOPSIS +# ${SCRIPT_NAME} [-hv] [-o[file]] args ... +# +# DESCRIPTION +# This is a script template +# to start any good shell script. +# More details at https://github.com/pratiktri/your_project +# +# OPTIONS +# -o [file], --output=[file] Set log file (default=/dev/null) +# use DEFAULT keyword to autoname file +# The default value is /dev/null. +# -t, --timelog Add timestamp to log ("+%y/%m/%d@%H:%M:%S") +# -x, --ignorelock Ignore if lock file exists +# -h, --help Print this help +# -v, --version Print script information +# +# EXAMPLES +# ${SCRIPT_NAME} -o DEFAULT arg1 arg2 +# +#================================================================ +# IMPLEMENTATION +# version ${SCRIPT_NAME} (www.uxora.com) 0.0.4 +# author Your Name Here +# copyright Copyright (c) +# license GNU General Public License +# +#================================================================ +# HISTORY +# 2015/03/01 : mvongvilay : Script creation +# 2015/04/01 : mvongvilay : Add long options and improvements +# +#================================================================ +# END OF HEADER +#================================================================ + +# All pending items here +# TODO + # Get the logging template + # Enable/Disable logging + # Log to STDOUT, File, Syslog - either or all + # Verbose and quite options + # Dates should be standard and non-abiguous + # STDOUT should have bright-yellow to display summary + # Red to display error + # Show the log location at the beginning and end + # Error Handling + # Traps + + + + +#### Bash Strict mode +# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` +set -o pipefail +# Exit on error. Append "|| true" if you expect an error. +set -o errexit +# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR +set -o nounset +# Exit on error inside any functions or subshells. +set -o errtrace + + +# Fail-fast checks +[[ "$(id --user)" != "0" ]] && { + echo -e "ERROR: You must be root to run this script.\nUse sudo and execute the script again." +} + + +usage() { + cat < --wp-source-dir --backup-dir [--storage-quota ] [--passphrase-dir ]" + -pname, --project-name A Unique name (usually the website name) for this backup + -wp_src, --wp-source-dir Directory where your WordPress website is stored + --backup-dir Directory where backup files will be stored + -quota, --storage-quota [Optional] Unlimited by default + When supplied backups would never exceed this capacity. + Older backups will automatically be deleted to make room for new ones. + -passdir, --passphrase-dir [Optional] /home/[user]/.config/borg by default + Backups keys are stored (in plain-text) at this location. + Use "export BORG_PASSPHRASE" as shown in the example below to avoid saving passphrase to file. + -h, --help Display this information + + NOTE:- You MUST specify BORG_PASSPHRASE by export + + $ export BORG_PASSPHRASE= + $ sudo $0 --project-name "example.com" --wp-source-dir "/var/www/example.com" --backup-dir "/home/me/backup/example.com" --storage-quota 5G --passphrase-dir /root/borg + +USAGE + + # If user asked to display this information - exit normally + if [[ ! "$#" -eq 0 ]]; then + exit 0 + fi +} + + +# Everything should be inside a function +# main() would contain the start of the script +main() { + # Explicitly Declare all variables as "local" + local SCRIPT_VERSION + local SCRIPT_NAME + readonly SCRIPT_VERSION=1.0, SCRIPT_NAME=wp_borg_backup + + ################################# Parse Script Arguments ################################# + + while [[ "${#}" -gt 0 ]]; do + case $1 in + --project-name | -pname) + + shift + shift + ;; + -h|--help) + echo + usage OK + echo + exit 0 + ;; + *) + echo + echo "Unknown parameter encounted : $1 - this will be ignored" + echo + shift + ;; + esac + done + + # Check if mandatory items were provided or not + # if [[ -z "${project_name}" ]]; then + # echo "ERROR: Script requires a project name (--project-name | -pname) parameter" 2>STDERR + # usage + # exit 6 + # fi + + ################################# Parse Script Arguments ################################# + + + + + ######################################### Set up ######################################### + + # Set variables that you require for the rest of the operations here + local TS + local LOGFILE + + # Create the backup directory structure + readonly TS="$(date '+%d_%m_%Y-%H_%M_%S')" + readonly LOGFILE=/tmp/"${SCRIPT_NAME}"_v"${SCRIPT_VERSION}"_"${TS}".log + touch "${LOGFILE}" + echo "You can find the log at ${LOGFILE}" + + ######################################### Set up ######################################### + + + + ################################## Operation 1 ################################## + + # Do your stuff here + + + ################################## Operation 1 ################################## +} + + +# Call the main() here +main "$@" \ No newline at end of file