diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58d7b7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.localBackupPath +.serverBackupPath +.sshKeyBackupPath +.sshKey +Backup/.lastDisk diff --git a/Backup/.Backup_HD.sh b/Backup/.Backup_HD.sh new file mode 100755 index 0000000..b8cb13a --- /dev/null +++ b/Backup/.Backup_HD.sh @@ -0,0 +1,136 @@ +# Ansi color code variables +red="\e[0;91m" +blue="\e[0;94m" +expand_bg="\e[K" +blue_bg="\e[0;104m${expand_bg}" +red_bg="\e[0;101m${expand_bg}" +green_bg="\e[0;102m${expand_bg}" +green="\e[0;92m" +white="\e[0;97m" +bold="\e[1m" +uline="\e[4m" +reset="\e[0m" + +function backup () { + # $1 - Repository + # $2 - Backup name + # $3 - Files/Folders to backup + prepareFolder $1 + echo -e "${blue} `date +%r` - Backing up (compressed)...${reset}" + nice -n 19 borg create --compression auto,zstd,9 --exclude-from=./exclude "$1::$2" "$3" + checkBackup $1 +} + +function backupNoCompression () { + # $1 - Repository + # $2 - Backup name + # $3 - Files/Folders to backup + prepareFolder $1 + echo -e "${blue} `date +%r` - Backing up (uncompressed)...${reset}" + nice -n 19 borg create --compression none --exclude-from=./exclude "$1::$2" "$3" + checkBackup $1 +} + +function prepareFolder() { + if [ ! -d "$1" ]; then + mkdir -p "$1" + borg init --encryption=none $1 + else + pruneBackup $1 + fi +} + +function checkBackup() { + echo -e -n "${blue} `date +%r` - Checking the backup...${reset}" + borg check "$1" > "$1"_status + if [[ $(cat "$1"_status) != "" ]]; then + echo -e "\n\033[1;31m ERROR UNPACKING $1 \033[0m" + else + echo -e ".${green}OK!${reset}" + rm "$1"_status + fi + echo +} + +function pruneBackup() { + echo -e "${blue} `date +%r` - Prune old backups...${reset}" + borg prune --keep-within=1y --keep-daily=30 --keep-weekly=12 --keep-monthly=24 --keep-yearly=3 $1 +} + + +cd /home/bruno/Apps/linuxShortcuts/Backup/ + +LastDisk=$(< .lastDisk) +if [ "$LastDisk" = '1' ]; then + ActiveDisk=2 +else + ActiveDisk=1 +fi + +YEAR=`date +%Y` +HDPath="/run/media/bruno/Backup_$ActiveDisk" + +BACKUPPATH="$HDPath/Backup" +YEARMONTH=`date +%Y-%m-%d` + +echo +echo "Disk : $ActiveDisk" +echo "HD Backup path : $BACKUPPATH" +echo +echo "Please, insert Disk #$ActiveDisk and press enter to start backup" +read + +timeout=30 +echo -n "Mounting Backup_$ActiveDisk" +device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1) +while [[ "$device" != *"/dev/"* ]]; do + [[ $timeout -lt 1 ]] && echo -e "\e[97m Timeout!\e[39m" && break + (( timeout-- )) + echo -n "." + sleep 1s + device=$(mount | grep "Backup_$ActiveDisk" | cut -d " " -f1) +done + +# If folder does not exist, exit with error +[ ! -d "$HDPath" ] && echo "This disk was used last time. Please, plug Backup_$ActiveDisk before running this script." && read && exit 1 +echo -e ".${green}OK!${reset}" +echo + +echo -e "${white}`date +%r` - Copying Linux Home folder (1/7)...\e[39m" +echo -e "${white} `date +%r` - Bruno\e[39m" +backup "$HDPath/LinuxHome-Bruno" "$YEARMONTH" "/home/bruno/" || echo "" + +echo -e "${white} `date +%r` - Admin\e[39m" +backup "$HDPath/LinuxHome-Admin" "$YEARMONTH" "/home/admin/" || echo "" + +echo -e "${white}`date +%r` - Copying Localização folder (2/7)...\e[39m" +backup "$HDPath/Multimedia-Localizacao" "$YEARMONTH" "/run/media/bruno/Multimedia/Localização/" || echo "" + +echo -e "${white}`date +%r` - Copying My Documents folder (3/7)...\e[39m" +backup "$HDPath/Multimedia-MyDocuments" "$YEARMONTH" "/run/media/bruno/Multimedia/MyDocuments/" || echo "" + +echo -e "${white}`date +%r` - Copying Música folder (4/7)...\e[39m" +backup "$HDPath/Multimedia-Musica" "$YEARMONTH" "/run/media/bruno/Multimedia/Música/" || echo "" + +echo -e "${white}`date +%r` - Copying Fotos folder (5/7)...\e[39m" +backupNoCompression "$HDPath/Fotos" "$YEARMONTH" "/run/media/bruno/Multimedia/Fotos" || echo "" + +echo -e "${white}`date +%r` - Copying Video folder (6/7)...\e[39m" +backupNoCompression "$HDPath/Videos" "$YEARMONTH" "/run/media/bruno/Multimedia/Videos" || echo "" + +echo -e "${white}`date +%r` - Copying Virtual Machines folder (7/7)...\e[39m" +backup "$HDPath/VirtualMachines" "$YEARMONTH" "/run/media/bruno/Multimedia/Virtual Machines" || echo "" + +# Show result +echo -e "${green}`date +%r` - Backup finished. Please, verify your log files.\e[39m" + +echo "$ActiveDisk" > .lastDisk + +kdialog --title "Backup Complete" --msgbox "Backup finished successfully" +echo +echo "Backup on $device is finished. Press any key to close..." +read + +#Try to umount device +udisksctl unmount -b "$device" && udisksctl power-off -b "$device" +exit diff --git a/Backup/.Backup_HD_1TB.sh b/Backup/.Backup_HD_1TB.sh deleted file mode 100755 index a93a742..0000000 --- a/Backup/.Backup_HD_1TB.sh +++ /dev/null @@ -1,59 +0,0 @@ -YEARMONTH=`date +%Y/%m-%b` -YEAR=`date +%Y` -HDPath="/run/media/bruno/Seagate\ Expansion\ Drive" -HDYEARMONTH="$HDPath/$YEARMONTH" - -White="\e[97m" -Gray="\e[39m" - -mkdir -p "$HDPath/$YEAR" -mkdir -p "$HDYEARMONTH" -mkdir -p "$HDYEARMONTH/LinuxHome" -mkdir -p "$HDYEARMONTH/LinuxHome/bruno" -mkdir -p "$HDYEARMONTH/LinuxHome/admin" -mkdir -p "$HDYEARMONTH/LinuxHome/lost+found" - -backup="rsync -rptgoDql --exclude-from=./exclude" - -echo -echo "Backup command : $backup" -echo "HD Backup path : $HDPath" -echo "HD Year-Month path: $HDYEARMONTH" -echo -echo Press enter key to start the backup -read -echo -echo -e "$White`date +%r` - Copying Dropbox folder (1/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/Dropbox" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "$White`date +%r` - Copying Linux Home folder (2/7)...$Gray" - -echo -e "$White `date +%r` - Bruno$Gray" -eval $backup "/home/bruno/" "$HDYEARMONTH/LinuxHome/bruno/" || echo "" - -echo -e "$White `date +%r` - Admin$Gray" -eval $backup "/home/admin/" "$HDYEARMONTH/LinuxHome/admin/" || echo "" - -echo -e "$White`date +%r` - Copying Localização folder (3/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/Localização" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "$White`date +%r` - Copying My Documents folder (4/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/My\ Documents" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "$White`date +%r` - Copying Música folder (5/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/Música" "$HDYEARMONTH/Multimedia/" || echo "" - -echo -e "$White`date +%r` - Copying Fotos folder (6/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/Fotos" "$HDPath/$YEAR/" || echo "" - -echo -e "$White`date +%r` - Copying Virtual Machines folder (7/7)...$Gray" -eval $backup "/run/media/bruno/Multimedia/Virtual\ Machines" "$HDPath/$YEAR/" || echo "" - -echo -e "$White`date +%r` - Backup finished. Please, verify your log files.$Gray" - -kdialog --title "Backup Complete" --msgbox "Backup finished successfully" - -echo -echo Press enter key to close -read - diff --git a/Backup/.lastDisk b/Backup/.lastDisk new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/Backup/.lastDisk @@ -0,0 +1 @@ +2 diff --git a/Backup/exclude b/Backup/exclude index 2c78ecf..b7a5d13 100755 --- a/Backup/exclude +++ b/Backup/exclude @@ -1 +1,30 @@ -.cache/* +/home/bruno/.AndroidStudio3.1 +/home/bruno/.cache/ +/home/bruno/.electron +/home/bruno/.local/share/dino/files +/home/bruno/.local/share/gajim/downloads +/home/bruno/.minecraft/ +/home/bruno/.netbeans +/home/bruno/.node-gyp +/home/bruno/.npm +/home/bruno/.npm-global +/home/bruno/.openshot_qt +/home/bruno/.steam/ +/home/bruno/.tlauncher +/home/bruno/.vagrant.d/ +/home/bruno/.wine/ +/home/bruno/Android/ +/home/bruno/Apps/Minecraft/Backups/ +/home/bruno/Emulation/ +/home/bruno/Videos/ +/home/bruno/VirtualBox VMs/ +/home/bruno/bin/ +/home/bruno/go/ +/home/bruno/node_modules +/home/bruno/shared/ +/run/media/bruno/Multimedia/Localização/Ccaps/Projetos/@Delivered +/run/media/bruno/Multimedia/Localização/Ccaps/TEMP +/run/media/bruno/Multimedia/Localização/FONTES +/run/media/bruno/Multimedia/MyDocuments/Camtasia Studio +/run/media/bruno/Multimedia/MyDocuments/Downloads +/run/media/bruno/Multimedia/Virtual\ Machines diff --git a/Backup/listBackups.sh b/Backup/listBackups.sh new file mode 100755 index 0000000..8234955 --- /dev/null +++ b/Backup/listBackups.sh @@ -0,0 +1,7 @@ +if [ $1 ]; then + sudo borg list $1 +else + echo + echo "ERROR: Backup folder argument is missing. Use folder name to display backup set or FOLDER_NAME::BACKUP_SET to display files." + echo +fi diff --git a/Backup/runBackup.sh b/Backup/runBackup.sh index 9d10a24..9082576 100755 --- a/Backup/runBackup.sh +++ b/Backup/runBackup.sh @@ -1,2 +1,2 @@ -#!/usr/bin/env bash -terminator -m -T BACKUP -x systemd-inhibit sudo bash .Backup_HD_1TB.sh +#!/bin/sh +/bin/terminator -m -T BACKUP -x sudo systemd-inhibit bash /home/bruno/Apps/linuxShortcuts/Backup/.Backup_HD.sh & diff --git a/Backup/zRestore.sh b/Backup/zRestore.sh new file mode 100755 index 0000000..184ac26 --- /dev/null +++ b/Backup/zRestore.sh @@ -0,0 +1,3 @@ +date +zbackup --non-encrypted --silent --cache-size 512mb restore $1 > $2 +date diff --git a/Dolphin/bf-copy.desktop b/Dolphin/bf-copy.desktop new file mode 100644 index 0000000..bfbb2c4 --- /dev/null +++ b/Dolphin/bf-copy.desktop @@ -0,0 +1,24 @@ +# Copyright 2019 Bruno Fontes + +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +MimeType=application/octet-stream;inode/directory +Actions=copyNameOnly;copyPathOnly;copyPath; +X-KDE-Priority=TopLevel +X-KDE-Submenu=BFCopy + +[Desktop Action copyNameOnly] +Name=Copy Filename +Name[pt_BR]=Copiar nome do arquivo +Exec=bash ~/.local/share/kservices5/ServiceMenus/copyName.sh %F + +[Desktop Action copyPathOnly] +Name=Copy Path +Name[pt_BR]=Copiar caminho +Exec=bash ~/.local/share/kservices5/ServiceMenus/copyPath.sh %F + +[Desktop Action copyPath] +Name=Copy Full Path +Name[pt_BR]=Copiar caminho completo +Exec=bash ~/.local/share/kservices5/ServiceMenus/copyFullPath.sh %F diff --git a/Dolphin/copyFullPath.sh b/Dolphin/copyFullPath.sh new file mode 100644 index 0000000..8e24ec5 --- /dev/null +++ b/Dolphin/copyFullPath.sh @@ -0,0 +1,7 @@ +#! /bin/bash +#printf "$@" | xsel -b -i +filelist="" +for line in "$@"; do + filelist="$filelist$line\n" +done +printf "$filelist" | xsel -b -i diff --git a/Dolphin/copyName.sh b/Dolphin/copyName.sh new file mode 100644 index 0000000..a260fc3 --- /dev/null +++ b/Dolphin/copyName.sh @@ -0,0 +1,7 @@ +#! /bin/bash +filelist="" +for line in "$@"; do + filename=$(basename -- "$line") + filelist="$filelist$filename\n" +done +printf "$filelist" | xsel -b -i diff --git a/Dolphin/copyPath.sh b/Dolphin/copyPath.sh new file mode 100644 index 0000000..bb113a6 --- /dev/null +++ b/Dolphin/copyPath.sh @@ -0,0 +1,8 @@ +#! /bin/bash +filelist="" +for line in "$@"; do + filename=$(basename -- "$line") + folder=${line%"$filename"} + filelist="$filelist$folder\n" +done +printf "$filelist" | xsel -b -i diff --git a/Dolphin/extract.desktop b/Dolphin/extract.desktop new file mode 100644 index 0000000..c169a71 --- /dev/null +++ b/Dolphin/extract.desktop @@ -0,0 +1,14 @@ +# Copyright 2019 Bruno Fontes + +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +MimeType=application/octet-stream;inode/directory +Actions=extract +X-KDE-Priority=TopLevel +X-KDE-Submenu=BFExtract + +[Desktop Action extract] +Name=Extract +Name[pt_BR]=Extrair +Exec=bash ~/.local/share/kservices5/ServiceMenus/extract.sh %F diff --git a/Dolphin/extract.sh b/Dolphin/extract.sh new file mode 100755 index 0000000..02b1392 --- /dev/null +++ b/Dolphin/extract.sh @@ -0,0 +1,23 @@ +#!/bin/bash +file="$1" +foldername="$(echo "$file" | sed 's/\(.*\)\..*/\1/')/" + +if [ -f "$file" ] ; then + case "$file" in + *.tar.bz2) tar xvjf "$file" -C "$foldername" ;; + *.tar.gz) tar xvzf "$file" -C "$foldername" ;; + *.bz2) bunzip2 "$file" "$foldername" ;; + *.rar) unrar x "$file" "$foldername" ;; + *.gz) gunzip "$file" "$foldername" ;; + *.tar) tar xvf "$file" -C "$foldername" ;; + *.tbz2) tar xvjf "$file" -C "$foldername" ;; + *.tgz) tar xvzf "$file" -C "$foldername" ;; + *.zip) unzip "$file" -d "$foldername" ;; + *.Z) uncompress "$file" "$foldername" ;; + *.7z) 7z x "$file" -o "$foldername" ;; + *) echo "'$file' cannot be extracted via >extract<" ;; + esac +else + echo "'$file' is not a valid file" +fi + diff --git a/Dolphin/{}-file b/Dolphin/{}-file new file mode 100644 index 0000000..e69de29 diff --git a/KDE/OXO.sh b/KDE/OXO.sh new file mode 100755 index 0000000..15e4c56 --- /dev/null +++ b/KDE/OXO.sh @@ -0,0 +1,3 @@ +#!/bin/sh +kactivities-cli --stop-activity `kactivities-cli --list-activities | grep "Main" | cut -d' ' -f2` +notify-send --icon=`kactivities-cli --list-activities | grep "OXO" | cut -d' ' -f4` -a "OXO Innovation" "Main profile closed" diff --git a/Pacman/updateRepositories.sh b/Pacman/updateRepositories.sh index 1b001ab..da3615d 100755 --- a/Pacman/updateRepositories.sh +++ b/Pacman/updateRepositories.sh @@ -2,30 +2,31 @@ BOLD='\e[91m' NC='\e[39m' function bold() { - echo -e "${BOLD}$1${NC}" + echo -e "\n\n${BOLD}$1${NC}" } function s() { - echo -e "$sudoPass\n" | sudo -S $1 - echo + sudo $* } -sudo -k -echo -n Please type your sudo password: -read -s sudoPass -echo -s "echo '**********'" +s -v +bold "Pacman-mirrors --continent" +s "pacman-mirrors --continent" 2>/dev/null +# s "pacman-mirrors -c Brazil" 2>/dev/null +s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" 2>/dev/null -bold "Pacman-mirrors -c" -s "pacman-mirrors -c Brazil" -s "reflector -l 30 -f 10 --save /etc/pacman.d/mirrorlist" +# From now on, exit when any command fails +set -e -#bold "Updating with YAY..." -s "echo" -yes | yay -Syu --diffmenu --noconfirm --color always +s -v +bold "Updating..." +yay -Syu --sudoloop --answerclean none --answerdiff all --answerupgrade none --noremovemake --nobatchinstall --cleanafter]] bold "Cleaning stuff..." -s "echo" -yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always) +s -v +yay -Sc --noconfirm 2>/dev/null +s -v +yes | (sudo -S pacman -Rns $(pacman -Qtdq) --color always 2>/dev/null) +s -k notify-send "Update script has finished!" diff --git a/Screen/desktop.sh b/Screen/desktop.sh new file mode 100755 index 0000000..9a5f6ae --- /dev/null +++ b/Screen/desktop.sh @@ -0,0 +1,3 @@ +#!/bin/sh +xrandr --output HDMI-1 --mode 1920x1080 +xrandr --output HDMI-2 --mode 1920x1080 diff --git a/Screen/new_laptop.sh b/Screen/new_laptop.sh new file mode 100755 index 0000000..6444fb6 --- /dev/null +++ b/Screen/new_laptop.sh @@ -0,0 +1,5 @@ +#!/bin/sh +setxkbmap -model abnt2 -layout br -variant ,abnt2 +xrandr --output HDMI-1 --mode 1280x720 #Max resolution monitor can do that fits blackout +xrandr --output HDMI-1 --mode 1366x768 #Max resolution monitor can do that fits blackout +xrandr --output HDMI-2 --mode 1366x768 diff --git a/Screen/old_laptop.sh b/Screen/old_laptop.sh new file mode 100755 index 0000000..e6cebb9 --- /dev/null +++ b/Screen/old_laptop.sh @@ -0,0 +1,4 @@ +#!/bin/sh +setxkbmap -model abnt2 -layout br -variant ,abnt2 +xrandr --output HDMI-1 --mode 1280x800 +xrandr --output HDMI-2 --mode 1280x800 diff --git a/Services/.localBackupPath_TEMPLATE b/Services/.localBackupPath_TEMPLATE new file mode 100644 index 0000000..1c7c918 --- /dev/null +++ b/Services/.localBackupPath_TEMPLATE @@ -0,0 +1 @@ +/my/local/backup diff --git a/Services/.serverBackupPath_TEMPLATE b/Services/.serverBackupPath_TEMPLATE new file mode 100644 index 0000000..deca4eb --- /dev/null +++ b/Services/.serverBackupPath_TEMPLATE @@ -0,0 +1 @@ +sshBackupUser@serverIp:/my/backup/path diff --git a/Services/.sshKey_TEMPLATE b/Services/.sshKey_TEMPLATE new file mode 100644 index 0000000..156085f --- /dev/null +++ b/Services/.sshKey_TEMPLATE @@ -0,0 +1 @@ +/home/myUser/.ssh/id_rsa_backup diff --git a/Services/after-wakeup.service b/Services/after-wakeup.service old mode 100644 new mode 100755 index 755f433..65439f8 --- a/Services/after-wakeup.service +++ b/Services/after-wakeup.service @@ -1,6 +1,7 @@ [Unit] Description=Bruno Fontes script after wakeup After=suspend.target +OnFailure=logErrors@%n.service [Service] Type=simple diff --git a/Services/backup-contabo-db.service b/Services/backup-contabo-db.service deleted file mode 100644 index 83f2e7d..0000000 --- a/Services/backup-contabo-db.service +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Description=Backup contabo db daily - -[Service] -ExecStart=/home/bruno/Backups/Contabo/backup-db.sh diff --git a/Services/backup-contabo-files.service b/Services/backup-contabo-files.service deleted file mode 100644 index 01c813e..0000000 --- a/Services/backup-contabo-files.service +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Description=Backup contabo files once per week - -[Service] -ExecStart=/home/bruno/Backups/Contabo/backup-files.sh diff --git a/Services/backup-contabo.env b/Services/backup-contabo.env new file mode 100644 index 0000000..eb63459 --- /dev/null +++ b/Services/backup-contabo.env @@ -0,0 +1 @@ +CONTABO_BACKUP_PATH="/home/bruno/Backups/Contabo" diff --git a/Services/backup-contabo.service b/Services/backup-contabo.service new file mode 100755 index 0000000..e5b714f --- /dev/null +++ b/Services/backup-contabo.service @@ -0,0 +1,7 @@ +[Unit] +Description=Backup contabo daily +OnFailure=logErrors@%n.service + +[Service] +ExecStart=/home/bruno/Backups/Contabo/backup-contabo.sh +EnvironmentFile=/home/bruno/Apps/linuxShortcuts/Services/backup-contabo.env diff --git a/Services/backup-contabo.sh b/Services/backup-contabo.sh new file mode 100755 index 0000000..e713cb3 --- /dev/null +++ b/Services/backup-contabo.sh @@ -0,0 +1,38 @@ +#! /bin/bash + +if [[ `nmcli -t -f GENERAL.METERED dev show | grep "METERED:yes"` ]]; then + echo Backup does not work on metered connections + exit 1 +fi + +if [[ -z $CONTABO_BACKUP_PATH ]]; then + echo CONTABO_BACKUP_PATH environment not set + exit 1 +fi +sleep 60 + +# Backup Contabo +/bin/rsync --archive --backup --exclude "files/nextcloud*" --rsh=ssh backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH + +# Backup Gitea +/bin/rsync --archive --backup --rsh=ssh bkpgitea:~/ttt/* ~/Backups/gitea/ + +# Backup OXO Files +/bin/rsync --archive --backup --rsh=ssh oxo:~/public_html ~/Backups/OXOwebsite/ +tar cfz ~/Backups/OXOwebsite/`date '+%Y-%m-%d'`_OXOwebsiteBackup.tar.gz ~/Backups/OXOwebsite/public_html/ +rm -rf ~/Backups/OXOwebsite/public_html/ + +# Backup OXO DB +ssh oxo ./backupDB.sh +/bin/rsync --archive --backup --compress --rsh=ssh oxo:~/db/* ~/Backups/OXOwebsite/ +ssh oxo rm ./db/* + +# Delete old backups +find $CONTABO_BACKUP_PATH/db -type f -name "*.sql.gz" -mtime +15 -delete +find $CONTABO_BACKUP_PATH/keys -type f -name "*.*" -mtime +15 -delete +find $CONTABO_BACKUP_PATH/files -type f -name "*.*" -mtime +35 -delete +find $CONTABO_BACKUP_PATH/mail -type f -name "*.*" -mtime +20 -delete +find $CONTABO_BACKUP_PATH/ -type f -name "*.*" -mtime +120 -delete + +find ~/Backups/OXOwebsite/ -type f -name "*.gz" -mtime +15 -delete +find ~/Backups/gitea/ -type f -name "*.zip" -mtime +15 -delete diff --git a/Services/backup-contabo-db.timer b/Services/backup-contabo.timer old mode 100644 new mode 100755 similarity index 59% rename from Services/backup-contabo-db.timer rename to Services/backup-contabo.timer index 4f75156..1abd42f --- a/Services/backup-contabo-db.timer +++ b/Services/backup-contabo.timer @@ -1,10 +1,11 @@ [Unit] -Description=Backup contabo db dayly +Description=Backup contabo daily [Timer] -#DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=*-*-* 10:00:00 Persistent=true +OnCalendar=*-*-* 10:15:00 +WakeSystem=true +#DayOfWeek Year-Month-Day Hour:Minute:Second [Install] WantedBy=timers.target diff --git a/Services/backup-joplin.service b/Services/backup-joplin.service new file mode 100755 index 0000000..7a7634a --- /dev/null +++ b/Services/backup-joplin.service @@ -0,0 +1,7 @@ +[Unit] +Description=Backup joplin weekly +OnFailure=logErrors@%n.service + +[Service] +User=bruno +ExecStart=/home/bruno/Apps/linuxShortcuts/Services/backup-joplin.sh diff --git a/Services/backup-joplin.sh b/Services/backup-joplin.sh new file mode 100755 index 0000000..a251259 --- /dev/null +++ b/Services/backup-joplin.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +BACKUP_DIR="/home/bruno/Backups/Joplin" +JOPLIN_BIN="/usr/bin/joplin" + +$JOPLIN_BIN sync +$JOPLIN_BIN e2ee decrypt + +# Delete old backups +cd "$BACKUP_DIR" +rm -r "./joplin.jex" +rm -rf "./MD" + +$JOPLIN_BIN --log-level debug export --format jex "$BACKUP_DIR/joplin.jex" +$JOPLIN_BIN --log-level debug export --format md "$BACKUP_DIR/MD" diff --git a/Services/backup-contabo-files.timer b/Services/backup-joplin.timer old mode 100644 new mode 100755 similarity index 58% rename from Services/backup-contabo-files.timer rename to Services/backup-joplin.timer index 0e45f51..72f5630 --- a/Services/backup-contabo-files.timer +++ b/Services/backup-joplin.timer @@ -1,10 +1,11 @@ [Unit] -Description=Backup contabo files once per week +Description=Backup joplin weekly [Timer] -#DayOfWeek Year-Month-Day Hour:Minute:Second -OnCalendar=Mon *-*-* 11:00:00 Persistent=true +OnCalendar=Thu *-*-* 10:10:00 +WakeSystem=true +#DayOfWeek Year-Month-Day Hour:Minute:Second [Install] WantedBy=timers.target diff --git a/Services/before-sleep.service b/Services/before-sleep.service old mode 100644 new mode 100755 index 272fee2..d713ad2 --- a/Services/before-sleep.service +++ b/Services/before-sleep.service @@ -1,6 +1,7 @@ [Unit] Description=Bruno Fontes script before sleep Before=sleep.target +OnFailure=logErrors@%n.service [Service] Type=oneshot diff --git a/Services/fixInternetAfterSleep.sh b/Services/fixInternetAfterSleep.sh new file mode 100755 index 0000000..2f7323f --- /dev/null +++ b/Services/fixInternetAfterSleep.sh @@ -0,0 +1,5 @@ +sleep 30 +if ! ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then + modProbeNumber=$(sudo dmesg | grep -m1 "enp1s0: link down" | awk '{if ($2 ~ /r[0-9].*/) { col=$2 } else { col=$3 }; gsub(":", "", col); print col }') + sudo modprobe -r "$modProbeNumber" && sleep 10 && sudo modprobe "$modProbeNumber" +fi diff --git a/Services/installSystemService.sh b/Services/installSystemService.sh new file mode 100755 index 0000000..ed7f43c --- /dev/null +++ b/Services/installSystemService.sh @@ -0,0 +1,4 @@ +doas rm /etc/systemd/system/$1 +doas cp -f $1 /etc/systemd/system/ +doas systemctl daemon-reload +doas systemctl status $1 diff --git a/Services/logErrors@.service b/Services/logErrors@.service old mode 100644 new mode 100755 diff --git a/Services/mbsync.service b/Services/mbsync.service new file mode 100644 index 0000000..8aa13d6 --- /dev/null +++ b/Services/mbsync.service @@ -0,0 +1,7 @@ +[Unit] +Description=Mailbox synchronization service + +[Service] +Type=oneshot +ExecStart=/usr/bin/mbsync -Va +ExecStartPost=/home/bruno/dotfiles/mutt/notmuch-hook.sh diff --git a/Services/mbsync.timer b/Services/mbsync.timer new file mode 100644 index 0000000..82ebb83 --- /dev/null +++ b/Services/mbsync.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Mailbox synchronization timer + +[Timer] +OnBootSec=2m +OnUnitActiveSec=5m +Unit=mbsync.service + +[Install] +WantedBy=timers.target diff --git a/Services/minecraft-hour.service b/Services/minecraft-hour.service new file mode 100755 index 0000000..d11612b --- /dev/null +++ b/Services/minecraft-hour.service @@ -0,0 +1,7 @@ +[Unit] +Description=Minecraft Informa a Hora Certa +OnFailure=logErrors@%n.service + +[Service] +User=bruno +ExecStart=/bin/sh /home/bruno/Apps/linuxShortcuts/Services/minecraft-hour.sh diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh new file mode 100755 index 0000000..16c9ab9 --- /dev/null +++ b/Services/minecraft-hour.sh @@ -0,0 +1,96 @@ +if screen -list | grep -q "MncftPublic"; then + publicBackup="true" +fi +if screen -list | grep -q "Minecraft"; then + otherBackup="true" +fi + +if [[ -z $publicBackup && -z $otherBackup ]] ; then + echo "Minecraft is not running. Exiting..." + exit 0 +fi + +BACKUPDIR="/home/bruno/Backups/Minecraft-borg" +SERVERDIR="/home/bruno/Apps/Minecraft" +PUBLICDIR="$SERVERDIR/BedrockServer_Public_19132" +SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132" +CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134" +PATHTOBACKUP="" +LogFile="log.txt" + +BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") + +alias run='screen -S Minecraft -X' +alias runSurvival='run at Survival stuff' +alias runCreative='run at Creative stuff' +alias runPublic='screen -S MncftPublic -X at Server stuff' +alias runAllWorlds='run at "#" stuff' + +cd /home/bruno/Apps/Minecraft + +runAllWorlds "^u" +# runAllWorlds "say $(date +%l:%M) - Saving worlds\n" +runPublic "say ^usave hold\n" +runAllWorlds "^usave hold\n" +sleep 2s + + +if [[ $publicBackup ]]; then + echo Preparing public + finishedPublic="" + timeout=30 + while [[ $finishedPublic != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Public world" + echo "Error Public $timeout" + exit 1 + fi + (( timeout-- )) + sleep 1s + echo $tmeout + runPublic "^usave query\n" + finishedPublic=$(tail -n 4 "$PUBLICDIR/$LogFile") + PATHTOBACKUP="$PATHTOBACKUP \"$PUBLICDIR\"" + done + echo "Passou Public" +fi + +if [[ $otherBackup ]]; then + echo Preparing others + finishedCreative="" + timeout=30 + while [[ $finishedCreative != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Creative world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runCreative "^u" + runCreative "save query\n" + finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") + done + PATHTOBACKUP="$PATHTOBACKUP \"$CREATIVEDIR\"" + + timeout=30 + finishedSurvival="" + while [[ $finishedSurvival != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Survival world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runSurvival "^u" + runSurvival "save query\n" + finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") + done + PATHTOBACKUP="$PATHTOBACKUP \"$SURVIVALDIR\"" +fi + +[[ $PATHTOBACKUP ]] && borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE" "$PATHTOBACKUP" + +[[ $publicBackup ]] && runPublic "say ^usave resume\n" +[[ $otherBackup ]] && runSurvival "say ^usave resume\n" && runCreative "say ^usave resume\n" + +borg prune --keep-within=3d --keep-hourly=96 --keep-weekly=8 --keep-monthly=6 "$BACKUPDIR" diff --git a/Services/minecraft-hour.timer b/Services/minecraft-hour.timer new file mode 100755 index 0000000..8846602 --- /dev/null +++ b/Services/minecraft-hour.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Minecraft Informa a Hora Certa +Requires=minecraft-hour.service + +[Timer] +Unit=minecraft-hour.service +OnCalendar=*-*-* *:0,15,30,45:00 +#DayOfWeek Year-Month-Day Hour:Minute:Second +AccuracySec=1s + +[Install] +WantedBy=timers.target diff --git a/Services/minecraft-server-public.sh b/Services/minecraft-server-public.sh new file mode 100644 index 0000000..36b8308 --- /dev/null +++ b/Services/minecraft-server-public.sh @@ -0,0 +1,50 @@ +if ! screen -list | grep -q "Minecraft"; then + exit 1 +fi + +BACKUPDIR="/home/bruno/Backups/zBackup-Minecraft/backups" +SERVERDIR="/home/bruno/Apps/Minecraft/BedrockServer_Public_19132" +LogFile="log.txt" + +alias run='screen -S MinecraftPublic -X' +alias runAllWorlds='run at "#" stuff' + +runAllWorlds "^u" +runAllWorlds "save hold\n" +sleep 2s + +finishedCreative="" +timeout=30 +while [[ $finishedCreative != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Creative world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runCreative "^u" + runCreative "save query\n" + finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile") +done + +timeout=30 +finishedSurvival="" +while [[ $finishedSurvival != *"Data saved."* ]]; do + if [[ $timeout -lt 1 ]]; then + notify-send "Error backuping Survival world" + exit 1 + fi + (( timeout-- )) + sleep 1s + runSurvival "^u" + runSurvival "save query\n" + finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile") +done + +BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S") +mkdir "$BACKUPDIR/$BACKUPDATE" +/bin/tar c "$SURVIVALDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Survival" +/bin/tar c "$CREATIVEDIR/worlds" | zbackup --non-encrypted backup "$BACKUPDIR/$BACKUPDATE/Creative" + +runAllWorlds "^u" +runAllWorlds "save resume\n" diff --git a/Services/minecraft-stop.service b/Services/minecraft-stop.service new file mode 100755 index 0000000..c75902c --- /dev/null +++ b/Services/minecraft-stop.service @@ -0,0 +1,12 @@ +[Unit] +Description=Properly shutdown Minecraft before PC shutdown +OnFailure=logErrors@%n.service + +[Service] +Type=oneshot +RemainAfterExit=true +User=bruno +ExecStop=/bin/sh /home/bruno/Apps/Minecraft/stopServers.sh + +[Install] +WantedBy=multi-user.target diff --git a/Services/roothints.service b/Services/roothints.service new file mode 100755 index 0000000..f6223c9 --- /dev/null +++ b/Services/roothints.service @@ -0,0 +1,7 @@ +[Unit] +Description=Update root hints for unbound +After=network.target +OnFailure=logErrors@%n.service + +[Service] +ExecStart=/usr/bin/curl -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache diff --git a/Services/roothints.timer b/Services/roothints.timer new file mode 100644 index 0000000..7a4c88c --- /dev/null +++ b/Services/roothints.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run root.hints monthly + +[Timer] +OnCalendar=monthly +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/Services/testDNS.service b/Services/testDNS.service new file mode 100755 index 0000000..d707c6f --- /dev/null +++ b/Services/testDNS.service @@ -0,0 +1,12 @@ +[Unit] +Description=Test and fix DNS update with wrong time +Wants=network-online.target +After=network-online.target +OnFailure=logErrors@%n.service + +[Service] +Type=oneshot +ExecStart = /bin/bash /home/bruno/Apps/linuxShortcuts/Services/fixDNS.sh + +[Install] +WantedBy=multi-user.target diff --git a/Services/updateRootHints.service b/Services/updateRootHints.service old mode 100644 new mode 100755 index 10f0902..13fbb1d --- a/Services/updateRootHints.service +++ b/Services/updateRootHints.service @@ -1,6 +1,7 @@ [Unit] Description=Run update DNS root hints montly +OnFailure=logErrors@%n.service [Service] Type=oneshot -ExecStart = /bin/bash /home/bruno/dns_update_rootHints.sh +ExecStart = /bin/bash /home/bruno/Apps/linuxShortcuts/Services/roothints.sh diff --git a/Services/xpra@.service b/Services/xpra@.service new file mode 100644 index 0000000..bac1950 --- /dev/null +++ b/Services/xpra@.service @@ -0,0 +1,11 @@ +[Unit] +Description=xpra display + +[Service] +Type=simple +User=%i +EnvironmentFile=/etc/conf.d/xpra +ExecStart=/usr/bin/xpra --no-daemon start ${%i} + +[Install] +WantedBy=multi-user.target diff --git a/browser.sh b/browser.sh new file mode 100755 index 0000000..2f2d966 --- /dev/null +++ b/browser.sh @@ -0,0 +1,20 @@ +#!/bin/bash +activity=`kactivities-cli --current-activity | cut -d" " -f3` + +if [[ $1 =~ .*youtube\.com.* ]]; then + /bin/freetube "$*" >/dev/null 2>&1 & + exit +fi + +if [[ $1 =~ .*\&incognitottt$ ]]; then + url="${1/\&incognitottt/}" + [[ $activity == "OXO" ]] && /bin/brave --incognito "$url" >/dev/null 2>&1 & + [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin --private-window "$url" >/dev/null 2>&1 & + [[ $activity == "Main" ]] && /bin/firefox --private-window "$url" >/dev/null 2>&1 & + [[ $activity == "Videos" ]] && /bin/firefox --private-window "$url" >/dev/null 2>&1 & +else + [[ $activity == "OXO" ]] && /bin/brave "$1" >/dev/null 2>&1 & + [[ $activity == "Development" ]] && /home/bruno/Apps/firefox/firefox-bin "$1" >/dev/null 2>&1 & + [[ $activity == "Main" ]] && /bin/firefox "$1" >/dev/null 2>&1 & + [[ $activity == "Videos" ]] && /bin/firefox "$1" >/dev/null 2>&1 & +fi diff --git a/music/spotify b/music/spotify deleted file mode 100755 index cbaad9b..0000000 --- a/music/spotify +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -P|--play) - qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play - shift - ;; - -p|--pause) - qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause - shift - ;; - *) - echo "Usage:" - echo "-P (--play) - Play" - echo "-p (--pause) - Pause" - exit 3 - ;; -esac -done -if [[ $# -ne $1 ]]; then - echo "Usage:" - echo "-P (--play) - Play" - echo "-p (--pause) - Pause" -fi - diff --git a/start-dashboard b/start-dashboard new file mode 100755 index 0000000..064205a --- /dev/null +++ b/start-dashboard @@ -0,0 +1,51 @@ +#!/bin/sh + +if [[ $(tmux ls | grep 'dashboard') ]]; then + terminator -T "Dashboard" -x tmux a -t dashboard & + exit +fi +echo "Iniciando Dashboard..." +sleep 2 +tmux new -d -s dashboard +tmux rename-window -t dashboard "Dashboard" +terminator -T "Dashboard" -x tmux a -t dashboard & +sleep 10 +tmux splitw -t dashboard +tmux splitw -h -t dashboard:0.0 +tmux resize-pane -U -t dashboard:0.2 15 +tmux resize-pane -L -t dashboard:0.1 10 +sleep 1 + +# 0 - Dashboard/khal +tmux send -t dashboard:0.0 $'clear;watch --interval $((30 * 60)) --no-title --color screenfetch\n' +tmux send -t dashboard:0.1 $'alias clear="clear;figlet Dashboard; echo -n Khal:\ ; khal list; echo;"\n' +tmux send -t dashboard:0.2 $'btop\n' +tmux send -t dashboard:0.1 $'clear\n' + +# 1 - Tut +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:1.0 $'tut\n' +tmux rename-window -t dashboard:1 tut +tmux setw monitor-activity -t dashboard:1 + +# 2 - GoMuks +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:2.0 $'gomuks\n' +tmux rename-window -t dashboard:2 gomuks + +# 3 - NeoMutt +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:3.0 $'sleep 120 && neomutt\n' +tmux rename-window -t dashboard:3 neomutt + +# 4 - Joplin +tmux new-window -t dashboard +sleep 1 +tmux send -t dashboard:4.0 $'joplin\n' +tmux rename-window -t dashboard:4 joplin + +tmux select-window -t dashboard:0 +tmux setw monitor-silence -t dashboard:0 diff --git a/startPMovase.sh b/startPMovase.sh new file mode 100755 index 0000000..4545ebd --- /dev/null +++ b/startPMovase.sh @@ -0,0 +1,24 @@ +cd /run/media/bruno/Multimedia/MyDocuments/Development/projetomovase +if [[ $(screen -ls | grep 'pmovase') ]]; then + echo "Já está rodando, saindo..." + exit +fi +echo "Iniciando Vagrant..." +screen -dmS pmovase +screen -S pmovase -p 0 -X stuff $'npm run vagrant; npm run watch\n' +screen -S pmovase -X screen +screen -S pmovase -X screen +sleep 2s +screen -S pmovase -p 2 -X title $'GIT' + +sleep 2m +screen -S pmovase -p 0 -X title $'NPM WATCH\n' +screen -S pmovase -p 1 -X stuff $'npm run ssh\n' +sleep 5s +screen -S pmovase -p 1 -X title $'Artisan' + +screen -S pmovase -X select 2 +screen -S pmovase -p 1 -X echo $'Done!\n' +screen -S pmovase -p 2 -X echo $'Done!\n' + +echo "Screen running. Attach to it with 'screen -r pmovase'" diff --git a/stop-pmovase.sh b/stop-pmovase.sh new file mode 100755 index 0000000..b4a3044 --- /dev/null +++ b/stop-pmovase.sh @@ -0,0 +1,13 @@ +#!/bin/zsh +#if [[ !$(tmux ls | grep 'pmovase') ]]; then +# exit +#fi + +killall /home/bruno/Apps/firefox/firefox-bin +killall /bin/vscodium + +cd /home/bruno/development/projetomovase/ +vagrant suspend +tmux send -t pmovase:0.4 $'^u' +#tmux send -t pmovase:0.4 $'vagrant suspend &\n' +tmux kill-session -t pmovase diff --git a/tmuxStartDicionarios.sh b/tmuxStartDicionarios.sh new file mode 100755 index 0000000..97eeb9a --- /dev/null +++ b/tmuxStartDicionarios.sh @@ -0,0 +1,21 @@ +#!/bin/zsh + +projectName=dicionarioscc +cd /run/media/bruno/Multimedia/MyDocuments/Development/BrunoFontes/dicionarios.cc/ +if [[ $(tmux ls | grep '$projectName') ]]; then + uxterm -T $projectName -geometry 627x927 -e tmux a -t $projectName & + exit +fi + +tmux new -d -s $projectName + +tmux splitw -ht $projectName +tmux splitw -vt $projectName:0.1 +tmux splitw -vt $projectName:0.2 + +uxterm -T $projectName -geometry 627x927 -e tmux a -t $projectName & + +tmux send -t $projectName:0.0 $'nvim\n' +tmux send -t $projectName:0.1 $'make dev\n' +tmux send -t $projectName:0.2 $'tail -f src/dicio.log\n' +tmux send -t $projectName:0.3 $'gss\n' diff --git a/tmuxStartPMOvase.sh b/tmuxStartPMOvase.sh new file mode 100755 index 0000000..3db8f4c --- /dev/null +++ b/tmuxStartPMOvase.sh @@ -0,0 +1,38 @@ +#!/bin/zsh +cd /run/media/bruno/Multimedia/MyDocuments/Development/projetomovase +if [[ $(tmux ls | grep 'pmovase') ]]; then + terminator -T PMova-se -b --geometry=627x927 -x tmux a -t pmovase & + exit +fi + +echo "Iniciando Vagrant..." +tmux new -d -s pmovase + +tmux splitw -t pmovase +tmux splitw -t pmovase +tmux splitw -t pmovase +tmux splitw -h -t pmovase:0.1 + +terminator -T PMova-se -b --geometry=627x927 -x tmux a -t pmovase & + +tmux resize-pane -t pmovase:0.0 -U 35 +tmux resize-pane -t pmovase:0.1 -U 10 +tmux resize-pane -t pmovase:0.4 -U 10 + +tmux send -t pmovase:0.0 $'npm run vagrant; npm run watch\n' +tmux send -t pmovase:0.2 $'clear; echo Waiting for vagrant to start...\n' + +while [[ -z $(ping projetomovase.test -c 1 | grep "time=") ]] ; do + sleep 5 +done +sleep 10 + +tmux send -t pmovase:0.1 $'npm run cypress:open\n' +tmux send -t pmovase:0.1 $'npm run test-watch\n' +tmux send -t pmovase:0.2 $'^u' +tmux send -t pmovase:0.2 $'npm run test-php-watch\n' +tmux send -t pmovase:0.3 $'npm run ssh\n' +tmux send -t pmovase:0.4 $'alias clear=\'clear;figlet PMova-se\';clear\n' + +/bin/vscodium & +/home/bruno/Apps/firefox/firefox-bin & diff --git a/turnOffMonitor.sh b/turnOffMonitor.sh new file mode 100755 index 0000000..52e751d --- /dev/null +++ b/turnOffMonitor.sh @@ -0,0 +1 @@ +xset -display :0.0 dpms force off diff --git a/video.sh b/video.sh new file mode 100755 index 0000000..9ae016b --- /dev/null +++ b/video.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo "$1" > ~/.lastVideo +/usr/bin/vlc --started-from-file "$1" 2>/dev/null & diff --git a/xrandr.sh b/xrandr.sh new file mode 100755 index 0000000..3cc2711 --- /dev/null +++ b/xrandr.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +xrandr --output HDMI-2 --left-of HDMI-1