Better setup for ESRF

This commit is contained in:
Thomas Dehaeze 2021-11-03 10:58:30 +01:00
parent 705815c64b
commit 859774b005
2 changed files with 83 additions and 107 deletions

View File

@ -317,7 +317,7 @@ export PYTHONPATH="${PYTHONPATH}:/usr/lib/python3.9/site-packages/configobj"
*** Linkding *** Linkding
#+begin_src bash #+begin_src bash
export LINKDING_URL="localhost:9090" export LINKDING_URL=`pass nas/linkding_url`
export LINKDING_TOKEN=`pass nas/linkding_token` export LINKDING_TOKEN=`pass nas/linkding_token`
#+end_src #+end_src

View File

@ -11,22 +11,19 @@
:END: :END:
#+begin_src bash :tangle ~/.local/bin/remote-desktop #+begin_src bash :tangle ~/.local/bin/remote-desktop
computer=$(echo -e 'RNICE\nPCMEL1\nPCNASS1\nPCMEG01' | dmenu -p 'Computer:' -l 20); computer=$(echo -e 'RNICE\nPCDEHAEZE\nPCNASS1' | rofi -dmenu -no-custom -p 'Computer:' -l 20);
dunstify --replace=89891 'Rdesktop' "Connection to ${computer}..." dunstify --replace=89891 'Rdesktop' "Connection to ${computer}..."
case $computer in case $computer in
PCMEL1) PCDEHAEZE)
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass ssl.esrf.fr/dehaeze | sed -n 1p) /v:PCMEL1.esrf.fr; xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:PCDEHAEZE.esrf.fr > /tmp/freerdp_pcdehaeze.log 2>&1 &
;;
PCMEG01)
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass ssl.esrf.fr/dehaeze | sed -n 1p) /v:PCMEG01.esrf.fr;
;; ;;
PCNASS1) PCNASS1)
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass ssl.esrf.fr/dehaeze | sed -n 1p) /v:PCNASS1.esrf.fr; xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:PCNASS1.esrf.fr > /tmp/freerdp_pcnass1.log 2>&1 &
;; ;;
RNICE) RNICE)
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass ssl.esrf.fr/dehaeze | sed -n 1p) /v:rnice.esrf.fr; xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:rnice.esrf.fr > /tmp/freerdp_rnice.log 2>&1 &
;; ;;
,*) ,*)
echo "Not existing" && \ echo "Not existing" && \
@ -35,110 +32,32 @@ case $computer in
esac esac
#+end_src #+end_src
* =print-rnice= - Print on Rnice * =mount-dir= - Mount/Unmout directories
:PROPERTIES: #+begin_src text :tangle no
:CUSTOM_ID: print-rnice # <file system> <mount point> <type> <options> <dump> <pass>
:END: homelab:/srv/storage/ /home/thomas/mnt/NAS fuse.sshfs noauto,allow_other,default_permissions 0 0
#+end_src
#+begin_src bash :tangle ~/.local/bin/print-rnice #+begin_src text :tangle no
nbpage=$(echo -e '1\n2\n4' | dmenu -p 'Number of pages per sheet' -l 20); # <file system> <mount point> <type> <options> <dump> <pass>
sides=$(echo -e 'one-sided\ntwo-sided-long-edge\ntwo-sided-short-edge' | dmenu -p 'Two Sided:' -l 20); dehaeze@rnice:/tmp_14_days/ /home/thomas/mnt/ESRF fuse.sshfs noauto,allow_other,default_permissions 0 0
media=$(echo -e 'A4\nA3' | dmenu -p 'Size:' -l 20); #+end_src
# First copy the file to Rnice #+begin_src bash :tangle ~/.local/bin/mount-dir
if sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@rnice:/home/esrf/dehaeze/Downloads/; then drive=$(echo -e 'ESRF\nNAS' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
# Then print on Rnice
sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" ssh dehaeze@rnice "lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P ctb127c1w \"/home/esrf/dehaeze/Downloads/$1\""; if grep -qs "/home/thomas/mnt/$drive" /proc/mounts; then
# Finally, delete the file umount "/home/thomas/mnt/$drive" && \
dunstify --replace=58249 "$drive " 'Successfully unmounted' || \
dunstify --replace=58249 --urgency=critical "$drive " 'Error while unmounted'
else else
echo "Command Failed" echo "It's not mounted."
mount "/home/thomas/mnt/$drive" && \
dunstify --replace=58249 "$drive " 'Successfully mounted' || \
dunstify --replace=58249 --urgency=critical "$drive " 'Error while mounted'
fi fi
#+end_src #+end_src
* =tmp14= - Mount/Umount tmp_14_days folder
:PROPERTIES:
:CUSTOM_ID: tmp14
:END:
#+begin_src bash :tangle ~/.local/bin/tmp_14_days
if [ $1 == "mount" ]; then
if sshfs -o allow_other,default_permissions -p 5022 dehaeze@firewall.esrf.fr:/tmp_14_days/ ~/mnt/ESRF; then
dunstify --replace=58249 'ESRF TMP ' 'Successfully mounted'
else
dunstify --replace=58249 --urgency=critical 'ESRF TMP ' 'Error while mounted'
fi
elif [ $1 == "umount" ]; then
if umount /home/thomas/mnt/ESRF/; then
dunstify --replace=58249 'ESRF TMP ' 'Successfully unmounted'
else
dunstify --replace=58249 --urgency=critical 'ESRF TMP ' 'Error while unmounted'
fi
fi
#+end_src
* =nas= - Interact with the NAS
:PROPERTIES:
:CUSTOM_ID: nas
:END:
As an alternative, =sshfs= can be used:
#+begin_src bash :tangle no
sshfs -o allow_other,default_permissions nas:/Data ~/mnt/NAS
#+end_src
#+begin_src bash :tangle ~/.local/bin/nas
if [ $1 == "mount" ]; then
if sshfs -o allow_other,default_permissions homelab:/srv/storage/ ~/mnt/NAS; then
dunstify --replace=58249 'NAS ' 'Successfully mounted'
else
dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while mounted'
fi
elif [ $1 == "umount" ]; then
if umount ~/mnt/NAS/; then
dunstify --replace=58249 'NAS ' 'Successfully unmounted'
else
dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while unmounted'
fi
fi
#+end_src
* =torrent-add= - Download Torrent
:PROPERTIES:
:CUSTOM_ID: torrent-add
:END:
#+begin_src bash :tangle ~/.local/bin/torrent-add :noweb yes
transmission-remote <<get-password(passname="ip/homelab")>>:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \
dunstify 'Torrent' 'Successfully added' || \
dunstify 'Torrent' 'Error'
#+end_src
* =dl-add= - Direct Download with Aria2
:PROPERTIES:
:CUSTOM_ID: dl-add
:END:
#+begin_src bash :tangle ~/.local/bin/dl-add
aria2p --port 6800 --host http://dl.tdehaeze.xyz --secret $(pass dl.tdehaeze.xyz/tdehaeze | sed -n 1p) add $1
#+end_src
* =note-extract-fig= - Extract Figure from note file
:PROPERTIES:
:CUSTOM_ID: note-extract-fig
:END:
Script used to convert a figure drawn on my Boox note2 to a png file that can then be imported into a document.
#+begin_src bash :tangle ~/.local/bin/note-extract-fig
# First check that the first argument is a pdf file
if [[ -f $1 && $1 == *.pdf ]]; then
pngfile=$(echo $1 | cut -f 1 -d '.' | sed 's/$/.png/')
# Convert to png and crop png
pdf2png $1 && convert -trim "$pngfile" "$pngfile"
fi
#+end_src
* =screen-select= - Xrandr pre-defined scripts * =screen-select= - Xrandr pre-defined scripts
:PROPERTIES: :PROPERTIES:
@ -183,6 +102,63 @@ esac
exit 0 exit 0
#+end_src #+end_src
* =print-rnice= - Print on Rnice
:PROPERTIES:
:CUSTOM_ID: print-rnice
:END:
#+begin_src bash :tangle ~/.local/bin/print-rnice
nbpage=$(echo -e '1\n2\n4' | rofi -dmenu -no-custom -p 'Number of pages per sheet' -l 20);
sides=$(echo -e 'one-sided\ntwo-sided-long-edge\ntwo-sided-short-edge' | rofi -dmenu -no-custom -p 'Two Sided:' -l 20);
media=$(echo -e 'A4\nA3' | rofi -dmenu -no-custom -p 'Size:' -l 20);
# First copy the file to Rnice
if sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@rnice:/home/esrf/dehaeze/Downloads/; then
# Then print on Rnice
sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" ssh dehaeze@rnice "lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P ctb127c1w \"/home/esrf/dehaeze/Downloads/$1\"";
# Finally, delete the file
else
echo "Command Failed"
fi
#+end_src
* =torrent-add= - Download Torrent
:PROPERTIES:
:CUSTOM_ID: torrent-add
:END:
#+begin_src bash :tangle ~/.local/bin/torrent-add :noweb yes
transmission-remote <<get-password(passname="ip/homelab")>>:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \
dunstify 'Torrent' 'Successfully added' || \
dunstify 'Torrent' 'Error'
#+end_src
* =dl-add= - Direct Download with Aria2
:PROPERTIES:
:CUSTOM_ID: dl-add
:END:
#+begin_src bash :tangle ~/.local/bin/dl-add
aria2p --port 6800 --host http://dl.tdehaeze.xyz --secret $(pass dl.tdehaeze.xyz/tdehaeze | sed -n 1p) add $1
#+end_src
* =note-extract-fig= - Extract Figure from note file
:PROPERTIES:
:CUSTOM_ID: note-extract-fig
:END:
Script used to convert a figure drawn on my Boox note2 to a png file that can then be imported into a document.
#+begin_src bash :tangle ~/.local/bin/note-extract-fig
# First check that the first argument is a pdf file
if [[ -f $1 && $1 == *.pdf ]]; then
pngfile=$(echo $1 | cut -f 1 -d '.' | sed 's/$/.png/')
# Convert to png and crop png
pdf2png $1 && convert -trim "$pngfile" "$pngfile"
fi
#+end_src
* =color-picker= - Pick color and copy to clipboard * =color-picker= - Pick color and copy to clipboard
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: color-picker :CUSTOM_ID: color-picker