diff --git a/os_and_install/bash_aliases.universal b/os_and_install/bash_aliases.universal index c2fd2b5..4670679 100755 --- a/os_and_install/bash_aliases.universal +++ b/os_and_install/bash_aliases.universal @@ -1,143 +1,82 @@ HOST=$(hostname) LOCAL_SCRIPTS="/home/lucas/scripts" -alias please="sudo" -alias NC_scripts="cd ${NC_SCRIPTS}" -alias regex_rename="${LOCAL_SCRIPTS}/rename.sh" -alias profile="${LOCAL_SCRIPTS}/profile_motd.sh" -alias auto_update="${LOCAL_SCRIPTS}/utils/upgrade.sh" -alias aptgrep="apt list --installed | grep -i " -alias reboot="sudo /sbin/reboot" -alias shutdown="sudo /sbin/shutdown" -alias sound_up="pactl -- set-sink-volume 0 +10%" -alias TU_vpn="sudo openconnect --user e1629051@student.tuwien.ac.at vpn.tuwien.ac.at" -alias psgrep="ps -elf | grep -v grep | grep -i " -alias vpn="sudo ${LOCAL_SCRIPTS}/network/networksettings.sh" + +######################################################################## +## NETWORK Commands +####################################################################### alias pubip="wget -T 5 -qO- ifconfig.co" alias pubip_country="wget -T 5 -qO- ifconfig.co/country" alias ipinfo='${LOCAL_SCRIPTS}/ip_info.sh' -alias pygen="/home/lucas/scripts/.venv/bin/python3" -alias mv="mv -i" -alias cp_low="ionice -c3 cp" -# Wallpaper Changer -alias WC="bash /home/lucas/scripts/utils/WallpaperChanger.sh" +# Wake Host alias mediawake="bash ${LOCAL_SCRIPTS}/network/wol.sh mediahost -c" alias serverwake="bash ${LOCAL_SCRIPTS}/network/wol.sh serverhost -c" alias quietwake="bash ${LOCAL_SCRIPTS}/network/wol.sh quiethost" -if [[ "${HOST}" == "quiethost" ]] || [[ "${HOST}" == "serverhost" ]]; then - ### Veracrypt aliases - #Passwd Mount and Grep - alias passwd_mount="sudo veracrypt -t --mount --non-interactive --stdin $DOC_DIR/Dokumente/Zeug/passwd /media/veracrypt_passwd && clear" - alias passwd_dismount="sudo veracrypt --dismount $DOC_DIR/Dokumente/Zeug/passwd && touch $DOC_DIR/Dokumente/Zeug/passwd" - alias passwd_grep="grep -i -A1 /media/veracrypt_passwd/passwd.txt -e " - #System mounts - alias system_mount="sudo veracrypt -t --mount --non-interactive --stdin /data/SystemData/Sys64/System_Data /media/veracrypt_system && clear" - alias system_dismount="sudo veracrypt --dismount /data/SystemData/Sys64/System_Data" - #vera - alias vera_mount="sudo veracrypt -t --mount --non-interactive --stdin //media/veracrypt_system/System32/SystemData/IMG.file /media/veracrypt_vera && clear" - alias vera_dismount="sudo veracrypt --dismount /media/veracrypt_system/System32/SystemData/IMG.file" - #no intenet - alias no_inet="sudo -s -g no-internet" - alias recipeAI="~/.venv_general/bin/python3 ~/scripts/quiethost/generateNutritionInfowithGemini.py /data/Nextcloud/Documents/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas/" - alias ffmepeg_handling="~/.venv_general/bin/python3 ~/scripts/ffmpeg_handling.py" -fi -if [ "${HOST}" != "serverhost" ]; then - alias serverhost="ssh -X serverhost" - alias lstorr="ssh serverhost du -a -d1 -h /torrent/complete/ | sed 's/\/torrent\/complete\///'g | head -n -1" - alias delugecopy='bash ${LOCAL_SCRIPTS}/copy.sh -h deluge -f ' - alias servercopy='bash ${LOCAL_SCRIPTS}/copy.sh -h serverhost -f ' - alias scriptcopy="ssh serverhost bash /home/lucas/scripts/scriptcopy.sh" - #Dinfo - alias dinfo="ssh serverhost ${LOCAL_SCRIPTS}/deluge-client.sh" -elif [ "${HOST}" != "vivohost" ];then - # Copy Torrents - alias ytlistdownload="screen -S ytdown bash /home/lucas/scripts/youtube.sh -L" -copytorrents() { - screen -S cptorr bash -c "/home/lucas/scripts/serverhost/copytorrents.sh -l -y $@; read" -} - # Print - alias print="lpr -P hp-LaserJet-1300 " - alias scriptcopy='bash ${LOCAL_SCRIPTS}/scriptcopy.sh' - # Serverhost Network Commands - alias occ_scan="sudo bash ${LOCAL_SCRIPTS}/Nextcloud/nextcloud_scan.sh" - alias netstat="sudo bash ${LOCAL_SCRIPTS}/network/state.sh" - alias routing="sudo ${LOCAL_SCRIPTS}/network/rev_routing.sh" - alias IPtables-save="sudo sh -c 'iptables-save > /etc/network/iptables'" - # Serverhost Deluge Commands - alias rmTorr="bash ${LOCAL_SCRIPTS}/removeTorrents.sh" - alias dadd='duser deluge-console add' - alias deluge="duser deluged && sleep 0.2 && duser deluge-console" - alias deluge-console='duser deluge-console' - alias del='if [[ $(psgrep delug | wc -l) -eq 0 ]]; then vpn; fi; duser deluge-console' - alias deluged="duser deluged" - alias duser="sudo ${LOCAL_SCRIPTS}/serverhost/deluge_user_cmd.sh" - alias dpubip="duser wget -T 5 -qO- ifconfig.co" - alias dpubip_country="duser wget -T 5 -qO- ifconfig.co/country" - alias lstorr="du -a -d1 -h /torrent/complete/ | sed 's/\/torrent\/complete\///'g | head -n -1" - # Serverhost NCSync - alias occ="sudo -u www-data php /nextcloud/nextcloud/occ" - #Dinfo - alias dinfo="${LOCAL_SCRIPTS}/serverhost/deluge-client.sh" - # Auto shutdown - alias autoshutdown_enable="echo "yes" > /home/lucas/.auto_shutdown" - alias autoshutdown_disable="echo "no" > /home/lucas/.auto_shutdown" -fi -if [ "${HOST}" != "quiethost" ]; then - alias quiethost="ssh -X quiethost" - alias quietcopy='bash ${LOCAL_SCRIPTS}/copy.sh -h quiethost -f ' -elif [ "${HOST}" != "vivohost" ];then - # XRDP duser@serverhost - alias serverxrdp="xfreerdp /bpp:32 /kbd:german /u:deluge-user /v:10.0.0.2 /port:3389 /cert-ignore /size:1920x950 /relax-order-checks +glyph-cache" - # Iptables - alias firewall="sudo /home/lucas/Documents/Dokumente/Projekte/Server/scripts/iptables_basic.sh" - # Torrents - alias torrentcopy="bash /home/lucas/scripts/quiethost/torrentcopy.sh" - # Screenshot - alias scrsht="bash /home/lucas/scripts/screenschot_grab.sh" - # Boot to Windows - alias winboot="sudo efibootmgr --bootnext 0000 && reboot" - # Boot to Windows - alias winhiber="sudo /home/lucas/scripts/enable-hibernate-reboot && sudo efibootmgr --bootnext 0003 && sudo systemctl hibernate" - # 3DVS mount - alias 3dvs_mount="sudo veracrypt -t --mount --non-interactive --stdin /data/SystemData/SystemGame3DSV2_10 /media/veracrypt_3DSV && clear" - alias 3dvs_dismount="sudo veracrypt --dismount /data/SystemData/SystemGame3DSV2_10" - # FFMPEG - # jpg2png - alias imconv="bash ${LOCAL_SCRIPTS}/img_type.sh" - alias FFmpeg="bash /home/lucas/scripts/ffmpeg_handling.sh" - # Wallpaper Changer - alias WC="bash /data/Nextcloud/Documents/Dokumente/Projekte/Server/scripts/serverhost/WallpaperChangerServer.sh" - # Display Modes - alias mode_work="xrandr --output HDMI-1-1 --off && bash /home/lucas/scripts/wallpaperChanger.sh" - alias mode_norm="xrandr --output eDP-1-1 --output HDMI-1-1 --auto --primary --left-of eDP-1-1 && bash /home/lucas/scripts/wallpaperChanger.sh" - # Repair Mouse - alias mouse_repair="sudo /home/lucas/scripts/repair_mouse.sh" - alias sd_rm="rm -dr /home/lucas/stable-diffusion-webui/outputs/* /home/lucas/stable-diffusion-webui/log/images/*" - alias stable="cd /stable/stable-diffusion-webui/ && ./webui.sh" - alias comfiUI="cd /stable/ComfyUI/ && HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 main.py" -fi +#no intenet +alias no_inet="sudo -s -g no-internet" -if [ "${HOST}" != "mediahost" ]; then - alias mediahost="ssh mediahost" -fi -if [ "${HOST}" == "vivohost" ]; then - alias labwake="sudo etherwake B4:2E:99:F1:82:3B -i wlo1" - #alias labhost="ssh ubuntu@LabNotebookUbuntu" - alias labhost="ssh labhost" +####################################################################### +## SSH Commands +####################################################################### +alias serverhost="ssh -Y serverhost" +alias quiethost="ssh -Y quiethost" +alias mediahost="ssh -Y mediahost" +alias labhost="ssh -Y labhost" - alias serverhost="ssh serverhost" - alias winboot="sudo efibootmgr --bootnext 0001 && sudo /usr/sbin/reboot" -fi +####################################################################### +## PYTHON Commands +####################################################################### +alias py_scripts="/home/lucas/scripts/.venv/bin/python3" -if [[ "${HOST}" == "quiethost" ]] || [[ "${HOST}" == "vivohost" ]]; then - DEFAULT_SUBNET=11 - if [ "${HOST}" == "quiethost" ]; then - DEFAULT_SUBNET=0 - fi - alias tcmcli="/usr/bin/python3 ~/git/calibration_gui/supportScripts/send_cli_command_lucas.py" - raspi() { x=$(echo $1 | grep -o '\.' | wc -l) ; if [[ $x -le 0 ]]; then ssh -X raspi@192.168.$DEFAULT_SUBNET.$1; elif [[ $x -eq 1 ]]; then ssh raspi@192.168.$1; elif [[ $x -eq 2 ]] ; then ssh raspi@192.$1; elif [[ $x -eq 3 ]]; then ssh raspi@$1; fi } +####################################################################### +## UTILS Commands +####################################################################### +alias please="sudo" +alias mv="mv -i" +alias cp_low="ionice -c3 cp" +alias rm='trash-put' +alias psgrep="ps -elf | grep -v grep | grep -i " +alias aptgrep="apt list --installed | grep -i " +alias reboot="sudo /sbin/reboot" +alias shutdown="sudo /sbin/shutdown" +alias auto_update="${LOCAL_SCRIPTS}/utils/upgrade.sh" +alias scrsht="bash /home/lucas/scripts/screenschot_grab.sh" +alias mouse_repair="sudo /home/lucas/scripts/repair_mouse.sh" +alias profile="${LOCAL_SCRIPTS}/profile_motd.sh" + +####################################################################### +## WALLPAPERCHANGER Commands +####################################################################### +alias WC="bash /home/lucas/scripts/utils/WallpaperChanger.sh" + +####################################################################### +## VERA Commands +####################################################################### +# Passwd Mount and Grep +alias passwd_mount="sudo veracrypt -t --mount --non-interactive --stdin $DOC_DIR/Dokumente/Zeug/passwd /media/veracrypt_passwd && clear" +alias passwd_dismount="sudo veracrypt --dismount $DOC_DIR/Dokumente/Zeug/passwd && touch $DOC_DIR/Dokumente/Zeug/passwd" +alias passwd_grep="grep -i -A1 /media/veracrypt_passwd/passwd.txt -e " +# System mounts +alias system_mount="sudo veracrypt -t --mount --non-interactive --stdin /data/SystemData/Sys64/System_Data /media/veracrypt_system && clear" +alias system_dismount="sudo veracrypt --dismount /data/SystemData/Sys64/System_Data" +# Vera Mounts +alias vera_mount="sudo veracrypt -t --mount --non-interactive --stdin //media/veracrypt_system/System32/SystemData/IMG.file /media/veracrypt_vera && clear" +alias vera_dismount="sudo veracrypt --dismount /media/veracrypt_system/System32/SystemData/IMG.file" + +####################################################################### +## FUNCTIONS +####################################################################### + +DEFAULT_SUBNET=11 +if [ "${HOST}" == "quiethost" ]; then + DEFAULT_SUBNET=0 fi +alias tcmcli="/usr/bin/python3 ~/git/calibration_gui/supportScripts/send_cli_command_lucas.py" + +raspi() { x=$(echo $1 | grep -o '\.' | wc -l) ; if [[ $x -le 0 ]]; then ssh -X raspi@192.168.$DEFAULT_SUBNET.$1; elif [[ $x -eq 1 ]]; then ssh raspi@192.168.$1; elif [[ $x -eq 2 ]] ; then ssh raspi@192.$1; elif [[ $x -eq 3 ]]; then ssh raspi@$1; fi } + dircreate() { + # Create a directory for every file stem in the current directory for file in *; do [ -f "$file" ] || continue @@ -152,6 +91,7 @@ dircreate() { } find_multi_video_dirs() { + # Find Dirctory with more than one Video file local exts='mkv|mp4|avi|mov|m4v|wmv|flv|webm|ts' find . -type d -print0 | @@ -167,27 +107,27 @@ find_multi_video_dirs() { } rename_dots() { - -find . -depth | while IFS= read -r path; do - [[ "$path" == "." ]] && continue - base=$(basename "$path") - dir=$(dirname "$path") - - if [[ -f "$path" && "$base" == *.tar.gz ]]; then - name="${base%.tar.gz}" - newbase="${name//./ }.tar.gz" - elif [[ -f "$path" && "$base" == *.* ]]; then - name="${base%.*}" - ext="${base##*.}" - newbase="${name//./ }.${ext}" - else - newbase="${base//./ }" - fi - - if [[ "$base" != "$newbase" ]]; then - newpath="$dir/$newbase" - echo "Moving: '$path' -> '$newpath'" - mv -n -- "$path" "$newpath" - fi -done + #remove dots from filenames: Dexter.1080p.mkv -> Dexter 1080p.mkv + find . -depth | while IFS= read -r path; do + [[ "$path" == "." ]] && continue + base=$(basename "$path") + dir=$(dirname "$path") + + if [[ -f "$path" && "$base" == *.tar.gz ]]; then + name="${base%.tar.gz}" + newbase="${name//./ }.tar.gz" + elif [[ -f "$path" && "$base" == *.* ]]; then + name="${base%.*}" + ext="${base##*.}" + newbase="${name//./ }.${ext}" + else + newbase="${base//./ }" + fi + + if [[ "$base" != "$newbase" ]]; then + newpath="$dir/$newbase" + echo "Moving: '$path' -> '$newpath'" + mv -n -- "$path" "$newpath" + fi + done }