From fc036396a0a23c81cc4158e967007a3d9d9e7250 Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Sun, 25 Sep 2022 03:47:51 +0530 Subject: [PATCH] changes made: - converted all tabs (that I could find) to spaces - move shell _then_ and _do_ keywords on same line as _if_ and _loops_ - re-organize .scripts/ dir (add sentinel and bluefeds scripts too) --- .bashrc | 4 +- .config/bspwm/bspwmrc | 42 ++++---- .config/polybar/mods/module_mpv.sh | 15 ++- .config/rofi/config.rasi | 16 +-- .config/sxhkd/mods/module_alsa.sh | 98 +++++++++---------- .config/sxhkd/sxhkdrc | 30 +++--- .../_bluefeds/cron/pratham/maintenance.sh | 57 +++++++++++ .scripts/_bluefeds/cron/root/zfs-bak.sh | 5 + ...ner-caddy-vishwambhar.service.mailcontents | 3 + ...ner-gitea-chitragupta.service.mailcontents | 3 + ...ntainer-gitea-govinda.service.mailcontents | 3 + ...ntainer-hugo-mahayogi.service.mailcontents | 3 + ...r-hugo-vaikunthnatham.service.mailcontents | 3 + ...nextcloud-chitragupta.service.mailcontents | 3 + ...ner-nextcloud-govinda.service.mailcontents | 3 + ...ainer-nextcloud-karma.service.mailcontents | 3 + ...r-transmission-raadhe.service.mailcontents | 3 + .scripts/_bluefeds/motd/show_logs.sh | 10 ++ .../hdd/notify_user.sh | 0 .../{flameboi => _flameboi}/hdd/on_boot.sh | 3 +- .scripts/_flameboi/hdd/on_resume.sh | 7 ++ .../{ => _flameboi}/xorg/root/restart_x.sh | 0 .scripts/_sentinel/cron/root/midnight.sh | 18 ++++ .../cron/root/unkill-transmission.sh | 23 +++++ .scripts/_sentinel/cron/root/zfs-bak.sh | 4 + .scripts/_sentinel/cron/ubuntu/dns-test.sh | 8 ++ .scripts/{other => common-scripts}/sort.py | 0 .scripts/flameboi/hdd/on_resume.sh | 6 -- .zsh_aliases | 9 +- .zshrc | 6 +- 30 files changed, 263 insertions(+), 125 deletions(-) create mode 100755 .scripts/_bluefeds/cron/pratham/maintenance.sh create mode 100644 .scripts/_bluefeds/cron/root/zfs-bak.sh create mode 100644 .scripts/_bluefeds/mail/containers/container-caddy-vishwambhar.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-gitea-chitragupta.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-gitea-govinda.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-hugo-mahayogi.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-hugo-vaikunthnatham.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-nextcloud-chitragupta.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-nextcloud-govinda.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-nextcloud-karma.service.mailcontents create mode 100644 .scripts/_bluefeds/mail/containers/container-transmission-raadhe.service.mailcontents create mode 100755 .scripts/_bluefeds/motd/show_logs.sh rename .scripts/{flameboi => _flameboi}/hdd/notify_user.sh (100%) rename .scripts/{flameboi => _flameboi}/hdd/on_boot.sh (57%) create mode 100644 .scripts/_flameboi/hdd/on_resume.sh rename .scripts/{ => _flameboi}/xorg/root/restart_x.sh (100%) create mode 100644 .scripts/_sentinel/cron/root/midnight.sh create mode 100644 .scripts/_sentinel/cron/root/unkill-transmission.sh create mode 100644 .scripts/_sentinel/cron/root/zfs-bak.sh create mode 100644 .scripts/_sentinel/cron/ubuntu/dns-test.sh rename .scripts/{other => common-scripts}/sort.py (100%) delete mode 100644 .scripts/flameboi/hdd/on_resume.sh diff --git a/.bashrc b/.bashrc index 15c94d9..c08d7cc 100644 --- a/.bashrc +++ b/.bashrc @@ -1,5 +1,5 @@ if [[ "$OSTYPE" == "freebsd"* ]]; then - echo "FreeBSD" + echo "WIP: FreeBSD" elif [[ "$OSTYPE" == "openbsd"* ]]; then - echo "OpenBSD" + echo "WIP: OpenBSD" fi diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc index c057506..8cb0337 100644 --- a/.config/bspwm/bspwmrc +++ b/.config/bspwm/bspwmrc @@ -7,34 +7,34 @@ pgrep -x sxhkd > /dev/null || sxhkd & bspc monitor -d work virtualization music other extra extraa -bspc config border_width 6 -bspc config window_gap 12 +bspc config border_width 6 +bspc config window_gap 12 -bspc config focused_border_color \#FF0000 -bspc config active_border_color \#FFFFFF -bspc config normal_border_color \#FFFFFF #08C96B -bspc config presel_border_color \#A57FE8 +bspc config focused_border_color \#FF0000 +bspc config active_border_color \#FFFFFF +bspc config normal_border_color \#FFFFFF #08C96B +bspc config presel_border_color \#A57FE8 -bspc config split_ratio 0.5 +bspc config split_ratio 0.5 -bspc config borderless_monocle false -bspc config gapless_monocle true +bspc config borderless_monocle false +bspc config gapless_monocle true -bspc config left_padding 8 -bspc config bottom_padding 8 -bspc config top_padding 8 -bspc config right_padding 8 +bspc config left_padding 8 +bspc config bottom_padding 8 +bspc config top_padding 8 +bspc config right_padding 8 -bspc config left_monocle_padding 6 -bspc config bottom_monocle_padding 6 -bspc config top_monocle_padding 6 -bspc config right_monocle_padding 6 +bspc config left_monocle_padding 6 +bspc config bottom_monocle_padding 6 +bspc config top_monocle_padding 6 +bspc config right_monocle_padding 6 -bspc config focus_follows_pointer false -bspc config pointer_follows_focus false -bspc config pointer_follows_monitor false +bspc config focus_follows_pointer false +bspc config pointer_follows_focus false +bspc config pointer_follows_monitor false -bspc config center_pseudo_tiled false +bspc config center_pseudo_tiled false bspc rule -a mpv state=floating bspc rule -a "Nvidia-settings" state=floating diff --git a/.config/polybar/mods/module_mpv.sh b/.config/polybar/mods/module_mpv.sh index f75138c..3089d30 100755 --- a/.config/polybar/mods/module_mpv.sh +++ b/.config/polybar/mods/module_mpv.sh @@ -1,14 +1,13 @@ #!/usr/bin/env bash if [[ $(pidof mpv) ]]; then - POS=$(echo '{ "command": ["get_property_string", "time-pos"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1) - DUR=$(echo '{ "command": ["get_property_string", "duration"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1) - METADATA=$(echo '{ "command": ["get_property", "media-title"] }' | socat - /tmp/mpvsocket | awk -F "\"*,\"*" '{print $1}' | awk -F "\"*:\"*" '{print $2}' ) - - printf "$METADATA" - printf ' (%d:%02d:%02d' $(($POS/3600)) $(($POS%3600/60)) $(($POS%60)) - printf ' / %d:%02d:%02d)\n' $(($DUR/3600)) $(($DUR%3600/60)) $(($DUR%60)) + POS=$(echo '{ "command": ["get_property_string", "time-pos"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1) + DUR=$(echo '{ "command": ["get_property_string", "duration"] }' | socat - /tmp/mpvsocket | jq .data | tr '"' ' ' | cut -d'.' -f 1) + METADATA=$(echo '{ "command": ["get_property", "media-title"] }' | socat - /tmp/mpvsocket | awk -F "\"*,\"*" '{print $1}' | awk -F "\"*:\"*" '{print $2}' ) + printf "$METADATA" + printf ' (%d:%02d:%02d' $(($POS/3600)) $(($POS%3600/60)) $(($POS%60)) + printf ' / %d:%02d:%02d)\n' $(($DUR/3600)) $(($DUR%3600/60)) $(($DUR%60)) else - exit + exit fi diff --git a/.config/rofi/config.rasi b/.config/rofi/config.rasi index 5058592..3b9fe95 100644 --- a/.config/rofi/config.rasi +++ b/.config/rofi/config.rasi @@ -1,10 +1,10 @@ configuration { - font: "Fira Code 14"; - show-icons: true; - terminal: "alacritty"; - /*icon-theme: ;*/ - sidebar-mode: false; - click-to-exit: true; - show-match: true; - theme: "gruvbox-dark-hard"; + font: "Fira Code 14"; + show-icons: true; + terminal: "alacritty"; + /*icon-theme: ;*/ + sidebar-mode: false; + click-to-exit: true; + show-match: true; + theme: "gruvbox-dark-hard"; } diff --git a/.config/sxhkd/mods/module_alsa.sh b/.config/sxhkd/mods/module_alsa.sh index 30ca692..3c76175 100755 --- a/.config/sxhkd/mods/module_alsa.sh +++ b/.config/sxhkd/mods/module_alsa.sh @@ -6,73 +6,63 @@ STAT1="$(amixer -D pulse sget Master | tail -n 1 | cut -c 35)" STAT2="$(amixer -D pulse sget Master | tail -n 1 | cut -c 40)" UPORDOWN="$1" -if [ "$UPORDOWN" = "up" ] -then - if [ "$STAT0" = "f" ] || [ "$STAT1" = "f" ] || [ "$STAT2" = "f" ] - then - notify-send -u critical "Volume Manager" "Unmuted\!" - pactl set-sink-mute 1 0 - fi - amixer -D pulse sset Master 10%+ +if [[ "$UPORDOWN" == "up" ]]; then + if [[ "$STAT0" == "f" ]] || [[ "$STAT1" == "f" ]] || [[ "$STAT2" == "f" ]]; then + notify-send -u critical "Volume Manager" "Unmuted\!" + pactl set-sink-mute 1 0 + fi + amixer -D pulse sset Master 10%+ fi -if [ "$UPORDOWN" = "down" ] -then +if [[ "$UPORDOWN" == "down" ]]; then - # the commented out part below should work - # but for some reason - # decreasing 10% volume shows 9% volume decrease in polybar widget - # but it is actually 10% volume decrease when checking with amixer - # so less efficient code; for the OCD; - #if [ "$VOL" = "100%" ] - #then - # amixer -D pulse sset Master 90% - #else - # amixer -D pulse sset Master 10%- - #fi + # the commented out part below should work + # but for some reason + # decreasing 10% volume shows 9% volume decrease in polybar widget + # but it is actually 10% volume decrease when checking with amixer + # so less efficient code; for the OCD; - case "$VOL" in + case "$VOL" in - "100%") - amixer -D pulse sset Master 90% - ;; + "100%") + amixer -D pulse sset Master 90% + ;; - "90%]") - amixer -D pulse sset Master 80% - ;; + "90%]") + amixer -D pulse sset Master 80% + ;; - "80%]") - amixer -D pulse sset Master 70% - ;; + "80%]") + amixer -D pulse sset Master 70% + ;; - "70%]") - amixer -D pulse sset Master 60% - ;; + "70%]") + amixer -D pulse sset Master 60% + ;; - "60%]") - amixer -D pulse sset Master 50% - ;; + "60%]") + amixer -D pulse sset Master 50% + ;; - "50%]") - amixer -D pulse sset Master 40% - ;; + "50%]") + amixer -D pulse sset Master 40% + ;; - "40%]") - amixer -D pulse sset Master 30% - ;; + "40%]") + amixer -D pulse sset Master 30% + ;; - "30%]") - amixer -D pulse sset Master 20% - ;; + "30%]") + amixer -D pulse sset Master 20% + ;; - "20%]") - amixer -D pulse sset Master 10% - ;; + "20%]") + amixer -D pulse sset Master 10% + ;; - "0%] ") - amixer -D pulse sset Master 10%- - ;; - - esac + "0%] ") + amixer -D pulse sset Master 10%- + ;; + esac fi diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index aa6975e..45a8390 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -1,66 +1,66 @@ # launch rofi super + space - rofi -modi drun,run -show drun + rofi -modi drun,run -show drun # Return to launch terminal emulator # b to launch browser super + {Return,b} - {alacritty,firefox} + {alacritty,firefox} # w to reload/relaunch feh/change bg # p to reload/relaunch polybar # Escape to turn screen off and lock the computer super + shift + {w,p,Escape} - {bash $HOME/.config/feh/fehbg &,bash $HOME/.config/polybar/launch.sh &,bash $HOME/.config/sxhkd/mods/module_lock_script.sh} + {bash $HOME/.config/feh/fehbg &,bash $HOME/.config/polybar/launch.sh &,bash $HOME/.config/sxhkd/mods/module_lock_script.sh} # c to reload config # q to quit selected window super + shift + {c,q} - {pkill -USR1 -x sxhkd && bspc wm -r,bspc node -c} + {pkill -USR1 -x sxhkd && bspc wm -r,bspc node -c} # t to enable tiled mode for current window # shift + t to enable floating mode for current window # f to enable fullscreen mode for current window super + {t,shift + t,f} - bspc node -t {tiled,floating,fullscreen} + bspc node -t {tiled,floating,fullscreen} # super h,j,k,l to move between windows # add shift to swap the window to left right etc super + {_,shift +, ctrl +}{h,j,k,l} - bspc node -{f,s,n} {west,south,north,east} + bspc node -{f,s,n} {west,south,north,east} # expand a window by moving one of its side outward super + alt + shift {h,j,k,l} - bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} + bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} #contract a window by moving one of its side inward super + ctrl + shift + {h,j,k,l} - bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} + bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} # focus the next/previous desktop in the current monitor super + bracket{left,right} - bspc desktop -f {prev,next}.local + bspc desktop -f {prev,next}.local # [ to decrease volume by 10% # ] to increase volume by 10% super + shift + bracket{left,right} - {bash $HOME/.config/sxhkd/mods/module_alsa.sh down,bash $HOME/.config/sxhkd/mods/module_alsa.sh up} + {bash $HOME/.config/sxhkd/mods/module_alsa.sh down,bash $HOME/.config/sxhkd/mods/module_alsa.sh up} # switch between nodes (locally) alt + {_,shift} + Tab - bspc node -f {next,prev}.local.!hidden.window + bspc node -f {next,prev}.local.!hidden.window # focus or send to the given desktop super + {_,shift + }{1-9,0} - bspc {desktop -f,node -d} '^{1-9,10}' + bspc {desktop -f,node -d} '^{1-9,10}' # move a floating window super + {Left,Down,Up,Right} - bspc node -v {-20 0,0 20,0 -20,20 0} + bspc node -v {-20 0,0 20,0 -20,20 0} # bspwm rotate: split horizontally/vertically super + shift + {v,s} - bspc node @parent -R {90,90} + bspc node @parent -R {90,90} # exit bspwn (return to console) super + shift + ctrl + alt + 0 - bspc quit + bspc quit diff --git a/.scripts/_bluefeds/cron/pratham/maintenance.sh b/.scripts/_bluefeds/cron/pratham/maintenance.sh new file mode 100755 index 0000000..ba2dc47 --- /dev/null +++ b/.scripts/_bluefeds/cron/pratham/maintenance.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# systemd services for each of my podman container +CONTAINER_SERVICES=( + "container-gitea-chitragupta.service" \ + "container-gitea-govinda.service" \ + "container-hugo-mahayogi.service" \ + "container-hugo-vaikunthnatham.service" \ + "container-nextcloud-chitragupta.service" \ + "container-nextcloud-govinda.service" \ + "container-transmission-raadhe.service" \ + "container-caddy-vishwambhar.service" \ +) + +# calculate uptime in MINUTES +SECONDS_SINCE=$(date --date "$(uptime -s)" +%s) +SECONDS_NOW=$(date +%s) +SECONDS_DIFF=$((SECONDS_NOW - SECONDS_SINCE)) +UPTIME_MINUTES=$((SECONDS_DIFF / 60)) +UPTIME_CMP=20 + +# Nextcloud takes time to start +# So don't immediately restart services (and send e-mail) +# until the uptime is greater than 20 minutes +if [[ "$UPTIME_MINUTES" -gt "$UPTIME_CMP" ]]; then + + # loop through all services in $CONTAINER_SERVICES + for INDV_SERVICE in ${CONTAINER_SERVICES[@]}; do + + CHECK_ENABLEMENT=$(systemctl --user is-enabled "$INDV_SERVICE") + + # check if a service is enabled + # don't restart services that I manually disabled + if [[ "$CHECK_ENABLEMENT" == "enabled" ]]; then + + # check if a service is active or not + CONTAINER_STAT=1 + systemctl --user is-active --quiet service "$INDV_SERVICE" && CONTAINER_STAT=0 + + # if container is not running + # start it + if [[ $CONTAINER_STAT -eq 1 ]]; then + + # pretty date format + CURR_DATE=$(date +'(UTC%:::z) %Y/%m/%d %H:%M:%S') + # what should be in the e-mail _IF_ the service is restarted? + MAILCONTENT=$HOME/.scripts/_bluefeds/mail/containers/"$INDV_SERVICE".mailcontents + + # restart $INDV_SERVICE _AND_ container-caddy-vishwambhar.service + systemctl --user start "$INDV_SERVICE" && systemctl --user restart container-caddy-vishwambhar.service && echo "$CURR_DATE: \"$INDV_SERVICE\"" >> $HOME/.log/cron/pratham/log + + # send e-mail about the service that was restarted + /usr/sbin/ssmtp thefirst1322@gmail.com < $MAILCONTENT + fi + fi + done +fi diff --git a/.scripts/_bluefeds/cron/root/zfs-bak.sh b/.scripts/_bluefeds/cron/root/zfs-bak.sh new file mode 100644 index 0000000..c347205 --- /dev/null +++ b/.scripts/_bluefeds/cron/root/zfs-bak.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +DATE=$(date +"%Y_%m_%d__%H_%M_%S"); + +/usr/sbin/zfs snapshot trayimurti/containers/volumes/nextcloud@$DATE diff --git a/.scripts/_bluefeds/mail/containers/container-caddy-vishwambhar.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-caddy-vishwambhar.service.mailcontents new file mode 100644 index 0000000..7c58d63 --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-caddy-vishwambhar.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'caddy-vishwambhar' diff --git a/.scripts/_bluefeds/mail/containers/container-gitea-chitragupta.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-gitea-chitragupta.service.mailcontents new file mode 100644 index 0000000..f4069cf --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-gitea-chitragupta.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'gitea-chitragupta' diff --git a/.scripts/_bluefeds/mail/containers/container-gitea-govinda.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-gitea-govinda.service.mailcontents new file mode 100644 index 0000000..463a99a --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-gitea-govinda.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'gitea-govinda' diff --git a/.scripts/_bluefeds/mail/containers/container-hugo-mahayogi.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-hugo-mahayogi.service.mailcontents new file mode 100644 index 0000000..421c14c --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-hugo-mahayogi.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'hugo-mahayogi' diff --git a/.scripts/_bluefeds/mail/containers/container-hugo-vaikunthnatham.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-hugo-vaikunthnatham.service.mailcontents new file mode 100644 index 0000000..14bb993 --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-hugo-vaikunthnatham.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'hugo-vaikunthnatham' diff --git a/.scripts/_bluefeds/mail/containers/container-nextcloud-chitragupta.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-nextcloud-chitragupta.service.mailcontents new file mode 100644 index 0000000..f0f4dd6 --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-nextcloud-chitragupta.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'nextcloud-chitragupta' diff --git a/.scripts/_bluefeds/mail/containers/container-nextcloud-govinda.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-nextcloud-govinda.service.mailcontents new file mode 100644 index 0000000..11f7e59 --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-nextcloud-govinda.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'nextcloud-govinda' diff --git a/.scripts/_bluefeds/mail/containers/container-nextcloud-karma.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-nextcloud-karma.service.mailcontents new file mode 100644 index 0000000..db44fe0 --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-nextcloud-karma.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'nextcloud-karma' diff --git a/.scripts/_bluefeds/mail/containers/container-transmission-raadhe.service.mailcontents b/.scripts/_bluefeds/mail/containers/container-transmission-raadhe.service.mailcontents new file mode 100644 index 0000000..9193426 --- /dev/null +++ b/.scripts/_bluefeds/mail/containers/container-transmission-raadhe.service.mailcontents @@ -0,0 +1,3 @@ +To: thefirst1322@gmail.com +From: DOWNTIME ALERT (bluefeds) +Subject: Restarted 'transmission-raadhe' diff --git a/.scripts/_bluefeds/motd/show_logs.sh b/.scripts/_bluefeds/motd/show_logs.sh new file mode 100755 index 0000000..12c9e69 --- /dev/null +++ b/.scripts/_bluefeds/motd/show_logs.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +CHK_DATE=$(date +'%Y/%m/%d') +LOG_FILE=$HOME/.log/cron/pratham/log + +if [[ -f "$LOG_FILE" ]]; then + echo "-----------" + cat "$LOG_FILE" | grep "${CHK_DATE}" | grep --color=auto -E "container.*service" + echo "-----------" +fi diff --git a/.scripts/flameboi/hdd/notify_user.sh b/.scripts/_flameboi/hdd/notify_user.sh similarity index 100% rename from .scripts/flameboi/hdd/notify_user.sh rename to .scripts/_flameboi/hdd/notify_user.sh diff --git a/.scripts/flameboi/hdd/on_boot.sh b/.scripts/_flameboi/hdd/on_boot.sh similarity index 57% rename from .scripts/flameboi/hdd/on_boot.sh rename to .scripts/_flameboi/hdd/on_boot.sh index 77eeeef..fa6bded 100644 --- a/.scripts/flameboi/hdd/on_boot.sh +++ b/.scripts/_flameboi/hdd/on_boot.sh @@ -9,4 +9,5 @@ /usr/bin/updatedb & sleep 600s -/home/pratham/.scripts/flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby ([re]boot-ed)" && exit 0 +# don't use $HOME, root is running this +/home/pratham/.scripts/_flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby ([re]boot-ed)" && exit 0 diff --git a/.scripts/_flameboi/hdd/on_resume.sh b/.scripts/_flameboi/hdd/on_resume.sh new file mode 100644 index 0000000..5943a98 --- /dev/null +++ b/.scripts/_flameboi/hdd/on_resume.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +/usr/bin/updatedb & +sleep 600s + +# don't use $HOME, root is running this +/home/pratham/.scripts/_flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby (resumed from suspend)" && exit 0 diff --git a/.scripts/xorg/root/restart_x.sh b/.scripts/_flameboi/xorg/root/restart_x.sh similarity index 100% rename from .scripts/xorg/root/restart_x.sh rename to .scripts/_flameboi/xorg/root/restart_x.sh diff --git a/.scripts/_sentinel/cron/root/midnight.sh b/.scripts/_sentinel/cron/root/midnight.sh new file mode 100644 index 0000000..0e780d9 --- /dev/null +++ b/.scripts/_sentinel/cron/root/midnight.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +ORIGDIR="/var/lib/transmission-daemon/.config/transmission-daemon/torrents" +CONFDIR="/libertine/config_dir" +TORRDIR="/libertine/torrents" + +rsync --size-only $ORIGDIR/*.* $CONFDIR/ +chmod 664 $CONFDIR/*.* +chown ubuntu:ubuntu -v $CONFDIR/*.* +sleep 5 + +chmod 775 -R $TORRDIR +chown ubuntu:debian-transmission -R $TORRDIR +find $TORRDIR -type f -exec chmod 664 {} \; +find $TORRDIR -type f -name "*.DS_Store" -exec rm {} \; +sleep 5 + +updatedb diff --git a/.scripts/_sentinel/cron/root/unkill-transmission.sh b/.scripts/_sentinel/cron/root/unkill-transmission.sh new file mode 100644 index 0000000..e72742b --- /dev/null +++ b/.scripts/_sentinel/cron/root/unkill-transmission.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +transmission-daemon.service +CHECK_ENABLEMENT=$(systemctl --user is-enabled transmission-daemon.service) + +# check if a service is enabled +# don't restart services that I manually disabled +if [[ "$CHECK_ENABLEMENT" == "enabled" ]]; then + + # check if a service is active or not + CONTAINER_STAT=1 + systemctl --user is-active --quiet service transmission-daemon.service && CONTAINER_STAT=0 + + # if container is not running + # start it + if [[ $CONTAINER_STAT -eq 1 ]]; then + + systemctl --user start transmission-daemon.service + + fi +else + exit 1 +fi diff --git a/.scripts/_sentinel/cron/root/zfs-bak.sh b/.scripts/_sentinel/cron/root/zfs-bak.sh new file mode 100644 index 0000000..d3a4260 --- /dev/null +++ b/.scripts/_sentinel/cron/root/zfs-bak.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +DATE=$(date +"%Y_%m_%d__%H_%M_%S"); +/usr/sbin/zfs snapshot libertine/container-vols/test@$DATE diff --git a/.scripts/_sentinel/cron/ubuntu/dns-test.sh b/.scripts/_sentinel/cron/ubuntu/dns-test.sh new file mode 100644 index 0000000..69028d7 --- /dev/null +++ b/.scripts/_sentinel/cron/ubuntu/dns-test.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +MY_IP_ADDR=$(hostname -I | awk '{print $1}') +dig +time=2 +tries=1 +noall example.com @${MY_IP_ADDR} + +if [[ $? -ne 0 ]]; then + /usr/local/bin/pihole restartdns +fi diff --git a/.scripts/other/sort.py b/.scripts/common-scripts/sort.py similarity index 100% rename from .scripts/other/sort.py rename to .scripts/common-scripts/sort.py diff --git a/.scripts/flameboi/hdd/on_resume.sh b/.scripts/flameboi/hdd/on_resume.sh deleted file mode 100644 index ecae04f..0000000 --- a/.scripts/flameboi/hdd/on_resume.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -/usr/bin/updatedb & -sleep 600s - -/home/pratham/.scripts/flameboi/hdd/notify_user.sh "critical" "Check HDDs" "Check if the HDDs are in standby (resumed from suspend)" && exit 0 diff --git a/.zsh_aliases b/.zsh_aliases index 54b5675..607db12 100644 --- a/.zsh_aliases +++ b/.zsh_aliases @@ -107,21 +107,18 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then alias gnomecc="XDG_CURRENT_DESKTOP=GNOME gnome-control-center" - if command -v flatpak > /dev/null - then + if command -v flatpak > /dev/null; then # Get a list of flatpak applications in the reverse domain name format readarray -t ids < <(flatpak list --app --columns=application) - for id in "${ids[@]}" - do + for id in "${ids[@]}"; do # Take everything past the last dot (the name) name="${id##*.}" # Make it lowercase to approximate binary name binary="${name,,}" # If there is not already a command at that name - if ! command -v "${binary}" > /dev/null - then + if ! command -v "${binary}" > /dev/null; then # Create an alias that runs the flatpak alias "$binary=flatpak run \"$id\"" fi diff --git a/.zshrc b/.zshrc index 456968b..3a5016d 100644 --- a/.zshrc +++ b/.zshrc @@ -53,8 +53,7 @@ PROMPT=$'\n%F{11}─┬─[%f %F{5}%y %f%F{white}%? %D %*%f %F{11}]%f # common stuff for Linux -if [[ "$OSTYPE" == "linux-gnu"* ]] -then +if [[ "$OSTYPE" == "linux-gnu"* ]]; then # syntax highlighting ZSH_SYNTAX_HIGH="/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" @@ -99,8 +98,7 @@ then fi # stuff for macOS -elif [[ "$OSTYPE" == "darwin"* ]] -then +elif [[ "$OSTYPE" == "darwin"* ]]; then # syntax highlighting ZSH_SYNTAX_HIGH="/usr/local/opt/zsh-fast-syntax-highlighting/share/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"