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)
This commit is contained in:
parent
e8a4944a11
commit
fc036396a0
4
.bashrc
4
.bashrc
|
@ -1,5 +1,5 @@
|
|||
if [[ "$OSTYPE" == "freebsd"* ]]; then
|
||||
echo "FreeBSD"
|
||||
echo "WIP: FreeBSD"
|
||||
elif [[ "$OSTYPE" == "openbsd"* ]]; then
|
||||
echo "OpenBSD"
|
||||
echo "WIP: OpenBSD"
|
||||
fi
|
||||
|
|
|
@ -8,7 +8,6 @@ if [[ $(pidof mpv) ]]; then
|
|||
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
|
||||
fi
|
||||
|
|
|
@ -6,30 +6,21 @@ 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
|
||||
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
|
||||
|
||||
case "$VOL" in
|
||||
|
||||
|
@ -74,5 +65,4 @@ then
|
|||
;;
|
||||
|
||||
esac
|
||||
|
||||
fi
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'caddy-vishwambhar'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'gitea-chitragupta'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'gitea-govinda'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'hugo-mahayogi'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'hugo-vaikunthnatham'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'nextcloud-chitragupta'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'nextcloud-govinda'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'nextcloud-karma'
|
|
@ -0,0 +1,3 @@
|
|||
To: thefirst1322@gmail.com
|
||||
From: DOWNTIME ALERT (bluefeds)
|
||||
Subject: Restarted 'transmission-raadhe'
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
6
.zshrc
6
.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"
|
||||
|
|
Loading…
Reference in New Issue