Merge branch 'master' of github.com:brunofontes/linuxShortcuts

This commit is contained in:
Bruno F. Fontes 2022-03-04 14:07:50 -03:00
commit f2471555fd
59 changed files with 798 additions and 124 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.localBackupPath
.serverBackupPath
.sshKeyBackupPath
.sshKey
Backup/.lastDisk

136
Backup/.Backup_HD.sh Executable file
View File

@ -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

View File

@ -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

1
Backup/.lastDisk Normal file
View File

@ -0,0 +1 @@
2

View File

@ -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

7
Backup/listBackups.sh Executable file
View File

@ -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

View File

@ -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 &

3
Backup/zRestore.sh Executable file
View File

@ -0,0 +1,3 @@
date
zbackup --non-encrypted --silent --cache-size 512mb restore $1 > $2
date

24
Dolphin/bf-copy.desktop Normal file
View File

@ -0,0 +1,24 @@
# Copyright 2019 Bruno Fontes <outros+dev@m.brunofontes.net>
[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

7
Dolphin/copyFullPath.sh Normal file
View File

@ -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

7
Dolphin/copyName.sh Normal file
View File

@ -0,0 +1,7 @@
#! /bin/bash
filelist=""
for line in "$@"; do
filename=$(basename -- "$line")
filelist="$filelist$filename\n"
done
printf "$filelist" | xsel -b -i

8
Dolphin/copyPath.sh Normal file
View File

@ -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

14
Dolphin/extract.desktop Normal file
View File

@ -0,0 +1,14 @@
# Copyright 2019 Bruno Fontes <outros+dev@m.brunofontes.net>
[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

23
Dolphin/extract.sh Executable file
View File

@ -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

0
Dolphin/{}-file Normal file
View File

3
KDE/OXO.sh Executable file
View File

@ -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"

View File

@ -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!"

3
Screen/desktop.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
xrandr --output HDMI-1 --mode 1920x1080
xrandr --output HDMI-2 --mode 1920x1080

5
Screen/new_laptop.sh Executable file
View File

@ -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

4
Screen/old_laptop.sh Executable file
View File

@ -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

View File

@ -0,0 +1 @@
/my/local/backup

View File

@ -0,0 +1 @@
sshBackupUser@serverIp:/my/backup/path

View File

@ -0,0 +1 @@
/home/myUser/.ssh/id_rsa_backup

1
Services/after-wakeup.service Normal file → Executable file
View File

@ -1,6 +1,7 @@
[Unit]
Description=Bruno Fontes script after wakeup
After=suspend.target
OnFailure=logErrors@%n.service
[Service]
Type=simple

View File

@ -1,5 +0,0 @@
[Unit]
Description=Backup contabo db daily
[Service]
ExecStart=/home/bruno/Backups/Contabo/backup-db.sh

View File

@ -1,5 +0,0 @@
[Unit]
Description=Backup contabo files once per week
[Service]
ExecStart=/home/bruno/Backups/Contabo/backup-files.sh

View File

@ -0,0 +1 @@
CONTABO_BACKUP_PATH="/home/bruno/Backups/Contabo"

View File

@ -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

38
Services/backup-contabo.sh Executable file
View File

@ -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

View File

@ -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

7
Services/backup-joplin.service Executable file
View File

@ -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

15
Services/backup-joplin.sh Executable file
View File

@ -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"

View File

@ -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

1
Services/before-sleep.service Normal file → Executable file
View File

@ -1,6 +1,7 @@
[Unit]
Description=Bruno Fontes script before sleep
Before=sleep.target
OnFailure=logErrors@%n.service
[Service]
Type=oneshot

View File

@ -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

View File

@ -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

0
Services/logErrors@.service Normal file → Executable file
View File

7
Services/mbsync.service Normal file
View File

@ -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

10
Services/mbsync.timer Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Mailbox synchronization timer
[Timer]
OnBootSec=2m
OnUnitActiveSec=5m
Unit=mbsync.service
[Install]
WantedBy=timers.target

View File

@ -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

96
Services/minecraft-hour.sh Executable file
View File

@ -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"

12
Services/minecraft-hour.timer Executable file
View File

@ -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

View File

@ -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"

12
Services/minecraft-stop.service Executable file
View File

@ -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

7
Services/roothints.service Executable file
View File

@ -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

9
Services/roothints.timer Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=Run root.hints monthly
[Timer]
OnCalendar=monthly
Persistent=true
[Install]
WantedBy=timers.target

12
Services/testDNS.service Executable file
View File

@ -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

3
Services/updateRootHints.service Normal file → Executable file
View File

@ -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

11
Services/xpra@.service Normal file
View File

@ -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

20
browser.sh Executable file
View File

@ -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

View File

@ -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

51
start-dashboard Executable file
View File

@ -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

24
startPMovase.sh Executable file
View File

@ -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'"

13
stop-pmovase.sh Executable file
View File

@ -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

21
tmuxStartDicionarios.sh Executable file
View File

@ -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'

38
tmuxStartPMOvase.sh Executable file
View File

@ -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 &

1
turnOffMonitor.sh Executable file
View File

@ -0,0 +1 @@
xset -display :0.0 dpms force off

3
video.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo "$1" > ~/.lastVideo
/usr/bin/vlc --started-from-file "$1" 2>/dev/null &

3
xrandr.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
xrandr --output HDMI-2 --left-of HDMI-1