Sync fixed

This commit is contained in:
2023-04-09 20:46:09 +02:00
parent a2bdf977d9
commit 22b71a2f59

View File

@@ -2,56 +2,72 @@
# To-do: Add Eww widgets or other interface # To-do: Add Eww widgets or other interface
theme="~/Scripts/Temas/" theme="~/Scripts/rofi/"
server_routes=("Anotaciones" "Universidad/Segundo[[:space:]]Cuatrimestre/" "Universidad/TFG/") server_routes=("Anotaciones" "Universidad/Segundo[[:space:]]Cuatrimestre/" "Universidad/TFG/")
local_full=("Documents/Anotaciones/" "Documents/Proyectos/" "Documents/Universidad/" "Images/Carteles[[:space:]]OZ/" "Images/Proyectos/") images=("Images/Carteles[[:space:]]OZ/" "Images/Proyectos/" "Images/Croquis[[:space:]]Heras[[:space:]]C.B")
docs=("Documents/Anotaciones/" "Documents/Proyectos/" "Documents/Universidad/")
music="Music/"
videos=("Videos/Proyectos/")
dotfiles=(".bashrc" ".config/nvim/" ".config/polybar/" ".config/i3/" ".config/mpd/" ".config/ncmpcpp/" ".config/mpv/" ".config/nemo/" ".config/dunst/" ".config/glava/" ".config/ranger/" ".config/sxhkd/" ".config/picom.conf") ask_operation(){
rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Action' -width 12 -line-padding 3 -lines 2 -theme /home/danih/Scripts/rofi/sinc.rasi <<< "PUSH|PULL"
}
ask_net(){
rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Network' -width 12 -line-padding 3 -lines 2 -theme /home/danih/Scripts/rofi/sinc.rasi <<< "LAN|WAN"
}
net="$(rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Network' -width 12 -line-padding 3 -lines 2 -theme /home/danih/Scripts/Temas/sinc.rasi <<< "LAN|WAN")" ask_what_to_sync(){
case "$net" in rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Files To Sync' -width 12 -line-padding 3 -lines 2 -theme /home/danih/Scripts/rofi/sinc.rasi <<< "Full|Documents|Images|Videos|Music"
LAN) }
operation="$(rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Action' -width 12 -line-padding 3 -lines 2 -theme /home/danih/Scripts/Temas/sinc.rasi <<< "PUSH|PULL")"
case "$operation" in net=$(ask_net &)
PUSH) operation=$(ask_operation &)
origin="/home/danih/" files_to_sync=$(ask_what_to_sync &)
dest="dqnid@192.168.0.109:/home/dqnid/" if test "$net" == "WAN"; then
;; for i in "${server_routes[@]}"
PULL) do
dest="/home/danih/" rsync -vrP -e "ssh -i ~/.ssh/id_rsa_dqnid" --delete-after /home/danih/Documents/$i dqnid@dqnid.com:/home/dqnid/Documents
origin="dqnid@192.168.0.109:/home/dqnid/" if test $? -eq 0; then
;; notify-send "Éxito - $i" "$i sincronizadas correctamente"
esac else
files_to_sync="$(rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Files To Sync' -width 12 -line-padding 3 -lines 2 -theme /home/danih/Scripts/Temas/sinc.rasi <<< "Documents|Images|Videos|Music|Dotfiles|All")" notify-send "Error - $i" "Fallo en sincronización de $i"
case "$files_to_sync" in fi
Documents | Images | Videos | Music) done
for dir in "$origin$files_to_sync"/* exit 0
rsync -vrP -e "ssh -i ~/.ssh/id_rsa_dqnid" --delete-after $origin/$dir $dest/$dir else
;; case "$operation" in
Dotfiles) PUSH)
for i in "${dotfiles[@]}" origin="/home/danih/"
do dest="dqnid@192.168.0.109:/home/dqnid/"
rsync -vrP -e "ssh -i ~/.ssh/id_rsa_dqnid" --delete-after $origin/$i $dest/$i ;;
if test $? -eq 0; then PULL)
notify-send "Éxito - $i" "$i sincronizadas correctamente" dest="/home/danih/"
else origin="dqnid@192.168.0.109:/home/dqnid/"
notify-send "Error - $i" "Fallo en sincronización de $i" ;;
fi esac
done case "$files_to_sync" in
;; Documents)
esac for dir in "${docs[@]}"
;; do
WAN) rsync -vrP -e "ssh -i ~/.ssh/id_local" --delete-after $origin/$dir $dest/$dir
for i in "${server_routes[@]}" done
do ;;
rsync -vrP -e "ssh -i ~/.ssh/id_rsa_dqnid" --delete-after /home/danih/Documents/$i dqnid@dqnid.com:/home/dqnid/Documents Images)
if test $? -eq 0; then for dir in "${images[@]}"
notify-send "Éxito - $i" "$i sincronizadas correctamente" do
else rsync -vrP -e "ssh -i ~/.ssh/id_local" --delete-after $origin/$dir $dest/$dir
notify-send "Error - $i" "Fallo en sincronización de $i" done
fi ;;
done Videos)
;; for dir in "${videos[@]}"
esac do
rsync -vrP -e "ssh -i ~/.ssh/id_local" --delete-after $origin/$dir $dest/$dir
done
;;
Music)
rsync -vrP -e "ssh -i ~/.ssh/id_local" --delete-after $origin/Music/ $dest/Music/
;;
esac
fi